Create a paypal payment
To create a new paypal payment, send a
POST
request to the
/api/paypal_payments
endpoint, passing the resource arguments in the request body.
The following table contains the list of all the possible arguments, along with their type, description and examples values.
All the arguments marked as
required must be present in the request.
Arguments:
The URL where the payer is redirected after they approve the payment.
Example:
https://yourbrand.com/thankyou
The URL where the payer is redirected after they cancel the payment.
Example:
https://yourbrand.com/checkout/payment
A free-form field that you can use to send a note to the payer on PayPal.
Example:
Thank you for shopping with us!
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
The order associated to the paypal payment, that is set as its payment source.
Example request:
POST /api/paypal_payments HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "paypal_payments",
"attributes": {
"return_url": "https://yourbrand.com/thankyou",
"cancel_url": "https://yourbrand.com/checkout/payment"
},
"relationships": {
"order": {
"data": {
"type": "orders",
"id": "1234"
}
}
}
}
}
Example response: 201 Created
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
{
"data": {
"id": "1234",
"type": "paypal_payments",
"links": {
"self": "https://your-brand.commercelayer.io/api/paypal_payments/1234"
},
"attributes": {
"return_url": "https://yourbrand.com/thankyou",
"cancel_url": "https://yourbrand.com/checkout/payment",
"note_to_payer": "Thank you for shopping with us!",
"paypal_payer_id": "ABCDEFG123456",
"name": "ABCDEFG123456",
"paypal_id": "1234567890",
"status": "created",
"approval_url": "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1234567890ABCDEFG",
"id": "1234",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANYREFEFERNCE",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"order": {
"links": {
"self": "https://your-brand.commercelayer.io/api/paypal_payments/1234/relationships/order",
"related": "https://your-brand.commercelayer.io/api/paypal_payments/1234/order"
}
}
},
"meta": {
"mode": "test"
}
}
}