Implement one-time payments with Stripe Custom Payment Methods and HitPay
One-time payments are single, non-recurring transactions where customers pay once for a product or service. The customer selects a HitPay payment method, completes the payment via QR code or redirect, and the transaction is recorded in Stripe.
This integration connects Stripe’s Payment Element with HitPay’s Payment Request API, allowing customers to pay using local payment methods while keeping all transaction records in Stripe.
Stripe DashboardCreate Custom Payment Method types in your Stripe Dashboard for each HitPay payment method you want to offer.After creating the custom payment method, the Dashboard displays the custom payment method ID (beginning with cpmt_) that you need for the next step.
Create CPM in Stripe Dashboard
Follow Stripe’s guide to create Custom Payment Method types and get your CPM Type IDs.
Download Payment Icons
Download official HitPay payment method icons (PayNow, ShopeePay, GrabPay, FPX, and more) optimized for Stripe Custom Payment Methods.
2
Create Configuration File
Server-sideMap your Stripe CPM Type IDs to HitPay payment methods:
Copy
Ask AI
// config/payment-methods.tsinterface CustomPaymentMethodConfig { id: string; // Stripe CPM Type ID (cpmt_xxx) hitpayMethod: string; // HitPay payment method displayName: string;}export const CUSTOM_PAYMENT_METHODS: CustomPaymentMethodConfig[] = [ { id: 'cpmt_YOUR_PAYNOW_ID', // Replace with your CPM Type ID hitpayMethod: 'paynow_online', displayName: 'PayNow', }, { id: 'cpmt_YOUR_SHOPEEPAY_ID', hitpayMethod: 'shopee_pay', displayName: 'ShopeePay', }, { id: 'cpmt_YOUR_GRABPAY_ID', hitpayMethod: 'grabpay', displayName: 'GrabPay', },];export function getHitpayMethod(cpmTypeId: string): string | undefined { return CUSTOM_PAYMENT_METHODS.find(pm => pm.id === cpmTypeId)?.hitpayMethod;}
3
Setup Stripe Client
Client-sideLoad Stripe.js with the beta flag and configure the Payment Element with your CPMs:
Server-sideSet up the required API keys and configuration for both Stripe and HitPay. These credentials authenticate your server with both payment platforms.
Copy
Ask AI
# StripeNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxSTRIPE_SECRET_KEY=sk_test_xxx# HitPayHITPAY_API_KEY=xxxHITPAY_SALT=xxxNEXT_PUBLIC_HITPAY_ENV=sandbox # or 'production'NEXT_PUBLIC_BASE_URL=https://your-domain.com
Never expose STRIPE_SECRET_KEY or HITPAY_API_KEY to the client.
2
Create HitPay Payment Request
Server-sideWhen a user selects a CPM in the Payment Element, create a HitPay payment request and display the QR code:
Displaying QR Codes: The generate_qr: true parameter returns QR code data in qr_code_data.qr_code. For detailed guidance on rendering QR codes and handling different payment methods, see our Embedded QR Code Payments guide.
Embedded QR Code Payments
Learn how to embed and display QR codes for PayNow, ShopeePay, and other supported payment methods.
3
Display QR Code in Payment Element
Client-sideRender the QR code in your checkout form when a customer selects a HitPay payment method. The customer scans the QR code with their mobile app to complete the payment.
Once the customer completes payment via HitPay, you need to:
Listen for payment confirmation from HitPay (via webhook or polling)
Record the payment in Stripe using the Payment Records API
This ensures all HitPay transactions appear in your Stripe Dashboard alongside native Stripe payments, enabling unified reporting and easier reconciliation.
Why record payments in Stripe? Without this step, HitPay payments would only appear in your HitPay Dashboard. By recording them via Stripe’s Payment Records API, you get a single source of truth for all transactions - cards, PayNow, ShopeePay, and more - all visible in one place.
Stripe Payment Records API
Learn how Payment Records work and how they appear in your Stripe Dashboard.
1
Listen for Payment Confirmation
Server-side
Webhooks (Recommended)
Polling (Not Recommended)
Use webhooks for production. HitPay automatically sends a POST request to your server when payment is completed - no polling required.How it works:
Customer completes payment via HitPay (scans QR, etc.)
HitPay sends webhook to your /api/hitpay/webhook endpoint
Your server verifies the signature and confirms payment status
Your server creates a Payment Record in Stripe
Transaction now appears in Stripe Dashboard for reconciliation