ruby - How do I insert X-PAYPAL headers with Rails Invoice SDK? -
i'm using paypal sdk invoicing located here: https://github.com/paypal/invoice-sdk-ruby
this works great.
i integrated paypal permissions sdk rails: https://github.com/paypal/permissions-sdk-ruby
the authorization workflow working great.
so need put them together. documentation permissions sdk leaves off after token. doesn't explain how use other paypal sdks (at least not understand :d ) invoice sdk tells see auth sdk.
paypal tells me:
# third-party auth headers -h "x-paypal-security-subject:<receiveredress>" # merchant's paypal e-mail -h "x-paypal-authentication:<oauthsig>" # generated oauth signature don't know how insert that. request generated here in model:
@create_and_send_invoice = api.build_create_and_send_invoice(paypalized || default_api_value) the data assembled in invoice model so:
paypalized = { :access_token => self.user.paypal_token, :invoice => { :merchantemail => self.user.paypal_email || self.user.email, :payeremail => self.client.email, :itemlist => @itemlist, :currencycode => "usd", :paymentterms => "dueonreceipt", :invoicedate => self.updated_at, :number => self.name, :note => self.description, :merchantinfo => @businessinfo # project / invoice title? } # end invoice } # end paypalized return paypalized this implementation not working , access_token field being rejected. looked through gems associated sdks can't see headers built or how interact that.
update: found gives me clue...
invoice_http_header = { "x-paypal-request-source" => "invoice-ruby-sdk-#{version}" } this seems used here during calls in paypal-sdk-invoice gem:
# service call: createandsendinvoice # @param createandsendinvoicerequest # @return createandsendinvoiceresponse def createandsendinvoice(options = {} , http_header = {}) request_object = buildcreateandsendinvoice(options) request_hash = request_object.to_hash ... i notice there's 2 arguments: options , http_header. it's possible can modify http_header argument , pass way in controller:
@create_and_send_invoice_response = api.create_and_send_invoice(@create_and_send_invoice, @cutsom_header) or maybe
@create_and_send_invoice = api.build_create_and_send_invoice(data, custom_header) i'll keep updated since googled around lot , couldn't find clear answers on how this...
you have pass token , token_secret while creating api object third-party authentication.
@api = paypal::sdk::invoice::api.new({ :token => "replace token", :token_secret => "replace token-secret" })
Comments
Post a Comment