I'm trying to make a website which sells items from different sellers to differen people. I'm using the PHP SDK, and I cannot set the email of the payee in the request body. I have already checked the documentation, and according to paypal-orders-v2-payee-object-in-checkout-php-sdk-fails-with-amount-error, the placement is wrong, so I fixed accordingly. But my response (from the create order) shows that the payee is different from what I've set.
Here is the request generation function inside createorder.php, which is called when the user clicks on the pay button.
function buildRequestBody()
{
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'return_url' => 'https://example.com/return',
'cancel_url' => 'https://example.com/cancel'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'EUR',
'value' => '221.00'
),
array(
'payee' =>
array(
'email_address' => 'sb-qloys3515897@business.example.com'//a business account which I created (sandbox)
)
)
)
)
);
}
Here is what the order creation returns:
{
"statusCode": 201,
"result": {
"id": "5P300384200963842",
"intent": "CAPTURE",
"status": "CREATED",
"purchase_units": [
{
"reference_id": "default",
"amount": {
"currency_code": "EUR",
"value": "221.00"
},
"payee": {
"email_address": "sb-acw7h3524652@business.example.com",//the email is different (this is actually the sandbox's default business account)
"merchant_id": "HYDLKKLS2AC9G"
}
}
],
"create_time": "2020-10-22T18:01:17Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/5P300384200963842",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/checkoutnow?token=5P300384200963842",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/5P300384200963842",
"rel": "update",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/5P300384200963842/capture",
"rel": "capture",
"method": "POST"
}
]
},
"headers": {
"": "",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
"Content-Length": "748",
"Content-Type": "application/json",
"Date": "Thu, 22 Oct 2020 18",
"Paypal-Debug-Id": "88a1fa19cd8c9"
}
}
The payee object array is still in the wrong place. Does this adjusted sample work for you? (not tested)
private static function buildRequestBody()
{
return array(
'intent' => 'AUTHORIZE',
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => '220.00'
),
'payee' =>
array(
'email_address' => 'payee@email.com'
)
)
)
);
}