我无法使用rest api sdk向paypal发送送货选项
这是@ payment.error.inspect
{
"name"=>"VALIDATION_ERROR",
"details"=>[
{
"field"=>"payer.payer_info.phone",
"issue"=>"This field currently not supported in this request" },
{
"field"=>"payer.payer_info.first_name",
"issue"=>"Not valid to specify this field in a request" },
{
"field"=>"payer.payer_info.last_name",
"issue"=>"Not valid to specify this field in a request" },
{
"field"=>"payer.payer_info.email",
"issue"=>"This field currently not supported in this request" },
{
"field"=>"payer.payer_info.shipping_address",
"issue"=>"Not valid to specify this field in a request" }
],
"message"=>"Invalid request - see details",
"information_link"=>"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR",
"debug_id"=>"2139ec6f8c916"
}
当我这样做时:
shipping_address = {
recipient_name: self.order.fullname,
type: self.order.address_type,
line1: self.order.street1,
line2: self.order.street2,
city: self.order.city,
country_code: self.order.country_code,
postal_code: self.order.zip,
state: self.order.state,
phone: self.order.phone_number }
payer_info = {
email: self.order.email,
first_name: self.order.fullname.split(" ").first,
last_name: self.order.fullname.split(" ").last,
phone: self.order.phone_number,
shipping_address: shipping_address }
self.payment = Payment.new({
:intent => "sale",
:payer => {
:payment_method => "paypal",
:payer_info => payer_info },
:redirect_urls => {
:return_url => return_url,
:cancel_url => cancel_url },
:transactions => [{
:item_list => {
:shipping_address => shipping_address,
:items => self.order.order_items.map do |item|
{
:name => _("T-shirts %{size} size") % {size: item.size},
:sku => "item",
:price => self.order.campaign.price_for_size(item.size),
:currency => "HKD",
:quantity => item.count,
:amount => item.price
}
end},
:amount => {
:total => self.order.price,
:currency => "HKD" },
:description => _("This is the payment transaction description.") }]})
self.payment.create
self.payment.error.inspect
我使用的是paypal-rest-sdk,需要将有关买家的信息发送到PayPal,以获取包含地址和买家信息的预先填写的字段。
如何发送到paypal送货地址和payer_info?
答案 0 :(得分:1)
当您的payment_method为" paypal"时,payer_info对象已预先填写。只有在payment_method为credit_card
时才需要提交payer_info