Berikut adalah langkah-langkah cara membuat Paylater melalui API dalam mode test:
1. Membuat secret API Key melalui dashboard Anda dalam mode test
Referensi dapat dilihat di doc berikut.
2. Masukkan callback URL Anda pada Dashboard - Settings - Callbacks di bagian Paylater Payment Status dan pastikan saat klik "test and save" respon mengembalikan 2XX
3. Membuat Customer menggunakan endpoint:
POST https://api.xendit.co/customers
4. Masukkan secret API key Anda pada Authorization
5. Pada Body request, Anda dapat menggunakan parameter dibawah sebagai contoh:
{
"given_names": "Harry",
"surname":"Potter",
"email": "customer@domain.co",
"mobile_number": "+628123456789",
"reference_id": "harrypoter123",
"addresses": [{
"street_line1": "Manila",
"city": "Manila",
"province": "Metro Manila",
"postal_code": "1011",
"country": "PH"
}]
}
6. Klik send dan Anda akan mendapatkan respons berikut:
{
"id": "c90572e0-5378-419f-917f-0abfa2707161",
"reference_id": "harrypoter123",
"given_names": "Harry",
"email": "customer@domain.co",
"mobile_number": "+628123456789",
"description": null,
"middle_name": null,
"surname": "Potter",
"phone_number": null,
"hashed_phone_number": null,
"nationality": null,
"date_of_birth": null,
"metadata": null,
"employment": null,
"addresses": [
{
"category": null,
"country": "PH",
"state": null,
"province": "Metro Manila",
"city": "Manila",
"postal_code": "1011",
"street_line1": "Manila",
"street_line2": null,
"is_preferred": false
}
]
}
7. Membuat Paylater Plan menggunakan endpoint:
POST https://api.xendit.co/paylater/plans
8. Masukkan secret API key Anda pada Authorization
9. Pada Body request, Anda dapat menggunakan parameter dibawah, mohon untuk masukan customer_id dari response sebelumnya di body request berikut (pada bagian bold):
{
"customer_id": "c90572e0-5378-419f-917f-0abfa2707161",
"channel_code": "PH_BILLEASE",
"currency": "PHP",
"amount": 50,
"order_items": [{
"type": "DIGITAL_PRODUCT",
"reference_id": "SKU_1323",
"name": "Potion ebooks",
"net_unit_amount": 50,
"quantity": 1,
"url": "https://www.zngmyhome.com/ebooks",
"category": "Classes"
}]
}
{
"id": "plp_b5f3d6c5-aa6c-4bbd-8f50-1817ccc1712c",
"customer_id": "c90572e0-5378-419f-917f-0abfa2707161",
"channel_code": "PH_BILLEASE",
"currency": "PHP",
"amount": 50,
"order_items": [
{
"type": "DIGITAL_PRODUCT",
"reference_id": "SKU_1323",
"name": "Potion ebooks",
"net_unit_amount": 50,
"quantity": 1,
"url": "https://www.zngmyhome.com/ebooks",
"category": "Classes",
"subcategory": null,
"description": null,
"metadata": null
}
],
"options": [
{
"downpayment_amount": 0,
"installment_amount": 50,
"interest_rate": 0,
"total_amount": 50,
"interval": "MONTH",
"interval_count": 1,
"total_recurrence": 1,
"description": "BNPL installment option 1 month"
},
{
"downpayment_amount": 0,
"installment_amount": 16.666666666666668,
"interest_rate": 0,
"total_amount": 50,
"interval": "MONTH",
"interval_count": 1,
"total_recurrence": 3,
"description": "BNPL installment option 3 months"
},
{
"downpayment_amount": 0,
"installment_amount": 9.63,
"interest_rate": 2.6,
"total_amount": 57.8,
"interval": "MONTH",
"interval_count": 1,
"total_recurrence": 6,
"description": "BNPL installment option 6 months"
},
{
"downpayment_amount": 0,
"installment_amount": 5.47,
"interest_rate": 2.6,
"total_amount": 65.6,
"interval": "MONTH",
"interval_count": 1,
"total_recurrence": 12,
"description": "BNPL installment option 12 months"
}
],
"created": "2023-04-03T06:53:13.389Z"
}
12. Masukkan secret API key Anda pada Authorization
13. Pada Body request, Anda dapat menggunakan parameter dibawah, mohon untuk masukan plan_id dari response sebelumnya di body request berikut (pada bagian bold):
{
"plan_id": "plp_b5f3d6c5-aa6c-4bbd-8f50-1817ccc1712c",
"reference_id": "order_id_234",
"checkout_method": "ONE_TIME_PAYMENT",
"success_redirect_url": "https://google.com",
"failure_redirect_url": "https://twitter.com"
}
{
"id": "plc_038923f7-3512-4be8-bad4-df8d9c5fb835",
"business_id": "6023480283321d40fff8cb84",
"reference_id": "order_id_234",
"customer_id": "c90572e0-5378-419f-917f-0abfa2707161",
"plan_id": "plp_b5f3d6c5-aa6c-4bbd-8f50-1817ccc1712c",
"currency": "PHP",
"amount": 50,
"channel_code": "PH_BILLEASE",
"checkout_method": "ONE_TIME_PAYMENT",
"status": "PENDING",
"actions": {
"desktop_web_checkout_url": "https://paylater-mock-connector-dev.xendit.co/checkout?charge_id=038923f7-3512-4be8-bad4-df8d9c5fb835&connector_reference_id=82a473ed-3349-4704-b874-6a3c15d63993&business_id=6023480283321d40fff8cb84",
"mobile_web_checkout_url": "https://paylater-mock-connector-dev.xendit.co/checkout?charge_id=038923f7-3512-4be8-bad4-df8d9c5fb835&connector_reference_id=82a473ed-3349-4704-b874-6a3c15d63993&business_id=6023480283321d40fff8cb84",
"mobile_deeplink_checkout_url": "https://paylater-mock-connector-dev.xendit.co/checkout?charge_id=038923f7-3512-4be8-bad4-df8d9c5fb835&connector_reference_id=82a473ed-3349-4704-b874-6a3c15d63993&business_id=6023480283321d40fff8cb84"
},
"expires_at": "2023-04-05T07:13:29.164Z",
"success_redirect_url": "https://google.com",
"failure_redirect_url": "https://twitter.com",
"callback_url": "https://testpaylater.free.beeceptor.com",
"created": "2023-04-03T07:13:29.183Z",
"updated": "2023-04-03T07:13:29.249Z",
"order_items": [
{
"type": "DIGITAL_PRODUCT",
"reference_id": "SKU_1323",
"name": "Potion ebooks",
"net_unit_amount": 50,
"quantity": 1,
"url": "https://www.zngmyhome.com/ebooks",
"category": "Classes",
"subcategory": null,
"description": null,
"metadata": null
}
],
"voided_at": null,
"payment_method_id": null,
"metadata": null
}