在paypal上设置送货地址(ruby on rails)

时间:2014-05-12 09:06:03

标签: ruby-on-rails ruby paypal

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)

我需要发送送货地址给paypal。

如何在params中设置送货地址?

1 个答案:

答案 0 :(得分:0)

如有疑问,请查看github SDK page上的示例。

我找到了这个例子:

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"

这让我相信正确的方法是:

    @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)