Search code examples
paypalpaypal-sandbox

PayPal JS SDK buttons and Orders API: How to set the billing address country?


I'm trying to change the default billing country in the PayPal payment form with no luck.

I'm using this link as reference and have tried different combinations of parameters already. https://developer.paypal.com/docs/api/orders/v2/#orders_create

Here is my code so far.

var request = new CreateOrderRequest
{
    intent = "CAPTURE",
    purchase_units = new List<PurchaseUnit>
    {
        new()
        {
            reference_id = reference,
            amount = new Amount
            {
                currency_code = currency,
                value = value
            }
        }
    },
    payment_source = new PaymentSource
    {
        card = new Card
        {
            billing_address = new Address
            {
                country_code = "GB",
            }
        }
    }
};

enter image description here

I passed the country code as "GB" to change the default billing country in the PayPal form.

I expect it to change to United Kingdom, but the default country is still showing US.


Solution

  • The product you are using, that black button, processes payments of type "paypal" in the PayPal system. You will not be able to distinguish them as being "card" payments (although there is a way to tell that the black card button was clicked, separate topic though it does not mean a card was ultimately used to pay)

    Anyway, for what you are doing you need the payment_source to be "paypal". Set the address there.

    Here it is in the JSON format used by the REST API call:

      "payment_source": {
        "paypal" : {
          "address" : {
            "country_code": "GB"
          }
        }
      }
    

    And the result (testing confirmed)

    enter image description here