Reputation: 23
I tried to send a payment to PayPal. But for some reason I only get a MALFORMED_REQUEST error. There are no more information. Not even with the getData() function for the exception.
Here is the compiled JSON:
{
"intent": "sale",
"payer": {
"payment_method": "paypal",
"payer_info": {
"first_name": "Testvorname",
"last_name": "Testnachname",
"email": "[email protected]",
"suffix": "Herr"
}
},
"transactions": [
{
"amount": {
"currency": "EUR",
"total": "72.00"
},
"item_list": {
"items": [
{
"quantity": "4",
"name": "test1",
"price": "8",
"currency": "EUR"
},
{
"quantity": "2",
"name": "test2",
"price": "20",
"currency": "EUR"
}
]
}
}
],
"redirect_urls": {
"return_url": "https://www.google.de",
"cancel_url": "https://www.google.de"
} }
I have no Idea what could be wrong with this JSON. I'm using the PHP SDK.
Upvotes: 2
Views: 3312
Reputation: 1489
The issue is not in the SDK. The data that you are passing to the paypal server is causing this issue. The error message was not obvious here though.
You do not need to pass "payer_info" in the "payer" object. Removing that fixes the issue. Here is how the JSON would look like:
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"currency": "EUR",
"total": "72.00"
},
"item_list": {
"items": [
{
"quantity": "4",
"name": "test1",
"price": "8",
"currency": "EUR"
},
{
"quantity": "2",
"name": "test2",
"price": "20",
"currency": "EUR"
}
]
}
}
],
"redirect_urls": {
"return_url": "https://www.google.de",
"cancel_url": "https://www.google.de"
}
}
For more information you could always use the samples provided in the SDK, and the documentation that helps you quickly help you debug issues, etc.
Here are some useful links:
Upvotes: 1