🪧Subscription payment using billing key

Request subscription (scheduled) payments using the customer_uid.

subscriptionsubscriptionYou can use the customer_uid obtained through the Get billing key or Non-authenticated payment (one-time) API to request a subscription or scheduled payment.

STEP 01. Request payment

You can schedule a payment for a desired time in the future by using the ChaiPort Schedule payment API.

Node.js
// Schedule payment
  axios({
    url: \`https://api.iamport.kr/subscribe/payments/schedule\`,
    method: "post",
    headers: { "Authorization": access_token }, // Add access token to authorization header
    data: {
      customer_uid: "gildong_0001_1234", // Unique ID for each card (billing key)
      schedules: [
        {
          merchant_uid: "order_monthly_0001", // Order ID
          schedule_at: 1519862400, // Schedule time in UNIX timestamp.
          amount: 8900,
          name: "Recurring payment for monthly subscription",
          buyer_name: "Hong Gildong",
          buyer_tel: "01012345678",
          buyer_email: "gildong@gmail.com"
        }
      ]
    }
  });

STEP 02. Receive payment result

When payment is attempted at the scheduled time, a webhook event occurs and the payment ID (imp_uid) and order ID (merchant_uid) are sent to the specified callback URL on the server. After receiving the payment result via webhook, you can complete the payment processing based on the result.

i'mport Webhook

For information about the i'mport Webhook and how to set the callback URL, refer to the i'mport webhook guide.

Recurring payment

To implement recurring payments, recursively schedule a payment to the i'mport server. When a payment is attempted at the scheduled time, a notification is sent to the server through the webhook URL.

The above example processes the webhook event that occurs when a scheduled payment is attempted. If the scheduled payment is completed successfully, the payment information is saved in the database and the next payment is scheduled.

Last updated