简体   繁体   中英

Customized location choices in Django/JS/Paypal Buttons Integration

Below I have my Payal Checkout setup. User can input any address they want but I want to limit the country, State/Province, and City choices they have with a dropdown menu.

我的贝宝结帐

Does anyone know how to do that? or any alternate options for this?

You cannot limit a user's billing address, it is outside your control They are free to enter any billing address.

If you prompt for a shipping address using your own form before displaying the buttons, you can pass that shipping address to PayPal and use the application_context object's SET_PROVIDED_ADDRESS object to force the use of the shipping address you have collected and validated.

For example:

"application_context": {
  "shipping_preference": "SET_PROVIDED_ADDRESS"
},
"purchase_units": [{
  "shipping": {
    "address": {
      "address_line_1": "123 Sunny Lane",
      "admin_area_2": "Phoenix",
      "admin_area_1": "AZ",
      "postal_code": "85001",
      "country_code": "US",
    },
    "name": {
      "full_name":"John Doe",
    }
  },
  "amount": {
    "currency_code": "USD",
    "value": "123.45"
  },
}]

PayPal doesn't recommend this integation, for two reasons:

1) If you collect an invalid address, the payment attempt will be rejected with an error (since you are forcing that address to be used), and checkout cannot proceed.

2) You are adding friction to the checkout process by forcing users to manually enter an address. Much of the benefit of the "PayPal" payment method, apart from security, is the ability to check out without having to type any payment or shipping information -- it's all all pre-saved in the buyer's account, allowing them to make a snap payment decision, thus increasing your site's sales "conversion" rate.

But well, there you go if you have this business need of controlling the addresses before the customer enters a checkout flow. This same v2/orders syntax applies to client-side JavaScript buttons, or a server-side API-based integration (interacting with the appropriate front-end for buttons)

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