PayPal
Complete PayPal Order
Finalizes the order using the PayPal token and payer id
POST
/
api
/
v1
/
domains
/
{domain}
/
express
/
paypal
/
complete-order
Complete PayPal Order
curl --request POST \
--url https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-firmly-authorization: <x-firmly-authorization>' \
--data '
{
"attributes": {
"paypal_token": "<string>",
"payer_id": "<string>"
}
}
'import requests
url = "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order"
payload = { "attributes": {
"paypal_token": "<string>",
"payer_id": "<string>"
} }
headers = {
"x-firmly-authorization": "<x-firmly-authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-firmly-authorization': '<x-firmly-authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({attributes: {paypal_token: '<string>', payer_id: '<string>'}})
};
fetch('https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
'paypal_token' => '<string>',
'payer_id' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-firmly-authorization: <x-firmly-authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order"
payload := strings.NewReader("{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-firmly-authorization", "<x-firmly-authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-firmly-authorization"] = '<x-firmly-authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cart_id": "<string>",
"platform_order_number": "<string>",
"cart_status": "<string>",
"submitted_at": "<string>",
"urls": {
"thank_you_page": "<string>"
},
"line_items": [
{}
],
"shipping_info": {},
"billing_info": {},
"payment_summary": {
"payment_type": "<string>"
},
"total": {}
}Overview
Completes the checkout by placing the order with the merchant using the PayPal authorization. This is the final step in the PayPal checkout flow. The endpoint validates the PayPal token and payer id, places the order, and returns the order confirmation with the merchant’s order number.If the Authorize step was skipped, this endpoint calls authorize automatically before completing the order, as long as
paypal_token and payer_id are provided (here or from the session).Authentication
Path Parameters
Request Body
PayPal payment attributes
Response
Returns the order confirmation object.Code Example
const response = await fetch(
'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/complete-order',
{
method: 'POST',
headers: {
'x-firmly-authorization': authToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
attributes: {
paypal_token: 'EC-25M07043P9951254S',
payer_id: 'QYR5Z8XZ5JX6N'
}
})
}
);
const order = await response.json();
console.log('Order number:', order.platform_order_number);
if (order.urls?.thank_you_page) {
window.location.href = order.urls.thank_you_page;
}
import requests
response = requests.post(
'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/complete-order',
headers={
'x-firmly-authorization': auth_token,
'Content-Type': 'application/json'
},
json={
'attributes': {
'paypal_token': 'EC-25M07043P9951254S',
'payer_id': 'QYR5Z8XZ5JX6N'
}
}
)
order = response.json()
print(f"Order placed: {order['platform_order_number']}")
curl -X POST https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/complete-order \
-H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"attributes": {"paypal_token": "EC-25M07043P9951254S", "payer_id": "QYR5Z8XZ5JX6N"}}'
Response Example
{
"cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
"platform_order_number": "6800018416",
"cart_status": "submitted",
"submitted_at": "2024-07-22T18:58:25.000Z",
"urls": {
"thank_you_page": "https://merchant.example.com/checkout/onepage/success/"
},
"line_items": [
{
"line_item_id": "3e66bef5-43f5-4a80-8957-91c5c8233163",
"sku": "MT12",
"quantity": 1,
"description": "Cassius Sparring Tank",
"price": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
}
],
"shipping_info": {
"first_name": "John",
"last_name": "Smith",
"address1": "123 Main St",
"city": "Seattle",
"state_or_province": "WA",
"country": "US",
"postal_code": "98101"
},
"billing_info": {
"first_name": "John",
"last_name": "Smith",
"address1": "123 Main St",
"city": "Seattle",
"state_or_province": "WA",
"country": "US",
"postal_code": "98101"
},
"payment_summary": {
"payment_type": "PayPal"
},
"total": { "currency": "USD", "value": 30, "number": 3000, "symbol": "$" }
}
Error Responses
| Code | Description |
|---|---|
ErrorCartNotFound | No active cart for this domain |
ErrorBadRequest | Missing PayPal token or payer id |
ErrorGatewayNotFound | PayPal is not enabled for this merchant |
ErrorPaymentMethodNotAvailable | PayPal is not available for this cart |
ErrorMissingShippingMethod | No shipping method selected |
ErrorMissingTaxSync | Tax has not been calculated |
ErrorCheckout | Checkout failed at the merchant |
ErrorRateLimited | Too many requests |
Related Endpoints
- Start PayPal Checkout - Create the PayPal order
- Authorize PayPal Checkout - Confirm authorization
⌘I
Complete PayPal Order
curl --request POST \
--url https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-firmly-authorization: <x-firmly-authorization>' \
--data '
{
"attributes": {
"paypal_token": "<string>",
"payer_id": "<string>"
}
}
'import requests
url = "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order"
payload = { "attributes": {
"paypal_token": "<string>",
"payer_id": "<string>"
} }
headers = {
"x-firmly-authorization": "<x-firmly-authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-firmly-authorization': '<x-firmly-authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({attributes: {paypal_token: '<string>', payer_id: '<string>'}})
};
fetch('https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
'paypal_token' => '<string>',
'payer_id' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-firmly-authorization: <x-firmly-authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order"
payload := strings.NewReader("{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-firmly-authorization", "<x-firmly-authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/complete-order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-firmly-authorization"] = '<x-firmly-authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": {\n \"paypal_token\": \"<string>\",\n \"payer_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cart_id": "<string>",
"platform_order_number": "<string>",
"cart_status": "<string>",
"submitted_at": "<string>",
"urls": {
"thank_you_page": "<string>"
},
"line_items": [
{}
],
"shipping_info": {},
"billing_info": {},
"payment_summary": {
"payment_type": "<string>"
},
"total": {}
}