Creating a Checkout Session
const checkout = await saligpay.checkout.create({
externalId: "order-123",
amount: 10000, // ₱100.00 in centavos
description: "Premium Plan Subscription",
webhookUrl: "https://yourapp.com/webhooks/saligpay",
returnUrl: "https://yourapp.com/payment/success",
contact: {
name: "John Doe",
email: "john@example.com",
contact: "+639123456789",
},
metadata: {
orderId: "12345",
userId: "user-abc",
},
isThirdParty: true,
});
console.log("Checkout ID:", checkout.id);
console.log("Session Token:", checkout.sessionToken);
console.log("Checkout URL:", checkout.checkoutUrl);
console.log("Expires At:", checkout.expiresAt);
Checkout Options
| Field | Type | Required | Description |
|---|
externalId | string | Yes | Unique external reference ID |
amount | number | Yes | Amount in centavos (cents) |
description | string | Yes | Payment description |
webhookUrl | string | Yes | URL for webhook notifications |
returnUrl | string | Yes | URL to redirect after payment |
contact | object | Yes | Customer contact information |
contact.name | string | Yes | Customer full name |
contact.email | string | Yes | Customer email |
contact.contact | string | No | Phone number |
metadata | object | No | Additional metadata |
isThirdParty | boolean | No | Default: true |
interface CreateCheckoutOptions {
/** Unique external reference ID (required) */
externalId: string;
/** Amount in centavos (required) */
amount: number;
/** Description of the payment (required) */
description: string;
/** URL to receive webhook notifications (required) */
webhookUrl: string;
/** URL to redirect after payment (required) */
returnUrl: string;
/** Customer contact information (required) */
contact: {
name: string;
email: string;
contact?: string;
};
/** Additional metadata (optional) */
metadata?: Record<string, unknown>;
/** Is third party integration (optional, default: true) */
isThirdParty?: boolean;
}
Checkout Response
interface CreateCheckoutApiResponse {
id: string;
sessionToken: string;
amount: number;
description: string;
checkoutUrl: string;
expiresAt: string;
status: CheckoutStatus;
createdAt: string;
}
Checkout Status
type CheckoutStatus =
| "pending"
| "processing"
| "completed"
| "failed"
| "cancelled"
| "expired";
| Status | Description |
|---|
pending | Checkout session created, awaiting customer action |
processing | Customer initiated payment, being processed |
completed | Payment successfully completed |
failed | Payment attempt failed |
cancelled | Customer cancelled the checkout |
expired | Checkout session expired before completion |
Contact Information
const contact = {
name: "Juan Dela Cruz",
email: "juan@example.com",
contact: "+639123456789", // Philippine format
};
Using Access Tokens
The SDK automatically uses stored tokens, but you can provide a custom token:
const checkout = await saligpay.checkout.create(
{
externalId: "order-456",
amount: 25000,
description: "One-time purchase",
webhookUrl: "https://yourapp.com/webhooks/saligpay",
returnUrl: "https://yourapp.com/payment/success",
contact: {
name: "Jane Smith",
email: "jane@example.com",
},
},
"custom-access-token", // optional custom token
);
Last modified on