Creating a Payment Intent
const intent = await saligpay.paymentIntents.create({
amount: 10000, // ₱100.00 in centavos
description: "One-time purchase",
externalId: "order-456",
contact: {
name: "Jane Smith",
email: "jane@example.com",
phone: "+639123456789",
},
metadata: { item: "premium_upgrade" },
returnUrl: "https://yourapp.com/payment/success",
webhookUrl: "https://yourapp.com/webhooks/saligpay",
});
console.log("Intent ID:", intent.id);
console.log("Status:", intent.status);
console.log("Payment Methods:", intent.paymentMethods);
Confirming a Payment Intent
const confirmation = await saligpay.paymentIntents.confirm("pi_abc123", {
paymentMethod: "pm_gcash_xyz",
contact: {
name: "Jane Smith",
email: "jane@example.com",
},
creditCardDetails: {
cardNumber: "4111111111111111",
expMonth: "12",
expYear: "2026",
cvc: "123",
},
});
if (confirmation.requiresAction && confirmation.nextAction) {
console.log("Redirect URL:", confirmation.nextAction.redirectUrl);
}
Getting Payment Intent Status
const intent = await saligpay.paymentIntents.getStatus("pi_abc123");
console.log("Intent Status:", intent.status);
console.log("Transaction ID:", intent.transactionId);
Payment Intent Options
Create Options
interface CreatePaymentIntentOptions {
/** Amount in centavos (required) */
amount: number;
/** Description of the payment (required) */
description: string;
/** Unique external reference ID (required) */
externalId: string;
/** Customer contact information (required) */
contact: {
name: string;
email: string;
phone?: string;
};
/** Additional metadata (optional) */
metadata?: Record<string, unknown>;
/** URL to redirect after payment (optional) */
returnUrl?: string;
/** URL to receive webhook notifications (optional) */
webhookUrl?: string;
}
Confirm Options
interface ConfirmPaymentIntentOptions {
/** Payment method ID (optional) */
paymentMethod?: string;
/** Customer contact information (optional) */
contact?: {
name: string;
email: string;
};
/** Credit card details for card payments (optional) */
creditCardDetails?: {
cardNumber: string;
expMonth: string;
expYear: string;
cvc: string;
};
}
Response Types
PaymentIntentApiResponse
interface PaymentIntentApiResponse {
id: string;
transactionId: string;
sessionToken: string;
amount: number;
status: PaymentIntentStatus;
description: string;
clientKey: string;
paymentMethods: string[];
fee: number;
createdAt: string;
updatedAt: string;
}
PaymentConfirmationApiResponse
interface PaymentConfirmationApiResponse {
intentId: string;
status: PaymentIntentStatus;
redirectUrl?: string;
requiresAction: boolean;
nextAction?: {
type: "redirect" | "display_details";
redirectUrl?: string;
};
}
PaymentIntentStatus
type PaymentIntentStatus =
| "requires_payment_method"
| "requires_confirmation"
| "requires_action"
| "processing"
| "succeeded"
| "canceled";
Status Descriptions
| Status | Description |
|---|
requires_payment_method | Payment method not yet provided |
requires_confirmation | Ready to be confirmed |
requires_action | Additional action required (e.g., 3D Secure) |
processing | Payment is being processed |
succeeded | Payment completed successfully |
canceled | Payment was canceled |
Last modified on