简体   繁体   中英

Set shipping address on paypal (ruby on rails)

gem 'paypal-sdk-merchant'

@api = PayPal::SDK::Merchant::API.new
params = {:SetExpressCheckoutRequestDetails => payment_params.merge({
        :ReturnURL => return_url,
        :CancelURL => cancel_url,
      })}
@set_express_checkout = @api.build_set_express_checkout(params)

i need send shipping address to paypal.

How to set shipping address in params?

When in doubt, take a look at the samples on the github SDK page .

I found this example:

set_express_checkout:
  SetExpressCheckoutRequestDetails:
    PaymentDetails:
      PaymentAction: Sale
      TaxTotal:
        currencyID: USD
        value: 0
      ShippingMethod: UPSGround
      ShippingTotal:
        currencyID: USD
        value: 3.0
      PaymentDetailsItem:
        Name: Item Name
        Amount:
          currencyID: USD
          value: 5.27
        Quantity: 1
        ItemCategory: Physical
      ShipToAddress:
        Name: John Doe
        Street1: "1 Main St"
        CityName: San Jose
        StateOrProvince: CA
        Country: US
        PostalCode: "95131"

Which leads me to believe the proper way to do it would be:

    @api = PayPal::SDK::Merchant::API.new
    params = {:SetExpressCheckoutRequestDetails => payment_params.merge({
            :ReturnURL => return_url,
            :CancelURL => cancel_url,
            :PaymentDetails => {
                :PaymentDetailsItem => {
                    :Name => "Item Name",
                    :Amount => {
                        :currencyId => "USD",
                        :value => "1.27"
                    }
                },
                :ShipToAddress => {
                    :Name => "John Doe",
                    :Street1 => "1 Main St",
                    :CityName => "San Jose",
                    :StateOrProvince => "CA",
                    :Country => "US",
                    :PostalCode => "95131" 
                }
            }
         }
    )}
    @set_express_checkout = @api.build_set_express_checkout(params)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM