Unprocessable Entity when creating order from Billing Agreement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I was trying to follow the following Guide to create an order and capture payment for it from a billing agreement. So far I managed to use the Billing Agreement to create payments using the deprecated `/v1/payments/payment` API, but when creating the order I am getting a 422 response with error `
Steps:
1. Create Agreement Token Request:
Request Body:
Response (201):
2. Agreement approved as a buyer
3. Agreement Created from Agreement Token
Request Body:
Response (201):
4. Attempt to create order from Billing Agreement:
Request Body:
Response (422):
Your help would be greatly appreciated. Thanks.
Best regards,
Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @brianzammit ,
Thank you for posting to the PayPal Community.
Here is another way you can use the billing agreement to process a payment:
POST https://api-m.sandbox.paypal.com/v1/payments/payment
{
"intent": "sale",
"payer":
{
"payment_method": "PAYPAL",
"funding_instruments": [
{
"billing":
{
"billing_agreement_id": "B-9BS46477KS1858732"
}
}]
},
"transactions": [
{
"amount":
{
"currency": "USD",
"total": "55.00"
},
"description": "Payment transaction.",
"custom": "Payment custom field.",
"note_to_payee": "Note to payee field.",
"invoice_number": "invoice777",
"item_list":
{
"items": [
{
"sku": "skuitemNo1",
"name": "ItemNo1",
"description": "The item description.",
"quantity": "1",
"price": "55.00",
"currency": "USD",
"tax": "0",
"url": "https://example.com/"
}]
}
}],
"redirect_urls":
{
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
Thanks,
Jennifer
MTS
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @MTS_Jennifer ,
Thank you for your reply! As indicated in my message, I have already managed to use the billing agreement to process a payment using the `v1/payments` API.
However, I was trying to work with the `v2/orders` API to avoid integrating with the deprecated `v1/payments` API. According to the documentation:
You pass the ID of the billing agreement in the JSON request body of a /v1/payments/payment call or a v2/orders call.
Is it possible to please clarify whether such integration should work, and maybe refer me to some additional documentation?
Thanks.
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @brianzammit ,
I did some testing, after you have the billing agreement id. Create an order like you normally would with orders v2 api.
https://api.sandbox.paypal.com/v2/checkout/orders POST with access_token
{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "123 W Main St",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95112",
"country_code": "US"
}
}
}
],
"application_context" : {
"return_url" : "http://www.example.com",
"cancel_url" : "http://cancel_url.com",
"error_url" : "http://errorurl.com",
"shipping_preference" : "SET_PROVIDED_ADDRESS"
}
}
Then in the Capture Call include the billing agreement as seen in below example:
POST https://api.sandbox.paypal.com/v2/checkout/orders/{{order_id}}/capture
{
"payment_source": {
"token": {
"id": "B-5SP65488AJ588XXXXX",
"type": "BILLING_AGREEMENT"
}
}
}
Thanks,
Jennifer
MTS
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @MTS_Jennifer .
Will try it out and get back to you if I encounter any further issues.
Best regards,
Brian

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Getting an error when calling API endpoint for Create Billing Agreement Token V1 in Sandbox Environment
- This merchant account is not permitted to create Merchant Initiated Billing Agreement in PayPal Payments Standard
- can we assign a unique detail to every subscription creation? in NVP/SOAP APIs
- This merchant account is not permitted to create Merchant Initiated Billing Agreement in Braintree Client-side Integration (JS, iOS, Android SDKs)
- how to capture a MERCHANT initiated transaction using restAPI v2 and v3 enpoints in REST APIs