PayPal
Start PayPal Checkout
Creates a PayPal Express Checkout order and returns the PayPal token and approval URL
POST
/
api
/
v1
/
domains
/
{domain}
/
express
/
paypal
/
start
Start PayPal Checkout
curl --request POST \
--url https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-firmly-authorization: <x-firmly-authorization>' \
--data '
{
"attributes": {}
}
'import requests
url = "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start"
payload = { "attributes": {} }
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: {}})
};
fetch('https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start', 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/start",
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' => [
]
]),
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/start"
payload := strings.NewReader("{\n \"attributes\": {}\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/start")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start")
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}"
response = http.request(request)
puts response.read_body{
"cart_id": "<string>",
"line_items": [
{}
],
"payment_method": {
"payment_type": "<string>",
"attributes": {
"paypal_token": "<string>",
"url": "<string>",
"sandbox": true
}
},
"total": {},
"sub_total": {}
}Overview
Initiates a PayPal checkout by creating a PayPal Express Checkout order on the merchant. Returns the cart enriched with apayment_method object containing the PayPal EC paypal_token and the PayPal approval url. The buyer approves the payment on PayPal (via the PayPal SDK button or by opening the approval URL); the approval returns a payer_id and paypal_token that you pass to Authorize.
PayPal is enabled per merchant. Check the cart’s
payment_method_options array for { "type": "PayPal", "wallet": "paypal", "config": { ... } } before offering PayPal; config carries the PayPal SDK settings (clientId, merchantId, sandbox, intent, integration_version, mode).Authentication
Path Parameters
Request Body
Response
Returns the cart enriched with the PayPal payment method.PayPal payment method details
Show Payment Method
Show Payment Method
PayPal checkout credentials
Show Attributes
Show Attributes
Code Example
const response = await fetch(
'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start',
{
method: 'POST',
headers: {
'x-firmly-authorization': authToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({ attributes: {} })
}
);
const cart = await response.json();
const paypalToken = cart.payment_method.attributes.paypal_token;
// Pass paypalToken to the PayPal SDK createOrder(), or open attributes.url to approve
import requests
response = requests.post(
'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start',
headers={
'x-firmly-authorization': auth_token,
'Content-Type': 'application/json'
},
json={'attributes': {}}
)
cart = response.json()
paypal_token = cart['payment_method']['attributes']['paypal_token']
curl -X POST https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start \
-H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"attributes": {}}'
Response Example
{
"cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
"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": "$" },
"line_price": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
}
],
"payment_method": {
"payment_type": "paypal",
"attributes": {
"paypal_token": "EC-25M07043P9951254S",
"url": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-25M07043P9951254S",
"sandbox": true
}
},
"sub_total": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" },
"total": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
}
Error Responses
| Code | Description |
|---|---|
ErrorCartNotFound | No active cart for this domain |
ErrorGatewayNotFound | PayPal is not enabled for this merchant |
ErrorOperationNotSupported | Merchant adapter does not support PayPal express checkout |
ErrorStartExpressCheckout | PayPal failed to create the Express Checkout order |
ErrorStoreUnavailable | Merchant temporarily unavailable |
ErrorRateLimited | Too many requests |
Related Endpoints
- Authorize PayPal Checkout - Confirm after buyer approval
- Complete PayPal Order - Finalize the order
⌘I
Start PayPal Checkout
curl --request POST \
--url https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-firmly-authorization: <x-firmly-authorization>' \
--data '
{
"attributes": {}
}
'import requests
url = "https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start"
payload = { "attributes": {} }
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: {}})
};
fetch('https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start', 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/start",
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' => [
]
]),
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/start"
payload := strings.NewReader("{\n \"attributes\": {}\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/start")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v1/domains/{domain}/express/paypal/start")
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}"
response = http.request(request)
puts response.read_body{
"cart_id": "<string>",
"line_items": [
{}
],
"payment_method": {
"payment_type": "<string>",
"attributes": {
"paypal_token": "<string>",
"url": "<string>",
"sandbox": true
}
},
"total": {},
"sub_total": {}
}