2. 정기(예약)/반복결제 구현하기 (서버)
발급한 빌링키로 정기(예약)결제를 구현하는 방법을 안내합니다.
1. 결제 예약하기
async function schedulePayment() {
// 1. 포트원 API를 사용하기 위한 액세스 토큰 발급 받기를 진행해주세요.
// 2. 포트원 결제 예약 API 호출
const response = await axios({
url: `https://api.portone.io/v2/payments/${PAYMENT_ID_HERE}/schedules`,
method: "post",
// 1번에서 발급받은 액세스 토큰을 Bearer 형식에 맞게 넣어주세요.
headers: { "Authorization": "Bearer " + access_token },
data: {
"payment_id": UNIQUE_PAYMENT_ID,
"billing_key": BILLING_KEY_HERE,
"order_name": "월간 이용권 정기결제",
"customer": {
"customer_id": CUSTOMER_ID_HERE,
// 고객 정보가 필요한 경우 API 명세에 따라 추가해주세요.
},
"total_amount": 8900,
"currency": "KRW",
"scheduled_at": "2023-08-24T14:15:22Z" // 결제를 시도할 시각
}
});
// 결제 예약 이후 로직을 구성해주세요.
}2. 결제 결과 수신받기
3. 반복결제 구현하기
Last updated
Was this helpful?
