Paypal API 400 Bad Request response “name”, though request is formed as in documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is my first try.
In sandbox business account I have created two test subscriptions: monthly and yearly and configured application with their id's.
However, when I make a call to API, to create a test subscription, I get weird response that 'name' parameter is formed incorrectly:
php artisan tinker >>> $paypal = resolve(App\Services\PaypalService::class); => App\Services\PaypalService {#3413} >>> $paypal->createSubscription('monthly', 'Test', 'testemail'); GuzzleHttp\Exception\ClientException with message 'Client error: `POST https://api- m.sandbox.paypal.com/v1/billing/subscriptions` resulted in a `400 Bad Request` response: {"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id (truncated...)
This is strange, because in Paypal API doc (see above), the 'name' param is described exactly like that!
Do I miss something or it is Paypal API is acting funky?
This is the method that makes the call:
public function createSubscription($planSlug, $name, $email) { return $this->makeRequest( 'POST', 'v1/billing/subscriptions', [], [ 'plan_id' => $this->plans[$planSlug], 'subscriber' => [ 'name' => [ 'given_name' => $name, ], 'email_address' => $email ], 'application_context'=> [ 'brand_name' => config('app.name'), 'shipping_preference' => 'NO_SHIPPING', 'user_action' => 'SUBSCRIBE_NOW', 'return_url' => route('subscribe.approval', ['plan' => $planSlug]), 'cancel_url'=> route('subscribe.cancelled') ], ], [], $isJsonRequest = true ); }
This is strange, because in Paypal API doc (see above), the 'name' param is described exactly like that!
Do I miss something or it is Paypal API is acting funky?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your request indeed looks correct, but I cannot tell from your error message that the name is what is malformed. It looks like the email address is not valid, though. Have you tried changing that to something valid with an @ in it?
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- SetExpressCheckout 10003 error with ITEMCATEGORY=Digital in NVP/SOAP APIs
- IPN works in sandbox but not live in Sandbox Environment
- Issue with Rendering Trustly Payment Button via PayPal JavaScript SDK in SDKs
- Handling payouts that are being on hold/blocked in REST APIs
- When I do PayPal capture Order, I keep on getting Invalid Request Connection in REST APIs