PayPal rejects my request to create an order (400 bad Request) if I include the customer's phone number.
I am using the V2 Orders API, using C and CURL.
Here is an example of the JSON data I POST to
https://api.sandbox.paypal.com/v2/checkout/orders
{
intent:"CAPTURE",
payer:
{
name:
{
given_name:"BOB",
surname:"SMITH"
},
email_address:"bob#domain.com",
phone:
{
country_code:"011",
national_number:"4162876593"
},
address:
{
address_line_1:"4180 YONGE STREET",
admin_area_2:"TORONTO",
admin_area_1:"ON",
postal_code:"M1S 2A9",
country_code:"CA"
}
},
purchase_units:
[
{
amount:
{
currency_code:"CAD",
value:"90.00"
}
}
],
application_context:
{
brand_name:"Benefit Gala",
landing_page:"LOGIN",
shipping_preference:"NO_SHIPPING",
user_action:"PAY_NOW",
payment_method:
{
payee_preferred:"IMMEDIATE_PAYMENT_REQUIRED"
},
return_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y",
cancel_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C"
}
}
I have tried a large variety of ways of specifying the phone number.
phone:{ country_code:"01", national_number:"14162876593" },
phone:{ country_code:"01", phone_number: { national_number:"14162876593" } },
and many others.
If I omit the phone number entirely, my request is accepted and the order is created and it can be subsequently captured.
If I include any variant of a phone number object, I get a 400 Bad Request returned.
Somewhere in the PayPal documentation it mentions that in order for the phone number to "be available" it is necessary to turn on Contact Number Required in the merchant account preferences. I have tried all three choices (On, Off, Optional) without effect.
The PayPal documentation has very few detailed examples and most of what I find with Google is for a language library like Java or PHP, which doesn't help me.
Is anyone passing a payer phone number when creating an order ? A sample of your JSON please !
The payer's definition (from the api doc) states that:
The phone.phone_number supports only national_number
So I don't think it'll accept the the country code.
Also the phone attribute in the payer's definition is of type phone_with_type :
So its content should follow this structure:
{
"phone_type" : "HOME",
"phone_number" : {
"national_number" : "4162876593"
}
}
I'm not familiar with paypal's api, but it seems to me (unless I'm mistaken) that your example doesn't match what's described the api's documentation.
Here is an example from paypal's documentation that I think is similar to what you want to do :
<script>paypal.Buttons({
enableStandardCardFields: true,
createOrder: function(data, actions) {
return actions.order.create({
intent: 'CAPTURE',
payer: {
name: {
given_name: "PayPal",
surname: "Customer"
},
address: {
address_line_1: '123 ABC Street',
address_line_2: 'Apt 2',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95121',
country_code: 'US'
},
email_address: "customer#domain.com",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "14082508100"
}
}
},
purchase_units: [
{
amount: {
value: '15.00',
currency_code: 'USD'
},
shipping: {
address: {
address_line_1: '2211 N First Street',
address_line_2: 'Building 17',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95131',
country_code: 'US'
}
},
}
]
});
}
}).render("body");
</script>
Update : Test program and results from Paypal's Sandbox
I added a test program at the end of the answer (and its output from my testing).
The program sends 4 requests using 4 json payloads:
the 1st one is the same as the example from the question.
the 2nd one is the same as the 1st without the phone attribute
the 3rd one is the same as the 1st but all the attribute names are quoted
the 4th one is the same as the 3rd one but the phone attribute structure follows the definition from the api doc.
In my testing (in paypal's sandbox), the first 3 jsons result in a response with a 400 Bad Request status code. Only the 4th one works and result in a response with a 201 Created status code.
Test Program
Before using the program the string ACCESS_TOKEN_HERE should be replaced by a valid access token (how to generate it).
To build the program with gcc : gcc -lcurl -o test-paypal test-paypal.c
#include <stdio.h>
#include <curl/curl.h>
void create_order(CURL* curl, char* payload, struct curl_slist *auth_header){
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://api-m.sandbox.paypal.com/v2/checkout/orders");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, auth_header);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
res = curl_easy_perform(curl);
long http_code = 0;
curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code);
if (http_code >= 200 && http_code < 300 && res != CURLE_ABORTED_BY_CALLBACK)
{
printf("\n******************************** SUCCESS *********************************");
printf("\n******************************** SUCCESS *********************************");
printf("\n******************************** SUCCESS *********************************\n");
}
else
{
printf("\n******************************** ERROR *********************************");
printf("\n******************************** ERROR *********************************");
printf("\n******************************** ERROR *********************************\n");
}
}
int main(char** args){
char* request1 = "{\n"
" intent:\"CAPTURE\",\n"
" payer:{\n"
" name:{\n"
" given_name:\"BOB\",\n"
" surname:\"SMITH\"\n"
" },\n"
" email_address:\"bob#domain.com\",\n"
" phone:{\n"
" country_code:\"011\",\n"
" national_number:\"4162876593\"\n"
" },\n"
" address:{\n"
" address_line_1:\"4180 YONGE STREET\",\n"
" admin_area_2:\"TORONTO\",\n"
" admin_area_1:\"ON\",\n"
" postal_code:\"M1S 2A9\",\n"
" country_code:\"CA\"\n"
" }\n"
" },\n"
" purchase_units:[\n"
" {\n"
" amount:{\n"
" currency_code:\"CAD\",\n"
" value:\"90.00\"\n"
" }\n"
" }\n"
" ],\n"
" application_context:{\n"
" brand_name:\"Benefit Gala\",\n"
" landing_page:\"LOGIN\",\n"
" shipping_preference:\"NO_SHIPPING\",\n"
" user_action:\"PAY_NOW\",\n"
" payment_method:{\n"
" payee_preferred:\"IMMEDIATE_PAYMENT_REQUIRED\"\n"
" },\n"
" return_url:\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y\",\n"
" cancel_url:\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C\"\n"
" }\n"
"}";
char* request2 = "{\n"
" intent:\"CAPTURE\",\n"
" payer:{\n"
" name:{\n"
" given_name:\"BOB\",\n"
" surname:\"SMITH\"\n"
" },\n"
" email_address:\"bob#domain.com\",\n"
" address:{\n"
" address_line_1:\"4180 YONGE STREET\",\n"
" admin_area_2:\"TORONTO\",\n"
" admin_area_1:\"ON\",\n"
" postal_code:\"M1S 2A9\",\n"
" country_code:\"CA\"\n"
" }\n"
" },\n"
" purchase_units:[\n"
" {\n"
" amount:{\n"
" currency_code:\"CAD\",\n"
" value:\"90.00\"\n"
" }\n"
" }\n"
" ],\n"
" application_context:{\n"
" brand_name:\"Benefit Gala\",\n"
" landing_page:\"LOGIN\",\n"
" shipping_preference:\"NO_SHIPPING\",\n"
" user_action:\"PAY_NOW\",\n"
" payment_method:{\n"
" payee_preferred:\"IMMEDIATE_PAYMENT_REQUIRED\"\n"
" },\n"
" return_url:\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y\",\n"
" cancel_url:\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C\"\n"
" }\n"
"}";
char* request3 = "{\n"
" \"intent\":\"CAPTURE\",\n"
" \"payer\":{\n"
" \"name\":{\n"
" \"given_name\":\"BOB\",\n"
" \"surname\":\"SMITH\"\n"
" },\n"
" \"email_address\":\"bob#domain.com\",\n"
" \"phone\":{\n"
" \"country_code\":\"011\",\n"
" \"national_number\":\"4162876593\"\n"
" },\n"
" \"address\":{\n"
" \"address_line_1\":\"4180 YONGE STREET\",\n"
" \"admin_area_2\":\"TORONTO\",\n"
" \"admin_area_1\":\"ON\",\n"
" \"postal_code\":\"M1S 2A9\",\n"
" \"country_code\":\"CA\"\n"
" }\n"
" },\n"
" \"purchase_units\":[\n"
" {\n"
" \"amount\":{\n"
" \"currency_code\":\"CAD\",\n"
" \"value\":\"90.00\"\n"
" }\n"
" }\n"
" ],\n"
" \"application_context\":{\n"
" \"brand_name\":\"Benefit Gala\",\n"
" \"landing_page\":\"LOGIN\",\n"
" \"shipping_preference\":\"NO_SHIPPING\",\n"
" \"user_action\":\"PAY_NOW\",\n"
" \"payment_method\":{\n"
" \"payee_preferred\":\"IMMEDIATE_PAYMENT_REQUIRED\"\n"
" },\n"
" \"return_url\":\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y\",\n"
" \"cancel_url\":\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C\"\n"
" }\n"
"}";
char *request4 = "{\n"
" \"intent\":\"CAPTURE\",\n"
" \"payer\":{\n"
" \"name\":{\n"
" \"given_name\":\"BOB\",\n"
" \"surname\":\"SMITH\"\n"
" },\n"
" \"email_address\":\"bob#domain.com\",\n"
" \"phone\":{\n"
" \"phone_type\":\"HOME\",\n"
" \"phone_number\":{\n"
" \"national_number\":\"4162876593\"\n"
" }\n"
" },\n"
" \"address\":{\n"
" \"address_line_1\":\"4180 YONGE STREET\",\n"
" \"admin_area_2\":\"TORONTO\",\n"
" \"admin_area_1\":\"ON\",\n"
" \"postal_code\":\"M1S 2A9\",\n"
" \"country_code\":\"CA\"\n"
" }\n"
" },\n"
" \"purchase_units\":[\n"
" {\n"
" \"amount\":{\n"
" \"currency_code\":\"CAD\",\n"
" \"value\":\"90.00\"\n"
" }\n"
" }\n"
" ],\n"
" \"application_context\":{\n"
" \"brand_name\":\"Benefit Gala\",\n"
" \"landing_page\":\"LOGIN\",\n"
" \"shipping_preference\":\"NO_SHIPPING\",\n"
" \"user_action\":\"PAY_NOW\",\n"
" \"payment_method\":{\n"
" \"payee_preferred\":\"IMMEDIATE_PAYMENT_REQUIRED\"\n"
" },\n"
" \"return_url\":\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y\",\n"
" \"cancel_url\":\"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C\"\n"
" }\n"
"}";
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN_HERE");
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
printf("\n*************************************************************");
printf("\n****************** REQUEST 1 ********************************");
printf("\n*************************************************************\n");
printf("%s\n", request1);
create_order(curl, request1, headers);
printf("\n*************************************************************");
printf("\n****************** REQUEST 2 ********************************");
printf("\n*************************************************************\n");
printf("%s\n", request2);
create_order(curl, request2, headers);
printf("\n*************************************************************");
printf("\n****************** REQUEST 3 ********************************");
printf("\n*************************************************************\n");
printf("%s\n", request3);
create_order(curl, request3, headers);
printf("\n*************************************************************");
printf("\n****************** REQUEST 4 ********************************");
printf("\n*************************************************************\n");
printf("%s\n", request4);
create_order(curl, request4, headers);
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
Output of the test program
*************************************************************
****************** REQUEST 1 ********************************
*************************************************************
{
intent:"CAPTURE",
payer:{
name:{
given_name:"BOB",
surname:"SMITH"
},
email_address:"bob#domain.com",
phone:{
country_code:"011",
national_number:"4162876593"
},
address:{
address_line_1:"4180 YONGE STREET",
admin_area_2:"TORONTO",
admin_area_1:"ON",
postal_code:"M1S 2A9",
country_code:"CA"
}
},
purchase_units:[
{
amount:{
currency_code:"CAD",
value:"90.00"
}
}
],
application_context:{
brand_name:"Benefit Gala",
landing_page:"LOGIN",
shipping_preference:"NO_SHIPPING",
user_action:"PAY_NOW",
payment_method:{
payee_preferred:"IMMEDIATE_PAYMENT_REQUIRED"
},
return_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y",
cancel_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C"
}
}
* Trying 151.101.65.35:443...
* Connected to api-m.sandbox.paypal.com (151.101.65.35) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=Delaware; serialNumber=3014267; C=US; ST=California; L=San Jose; O=PayPal, Inc.; CN=www.sandbox.paypal.com
* start date: Jun 2 00:00:00 2021 GMT
* expire date: Mar 24 23:59:59 2022 GMT
* subjectAltName: host "api-m.sandbox.paypal.com" matched cert's "api-m.sandbox.paypal.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0xa65310)
> POST /v2/checkout/orders HTTP/2
Host: api-m.sandbox.paypal.com
accept: */*
content-type: application/json
authorization: Bearer REMOVED_ACCESS_TOKEN
content-length: 982
* We are completely uploaded and fine
< HTTP/2 400
< content-type: application/json
< server: nginx/1.14.0 (Ubuntu)
< cache-control: max-age=0, no-cache, no-store, must-revalidate
< paypal-debug-id: f724c871e93df
< strict-transport-security: max-age=31536000; includeSubDomains
< accept-ranges: bytes
< via: 1.1 varnish, 1.1 varnish
< edge-control: max-age=0
< date: Wed, 14 Jul 2021 21:43:56 GMT
< x-served-by: cache-lhr6623-LHR, cache-cdg20728-CDG
< x-cache: MISS, MISS
< x-cache-hits: 0, 0
< x-timer: S1626299036.618323,VS0,VE589
< content-length: 356
<
* Connection #0 to host api-m.sandbox.paypal.com left intact
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"f724c871e93df","details":[{"location":"body","issue":"MALFORMED_REQUEST_JSON"}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MALFORMED_REQUEST_JSON","rel":"information_link","encType":"application/json"}]}
******************************** ERROR *********************************
******************************** ERROR *********************************
******************************** ERROR *********************************
*************************************************************
****************** REQUEST 2 ********************************
*************************************************************
{
intent:"CAPTURE",
payer:{
name:{
given_name:"BOB",
surname:"SMITH"
},
email_address:"bob#domain.com",
address:{
address_line_1:"4180 YONGE STREET",
admin_area_2:"TORONTO",
admin_area_1:"ON",
postal_code:"M1S 2A9",
country_code:"CA"
}
},
purchase_units:[
{
amount:{
currency_code:"CAD",
value:"90.00"
}
}
],
application_context:{
brand_name:"Benefit Gala",
landing_page:"LOGIN",
shipping_preference:"NO_SHIPPING",
user_action:"PAY_NOW",
payment_method:{
payee_preferred:"IMMEDIATE_PAYMENT_REQUIRED"
},
return_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y",
cancel_url:"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C"
}
}
* Found bundle for host api-m.sandbox.paypal.com: 0xa62db0 [can multiplex]
* Re-using existing connection! (#0) with host api-m.sandbox.paypal.com
* Connected to api-m.sandbox.paypal.com (151.101.65.35) port 443 (#0)
* Using Stream ID: 3 (easy handle 0xa65310)
> POST /v2/checkout/orders HTTP/2
Host: api-m.sandbox.paypal.com
accept: */*
content-type: application/json
authorization: Bearer REMOVED_ACCESS_TOKEN
content-length: 892
* We are completely uploaded and fine
< HTTP/2 400
< content-type: application/json
< server: nginx/1.14.0 (Ubuntu)
< cache-control: max-age=0, no-cache, no-store, must-revalidate
< paypal-debug-id: c7ac50f5fe921
< strict-transport-security: max-age=31536000; includeSubDomains
< accept-ranges: bytes
< via: 1.1 varnish, 1.1 varnish
< edge-control: max-age=0
< date: Wed, 14 Jul 2021 21:43:56 GMT
< x-served-by: cache-lhr7357-LHR, cache-cdg20728-CDG
< x-cache: MISS, MISS
< x-cache-hits: 0, 0
< x-timer: S1626299036.212274,VS0,VE470
< content-length: 356
<
* Connection #0 to host api-m.sandbox.paypal.com left intact
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"c7ac50f5fe921","details":[{"location":"body","issue":"MALFORMED_REQUEST_JSON"}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MALFORMED_REQUEST_JSON","rel":"information_link","encType":"application/json"}]}
******************************** ERROR *********************************
******************************** ERROR *********************************
******************************** ERROR *********************************
*************************************************************
****************** REQUEST 3 ********************************
*************************************************************
{
"intent":"CAPTURE",
"payer":{
"name":{
"given_name":"BOB",
"surname":"SMITH"
},
"email_address":"bob#domain.com",
"phone":{
"country_code":"011",
"national_number":"4162876593"
},
"address":{
"address_line_1":"4180 YONGE STREET",
"admin_area_2":"TORONTO",
"admin_area_1":"ON",
"postal_code":"M1S 2A9",
"country_code":"CA"
}
},
"purchase_units":[
{
"amount":{
"currency_code":"CAD",
"value":"90.00"
}
}
],
"application_context":{
"brand_name":"Benefit Gala",
"landing_page":"LOGIN",
"shipping_preference":"NO_SHIPPING",
"user_action":"PAY_NOW",
"payment_method":{
"payee_preferred":"IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url":"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y",
"cancel_url":"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C"
}
}
* Found bundle for host api-m.sandbox.paypal.com: 0xa62db0 [can multiplex]
* Re-using existing connection! (#0) with host api-m.sandbox.paypal.com
* Connected to api-m.sandbox.paypal.com (151.101.65.35) port 443 (#0)
* Using Stream ID: 5 (easy handle 0xa65310)
> POST /v2/checkout/orders HTTP/2
Host: api-m.sandbox.paypal.com
accept: */*
content-type: application/json
authorization: Bearer REMOVED_ACCESS_TOKEN
content-length: 1038
* We are completely uploaded and fine
< HTTP/2 400
< content-type: application/json
< server: nginx/1.14.0 (Ubuntu)
< cache-control: max-age=0, no-cache, no-store, must-revalidate
< paypal-debug-id: b52221afefcf6
< strict-transport-security: max-age=31536000; includeSubDomains
< accept-ranges: bytes
< via: 1.1 varnish, 1.1 varnish
< edge-control: max-age=0
< date: Wed, 14 Jul 2021 21:43:57 GMT
< x-served-by: cache-lhr7340-LHR, cache-cdg20728-CDG
< x-cache: MISS, MISS
< x-cache-hits: 0, 0
< x-timer: S1626299037.687787,VS0,VE596
< content-length: 468
<
* Connection #0 to host api-m.sandbox.paypal.com left intact
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"b52221afefcf6","details":[{"field":"/payer/phone/phone_number","value":"","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field / parameter is missing."}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MISSING_REQUIRED_PARAMETER","rel":"information_link","encType":"application/json"}]}
******************************** ERROR *********************************
******************************** ERROR *********************************
******************************** ERROR *********************************
*************************************************************
****************** REQUEST 4 ********************************
*************************************************************
{
"intent":"CAPTURE",
"payer":{
"name":{
"given_name":"BOB",
"surname":"SMITH"
},
"email_address":"bob#domain.com",
"phone":{
"phone_type":"HOME",
"phone_number":{
"national_number":"4162876593"
}
},
"address":{
"address_line_1":"4180 YONGE STREET",
"admin_area_2":"TORONTO",
"admin_area_1":"ON",
"postal_code":"M1S 2A9",
"country_code":"CA"
}
},
"purchase_units":[
{
"amount":{
"currency_code":"CAD",
"value":"90.00"
}
}
],
"application_context":{
"brand_name":"Benefit Gala",
"landing_page":"LOGIN",
"shipping_preference":"NO_SHIPPING",
"user_action":"PAY_NOW",
"payment_method":{
"payee_preferred":"IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url":"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=Y",
"cancel_url":"https://Gala.domain.com/cgi-bin/paypal?FZ=4&MF=4&K=SMITH&MR=M&PP=C"
}
}
* Found bundle for host api-m.sandbox.paypal.com: 0xa62db0 [can multiplex]
* Re-using existing connection! (#0) with host api-m.sandbox.paypal.com
* Connected to api-m.sandbox.paypal.com (151.101.65.35) port 443 (#0)
* Using Stream ID: 7 (easy handle 0xa65310)
> POST /v2/checkout/orders HTTP/2
Host: api-m.sandbox.paypal.com
accept: */*
content-type: application/json
authorization: Bearer REMOVED_ACCESS_TOKEN
content-length: 1077
* We are completely uploaded and fine
< HTTP/2 201
< content-type: application/json
< server: nginx/1.14.0 (Ubuntu)
< cache-control: max-age=0, no-cache, no-store, must-revalidate
< paypal-debug-id: 532a3181c034b
< strict-transport-security: max-age=31536000; includeSubDomains
< accept-ranges: bytes
< via: 1.1 varnish, 1.1 varnish
< edge-control: max-age=0
< date: Wed, 14 Jul 2021 21:43:58 GMT
< x-served-by: cache-lhr7357-LHR, cache-cdg20728-CDG
< x-cache: MISS, MISS
< x-cache-hits: 0, 0
< x-timer: S1626299037.296772,VS0,VE954
< content-length: 501
<
* Connection #0 to host api-m.sandbox.paypal.com left intact
{"id":"82447239S1973611B","status":"CREATED","links":[{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/82447239S1973611B","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/checkoutnow?token=82447239S1973611B","rel":"approve","method":"GET"},{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/82447239S1973611B","rel":"update","method":"PATCH"},{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/82447239S1973611B/capture","rel":"capture","method":"POST"}]}
******************************** SUCCESS *********************************
******************************** SUCCESS *********************************
******************************** SUCCESS *********************************
Mohammed, thanks very much for this !!
The unexpected answer is that the quotes around the field names are required. I have seen many examples where they were not included, and in fact it worked fine without those quotes when the phone number was not specified.
The "phone_type" object is ignored, with HOME specified, the number is still displayed by PayPal as MOBILE, but I can live with that.
Thanks again !!