PayPal Create Payment API
Initiate PayPal payments for subscriptions and purchases with seamless checkout experience
PayPal Create Payment API
Enable PayPal checkout for your users. Create payment orders that redirect to PayPal's secure checkout flow for subscription and one-time purchases.
Buyer Protection
PayPal's buyer protection builds trust with customers.
Global Reach
Accept payments from 200+ countries and regions.
Multiple Funding
PayPal balance, bank accounts, and linked cards.
Endpoint Overview
/graphqlCreate a PayPal payment order by providing payment category, group ID, and additional login count. Returns an order ID for checkout redirection.
Request Parameters
categoryPaymentCategory!RequiredThe category of the payment. Values: SUBSCRIPTION, ONE_TIME, ADDON.
groupIdIntRequiredThe ID of the subscription group/plan associated with the payment.
moreLoginCountIntNumber of additional logins to purchase (optional, set to 0 if not needed).
GraphQL Mutation
mutation paypalCreatePayment(
$category: PaymentCategory!
$groupId: Int
$moreLoginCount: Int
) {
paypalCreatePayment(
category: $category
groupId: $groupId
moreLoginCount: $moreLoginCount
) {
orderId
}
}Variables:
{
"category": "SUBSCRIPTION",
"groupId": 1,
"moreLoginCount": 0
}HTTP Request:
curl -X POST https://api.orbnet.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"query": "mutation paypalCreatePayment($category: PaymentCategory!, $groupId: Int, $moreLoginCount: Int) { paypalCreatePayment(category: $category, groupId: $groupId, moreLoginCount: $moreLoginCount) { orderId } }",
"variables": {
"category": "SUBSCRIPTION",
"groupId": 1,
"moreLoginCount": 0
}
}'Response
{
"data": {
"paypalCreatePayment": {
"orderId": "5O190127TN364715T"
}
}
}{
"errors": [
{
"message": "Invalid payment category",
"path": ["paypalCreatePayment"],
"extensions": {
"code": "INVALID_CATEGORY"
}
}
],
"data": null
}Payment Flow
Create Order
Call this API to create a PayPal order and receive an orderId.
Redirect to PayPal
Use PayPal SDK to redirect user to PayPal checkout with the orderId.
User Approves Payment
User logs into PayPal and approves the payment on PayPal's site.
Capture Payment
Call paypalApprovePayment API with the orderId to finalize the transaction.
Frontend Integration
// Load PayPal SDK
paypal.Buttons({
createOrder: async () => {
// Call your backend which calls this API
const response = await fetch('/api/create-paypal-order', {
method: 'POST',
body: JSON.stringify({ groupId: 1, category: 'SUBSCRIPTION' })
});
const data = await response.json();
return data.orderId;
},
onApprove: async (data) => {
// Call paypalApprovePayment API
await fetch('/api/approve-paypal-order', {
method: 'POST',
body: JSON.stringify({ orderId: data.orderID })
});
// Payment successful!
}
}).render('#paypal-button-container');Best Practices
Use PayPal SDK
Integrate PayPal's official JavaScript SDK for the best checkout experience.
Handle Cancellation
Implement onCancel callback to handle users who cancel during checkout.
Store Order ID
Save the orderId for tracking and customer support purposes.
Verify Completion
Always call the approve endpoint to verify and capture the payment.
Related Endpoints
Complete the Flow
Creating a PayPal order is only the first step. You must call the paypalApprovePayment API after the user completes checkout to capture the payment.
Enable PayPal Checkout
Offer your users the trusted PayPal payment option. Support PayPal balance, bank transfers, and linked cards.