I'm following this tutorial
This is supposed to be my output (desired result):
{
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "ABC123",
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"application_context": {
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}
However, after a PHP array and converting using json_encode I'm getting this result
{
"intent": "CAPTURE",
"purchase_units": {
"reference_id": "ABC123",
"amount": {
"currency_code": "USD",
"value": 100
}
},
"application_context": {
"return_url": "https:\/\/example.com\/return",
"cancel_url": "https:\/\/example.com\/exit"
}
}
The most noticeable differences can be found here - the desired result has "purchase_units": [{ and }], while my output is returning "purchase_units": { and '},' without the square brackets.
This is my PHP code:
$seller = array(
'intent' => 'CAPTURE',
'purchase_units' => array(
'reference_id' => 'ABC123',
'amount' => array(
'currency_code' => 'USD',
'value' => 100.00
),
),
'application_context' => array(
'return_url' => 'https://example.com/return',
'cancel_url' => 'https://example.com/exit',
),
);