PayPal REST API does not take the customized shipping address

喜夏-厌秋 提交于 2019-12-22 06:28:33

问题


I am following the PayPal REST API Reference at https://developer.paypal.com/webapps/developer/docs/api/ to create and execute payments.

To create a payment, I send the following data to PayPal. The data contain "shipping_address". The payment is created successfully.

{
"intent": "sale",
"payer": {
    "payment_method": "paypal"
},
"redirect_urls": {
    "return_url": "http://www.somethingabc.com/approve",
    "cancel_url": "http://www.somethingabc.com/cancel"
},
"transactions": [{
    "amount": {
        "currency": "USD",
        "total": "10.00",
        "details": {
            "shipping": "0.00",
            "subtotal": "10.00",
            "tax": "0.00"
        }
    },
    "item_list": {
        "items": [{
            "quantity": "1",
            "name": "Apples",
            "price": "10.00",
            "currency": "USD"
        }],
        "shipping_address": {
            "recipient_name": "John",
            "type": "residential",
            "line1": "441 Waterdale RD",
            "city": "Heidelberg West",
            "country_code": "AU",
            "postal_code": "3081",
            "state": "VICTORIA"
        }
    }
}]

}

Then, I redirect the web browser to the approval_url (e.g., https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-343434SADSDSAD34) given in the PayPal response for the user to login and approve the payment. The user logins and a PayPal review web page appears. I expect that this review page should show the customized shipping address which I have provided previously when the payment was created. However, the PayPal review web page shows the PayPal owner's address instead.

So, my question is how to force the PayPal review web page to show the customized shipping address instead of the PayPal owner's address? If this can't be done, how can I get the shipping address which the user has selected on the PayPal review web page (when I call the API to execute the payment, the selected shipping address is not included in the payer_info object!).

Thanks.


回答1:


After testing your code I cannot find any errors. The response I get when completing the payment:

{
  "id": "PAY-xxxxxxx",
  "create_time": "2014-05-01T23:54:00Z",
  "update_time": "2014-05-01T23:59:35Z",
  "state": "approved",
  "intent": "sale",
  "payer": {
    "payment_method": "paypal",
    "payer_info": {
      "email": "test@paypal.com",
      "first_name": "John",
      "last_name": "Smith",
      "payer_id": "GPV2878GCMNGE",
      "shipping_address": {
        "line1": "441 Waterdale RD",
        "city": "Heidelberg West",
        "state": "Victoria",
        "postal_code": "3081",
        "country_code": "AU"
      }
    }
  },
  "transactions": [
    {
      "amount": {
        "total": "10.00",
        "currency": "USD",
        "details": {
          "subtotal": "10.00"
        }
      },
      "item_list": {
        "items": [
          {
            "name": "Apples",
            "price": "10.00",
            "currency": "USD",
            "quantity": "1"
          }
        ],
        "shipping_address": {
          "recipient_name": "John",
          "line1": "441 Waterdale RD",
          "city": "Heidelberg West",
          "state": "VICTORIA",
          "postal_code": "3081",
          "country_code": "AU"
        }
      },
      .....
}

If there you are not seeing this I would reach out to Paypal's Technical Support and file a trouble ticket. As this is the response you should get.




回答2:


You will need to create an Experience Profile with the address_override option set to 1. The customer will then be unable to change the shipping address you have passed to PayPal.

You would include the experience_profile_id in your JSON request when initiating the sale.



来源:https://stackoverflow.com/questions/19508080/paypal-rest-api-does-not-take-the-customized-shipping-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!