用无效的美国地址覆盖送货地址



我想用无效的美国地址覆盖PayPal的送货地址。我确实在https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/中读到,我只需要使用ADDROVERRIDE=1,然后使用PAYMENTREQUEST_0_SHIPTOSTREET覆盖地址(加上一些其他相关参数)。

然而,文档指南对我不起作用。这将工作,如果送货地址是位于美国以外。我已经设置了一个测试应用程序,代码如下:

class HomeController < ApplicationController
  def index
  end
  def pay
    paypal_options = {
      no_shipping: true, # if you want to disable shipping information
      allow_note: false, # if you want to disable notes
      pay_on_paypal: true # if you don't plan on showing your own confirmation step
    }
    response = paypal_request.setup(
      payment_request,
      'http://localhost:3000/done',
      'http://localhost:3000/done',
      paypal_options  # Optional
    )
    redirect_to response.redirect_uri
  rescue Paypal::Exception::HttpError, Paypal::Exception::APIError => e
    puts "------- ERROR"
    puts e.response.details.map(&:long_message).join("")
  end
  def done
    @response = paypal_request.checkout!(
      params[:token],
      params[:PayerID],
      payment_request
    )
  end
  private
  def payment_request
    Paypal::Payment::Request.new(
      :description   => "Some description",    # item description
      :quantity      => 1,      # item quantity
      :amount        => 1.00,   # item value
      :custom_fields => {
        METHOD: 'SetExpressCheckout',
        ADDROVERRIDE: 1,
        REQCONFIRMSHIPPING: 0,
        :"PAYMENTREQUEST_{n}_SHIPTONAME" => 'Donna W. Brogan',
        :"PAYMENTREQUEST_{n}_SHIPTOCITY" => 'Oak Lawns',
        :"PAYMENTREQUEST_{n}_SHIPTOSTREET" => '4223 Flinderation Road',
        :"PAYMENTREQUEST_{n}_SHIPTOSTREET2" => '',
        :"PAYMENTREQUEST_{n}_SHIPTOSTATE" => 'IL',
        :"PAYMENTREQUEST_{n}_SHIPTOCOUNTRYCODE" => 'US',
        :"PAYMENTREQUEST_{n}_SHIPTOZIP" => '60453'
      }
    )
  end
  def paypal_request
    Paypal::Express::Request.new(
      :username   => PAYPAL_CONFIG[:username],
      :password   => PAYPAL_CONFIG[:password],
      :signature  => PAYPAL_CONFIG[:signature]
    )
  end
end

地址无效,因为没有Oak Lawns,请注意额外的s

得到的错误是:

Shipping Address Invalid City State Postal Code

这些是基于调试器发送的参数:

ADDROVERRIDE=1
&ALLOWNOTE=0
&CANCELURL=http%3A%2F%2Flocalhost%3A3000%2Fdone
&METHOD=SetExpressCheckout
&NOSHIPPING=1
&PAYMENTREQUEST_0_AMT=1.00
&PAYMENTREQUEST_0_DESC=Some+description
&PAYMENTREQUEST_0_SHIPPINGAMT=0.00
&PAYMENTREQUEST_0_SHIPTOCITY=Oak+Lawns
&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=US
&PAYMENTREQUEST_0_SHIPTONAME=Donna+W.+Brogan
&PAYMENTREQUEST_0_SHIPTOSTATE=IL
&PAYMENTREQUEST_0_SHIPTOSTREET2=
&PAYMENTREQUEST_0_SHIPTOSTREET=4223+Flinderation+Road
&PAYMENTREQUEST_0_SHIPTOZIP=60453
&PAYMENTREQUEST_0_TAXAMT=0.00
&REQCONFIRMSHIPPING=0
&RETURNURL=http%3A%2F%2Flocalhost%3A3000%2Fdone

如果我将城市更改为Oak Lawn,这是一个有效的送货地址,这将工作得很好。我使用https://github.com/nov/paypal-express gem用于此目的。

PayPal默认使用USPS格式验证美国地址,这意味着当你用无效的地址"覆盖"买家的帐户存储地址时,它会出错,不会让你通过。查看地址处理过程

相关内容

  • 没有找到相关文章

最新更新