NAV undefined
bash php javascript java go python

2019-02-04 Cardless Credit

PayLater payment channel allows you to receive payments upfront from the credit provider. End users get the option to split their payments into installments.

Create Payment / Generate Checkout URL

Endpoint: Generate Checkout URL

POST https://api.xendit.co/cardless-credit

Version

You are currently viewing API version 2019-02-04. New version is available!

Request Parameters

Example: Generate Checkout URL

curl https://api.xendit.co/cardless-credit -X POST \
  -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
  --header 'content-type: application/json' \
  --data '{
    "cardless_credit_type": "KREDIVO",
    "external_id": "test-cardless-credit-01",
    "amount": 800000,
    "payment_type": "3_months",
    "items": [
      {
        "id": "123123",
        "name": "Phone Case",
        "price": 200000,
        "type": "Smartphone",
        "url": "http://example.com/phone/phone_case",
        "quantity": 2
      },
      {
        "id": "234567",
        "name": "Bluetooth Headset",
        "price": 400000,
        "type": "Audio",
        "url": "http://example.com/phone/bluetooth_headset",
        "quantity": 1
      }
    ],
    "customer_details": {
      "first_name": "customer first name",
      "last_name": "customer last name",
      "email": "customer@yourwebsite.com",
      "phone": "081513114262"
    },
    "shipping_address": {
      "first_name": "first name",
      "last_name": "last name",
      "address": "Jalan Teknologi No. 12",
      "city": "Jakarta",
      "postal_code": "12345",
      "phone": "081513114262",
      "country_code": "IDN"
    },
    "redirect_url": "https://example.com",
    "callback_url": "http://example.com/callback-cardless-credit"
  }'
<?php

  use Xendit\Xendit;
  require 'vendor/autoload.php';

  Xendit::setApiKey('xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==');

  $params = [
    'cardless_credit_type' => 'KREDIVO',
    'external_id' => 'test-cardless-credit-01',
    'amount' => 800000,
    'payment_type' => '3_months',
    'items' => [
      [
        'id' => '123123',
        'name' => 'Phone Case',
        'price' => 200000,
        'type' => 'Smartphone',
        'url' => 'http=>//example.com/phone/phone_case',
        'quantity' => 2
      ],
      [
        'id' => '234567',
        'name' => 'Bluetooth Headset',
        'price' => 400000,
        'type' => 'Audio',
        'url' => 'http=>//example.com/phone/bluetooth_headset',
        'quantity' => 1
      ]
    ],
    'customer_details' => [
      'first_name' => 'customer first name',
      'last_name' => 'customer last name',
      'email' => 'customer@yourwebsite.com',
      'phone' => '081513114262'
    ],
    'shipping_address' => [
      'first_name' => 'first name',
      'last_name' => 'last name',
      'address' => 'Jalan Teknologi No. 12',
      'city' => 'Jakarta',
      'postal_code' => '12345',
      'phone' => '081513114262',
      'country_code' => 'IDN'
    ],
    'redirect_url' => 'https://example.com',
    'callback_url' => 'http://example.com/callback-cardless-credit'
  ];

  $createPayment = \Xendit\CardlessCredit::create($params);
  var_dump($createPayment);

?>
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
try {
  //items
  CardlessCreditItem items[] = new CardlessCreditItem[1];
  items[0] =
    CardlessCreditItem.builder()
        .id("123")
        .name("Phone Case")
        .price(200000)
        .type("Smartphone")
        .url("https://www.example.org")
        .quantity(1)
        .build();

  //address
  CardlessCreditShippingAddress address =
      CardlessCreditShippingAddress.builder()
          .firstName("Lorem")
          .lastName("Ipsum")
          .address("Jalan teknologi")
          .city("Jakarta")
          .postalCode("12345")
          .countryCode("IDN")
          .phone("08129748247684")
          .build();

  //Customer
  CardlessCreditCustomer customer =
      CardlessCreditCustomer.builder()
          .firstName("Lorem")
          .lastName("Ipsum")
          .email("email@example.com")
          .phone("08129748247684")
          .build();

  CardlessCredit cardlessCredit = CardlessCredit.create(
    "KREDIVO",
    "external_id",
    200000,
    CardlessCredit.PaymentType.THREE_MONTHS.getVal(),
    items,
    customer,
    address,
    "www.example.com",
    "www.example.com"
  );
} catch (XenditException e) {
  e.printStackTrace();
}
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="

createPaymentData := cardlesscredit.CreatePaymentParams{
  CardlessCreditType: xendit.CardlessCreditTypeEnumKREDIVO,
  ExternalID:         "test-cardless-credit-01",
  Amount:             200000,
  PaymentType:        xendit.PaymentTypeEnum3Months,
  Items: []cardlesscredit.Item{
    {
      ID:       "123",
      Name:     "Laptop Asus Ila",
      Price:    200000,
      Type:     "Laptop",
      URL:      "http://asus-ila.com",
      Quantity: 1,
    },
  },
  CustomerDetails: cardlesscredit.CustomerDetails{
    FirstName: "Michael",
    LastName:  "Belajarrock",
    Email:     "michaelbelajarrock@mail.com",
    Phone:     "08123123123",
  },
  ShippingAddress: cardlesscredit.ShippingAddress{
    FirstName:   "Michael",
    LastName:    "Belajarjazz",
    Address:     "Jalan Teknologi No. 12",
    City:        "Jakarta",
    PostalCode:  "40000",
    Phone:       "08123123123",
    CountryCode: "IDN",
  },
  RedirectURL: "https://sandbox.kredivo.com/kredivo/v2/signin?tk=fKhTeBntLW3Zyu23+GQ6s+RQaMMRtQ6YdZA1bnbTszt9WXcph/B4+j8nuPlV599Rfkv85FAYuE21Suajpm45tEMZqjZIdqnSgIPlt7T5gJk=",
  CallbackURL: "https://google.com",
}

resp, err := cardlesscredit.CreatePayment(&createPaymentData)
if err != nil {
  log.Fatal(err)
}

fmt.Printf("created payment: %+v\n", resp)
from xendit import Xendit, CardlessCreditType

api_key = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
xendit_instance = Xendit(api_key=api_key)
CardlessCredit = xendit_instance.CardlessCredit

cardless_credit_items = []
cardless_credit_items.append(
    CardlessCredit.helper_create_item(
        id="item-123",
        name="Phone Case",
        price=200000,
        type="Smartphone",
        url="http://example.com/phone/phone_case",
        quantity=2,
    )
)
customer_details = CardlessCredit.helper_create_customer_details(
    first_name="customer first name",
    last_name="customer last name",
    email="customer@email.com",
    phone="0812332145",
)
shipping_address = CardlessCredit.helper_create_shipping_address(
    first_name="first name",
    last_name="last name",
    address="Jl Teknologi No. 12",
    city="Jakarta",
    postal_code="12345",
    phone="081513114262",
    country_code="IDN",
)
cardless_credit_payment = CardlessCredit.create_payment(
    cardless_credit_type=CardlessCreditType.KREDIVO,
    external_id="id-1595923113",
    amount=10000,
    payment_type="3_months",
    items=cardless_credit_items,
    customer_details=customer_details,
    shipping_address=shipping_address,
    redirect_url="https://my-shop.com/home",
    callback_url="https://my-shop.com/callback",
)
print(cardless_credit_payment)

Example: Generate Checkout URL Success Response

{
  "redirect_url": "https://sandbox.kredivo.com/kredivo/v2/signin?tk=fKhTeBntLW3Zyu23+GQ6s+RQaMMRtQ6YdZA1bnbTszt9WXcph/B4+j8nuPlV599Rfkv85FAYuE21Suajpm45tEMZqjZIdqnSgIPlt7T5gJk=",
  "transaction_id": "66403e84-c8da-4af4-8d30-d17e95522f43",
  "order_id": "123456-test-cardless-credit-01",
  "external_id": "test-cardless-credit-01",
  "cardless_credit_type": "KREDIVO"
}
Parameter Type Description
cardless_credit_type
required
string The type of cardless-credit to be paid. Must be in capital letters.
Supported Cardless Credit types: KREDIVO
external_id
required
string An ID of your choice. Often it is unique identifier like a phone number, email or transaction ID. Maximum length allowed is 1000 characters.
amount
required
number Amount end customer will pay.
Note: minimum amount is 1 IDR
payment_type
required
string The type of installment, you can choose between: "30_days", "3_months", "6_months" and "12_months".
items
required
array of item object List of items / products.
item object
required
item object Details of an item, it should contains: id [string], name [string], price [number], type [string], url [string], quantity [number]
customer_details
required
object Details of the customer, it should contains: first_name [string], last_name [string], email [string], phone [string]
shipping_address
required
object Details of the shipping address, it should contains: first_name [string], last_name [string], address [string], city [string], postal_code [string], phone [string], country_code [string]
redirect_url
required
string After end-customer complete the checkout they will be redirected to the url that you specify in this field. You can put your transaction details page or your home page.
callback_url
required
string We will send callback to this address when the customer completes the payment proccess.

Error Codes

Example: Generate Checkout URL error response

{
  "error_code": "API_VALIDATION_ERROR",
  "message": "[fieldName] is required"
}
{
  "error_code": "DUPLICATE_PAYMENT_ERROR",
  "message": "Checkout URL with the same external_id has been created before."
}
Error Code Description
MERCHANT_NOT_FOUND
422
You are not registered yet to use this payment method.
GENERATE_CHECKOUT_URL_ERROR
422
Your request did not meet the requirement or there is a problem in the Kredivo / Partner server.
DUPLICATE_PAYMENT_ERROR
422
Checkout URL with the same external_id has been created before.
REQUEST_FORBIDDEN_ERROR
403
API key in use does not have necessary permissions to perform the request. Please assign proper permissions for the key. Learn more here

Calculate Payment Types

Calculate Payment Types feature helps merchants to get an accurate value of the installment offered to end customers by the cardless credit provider. Merchants can use this to calculate and display installment plans before end customer is redirected for authentication.

Endpoint: Calculate Payment Types

POST https://api.xendit.co/cardless-credit/payment-types

Calculate Payment Types

Example: Calculate Payment Types Request

curl https://api.xendit.co/cardless-credit/payment-types -X POST \
  -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
  --header 'content-type: application/json' \
  --data '{
    "cardless_credit_type": "KREDIVO",
    "amount": 2000000,
    "items": 
    [
      {
        "id": "123123",
        "name": "Phone Case",
        "price": 1000000,
        "type": "Smartphone",
        "url": "http://example.com/phone/phone_case",
        "quantity": 1
      }
    ]
  }'
<?php
  $url = 'https://api.xendit.co/cardless-credit/payment-types';
  $apiKey = 'xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:';
  $headers = [];
  $headers[] = 'Content-Type: application/json';
  $item_1 = new stdClass();
  $item_1->id = "123123";
  $item_1->name = "Phone Case";
  $item_1->price = 200000;
  $item_1->type = "Smartphone";
  $item_1->url = "http://example.com/phone/phone_case";
  $item_1->quantity = 2;
  $data = [
      "cardless_credit_type" => "KREDIVO",
      "amount" => 800000,
      "items" => [ $item_1 ],
  ];
  $curl = curl_init();
  $payload = json_encode($data);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_USERPWD, $apiKey.":");
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($curl);
  echo $result;
from xendit import Xendit, CardlessCreditType

api_key = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:"
xendit_instance = Xendit(api_key=api_key)
CardlessCredit = xendit_instance.CardlessCredit

cardless_credit_items = []
cardless_credit_items.append(
    CardlessCredit.helper_create_item(
        id="item-123",
        name="Phone Case",
        price=200000,
        type="Smartphone",
        url="http://example.com/phone/phone_case",
        quantity=2,
    )
)
cardless_credit_payment_types = CardlessCredit.calculate_payment_type(
    cardless_credit_type=CardlessCreditType.KREDIVO,
    amount=10000,
    items=cardless_credit_items,
)
print(cardless_credit_payment_types)
Parameter Description
cardless_credit_type
required
string The type of cardless-credit to be paid. Must be in capital letters.
Supported Cardless Credit types: KREDIVO
amount
required
number Amount end customer will pay.
Note: minimum amount is 1 IDR
items
required
array of item object List of items / products.
items.id
required
string Merchant product ID of specified product in transaction
items.name
required
string Name of specified product in transaction
items.price
required
number Unit price of specified product in transaction
items.type
required
string Category of specified product in transaction
items.url
required
string Web url of specified product in transaction
items.quantity
required
number Quantity of specified product in transaction

Calculate Payment Types Response

Example: Calculate Payment Types Response

{
    "message": "Available payment types are listed.",
    "payments": [
        {
            "raw_monthly_installment": 187534.6668043921,
            "name": "Bayar dalam 6 bulan",
            "amount": 1000000,
            "installment_amount": 1125240,
            "raw_amount": 1000000,
            "rate": 2.95,
            "down_payment": 0,
            "monthly_installment": 187540,
            "discounted_monthly_installment": 0,
            "tenure": 6,
            "id": "6_months"
        },
        {
            "raw_monthly_installment": 1020000,
            "name": "Bayar dalam 30 hari",
            "amount": 1020000,
            "installment_amount": 1020000,
            "raw_amount": 1020000,
            "rate": 0,
            "down_payment": 0,
            "monthly_installment": 1020000,
            "discounted_monthly_installment": 0,
            "tenure": 1,
            "id": "30_days"
        },
        {
            "raw_monthly_installment": 356786.46273702476,
            "name": "Bayar dalam 3 bulan",
            "amount": 1000000,
            "installment_amount": 1070370,
            "raw_amount": 1000000,
            "rate": 2.95,
            "down_payment": 0,
            "monthly_installment": 356790,
            "discounted_monthly_installment": 0,
            "tenure": 3,
            "id": "3_months"
        }
    ]
}
Parameter Description
message
required
string ÔÇťAvailable payment types are listed
payments
required
array List of calculated payment types
payments.raw_monthly_installment
required
number Monthly installment before rounding
payments.name
required
string Name of installment plan
payments.amount
required
number Total payment amount before interest
payments.installment_amount
required
number Total payment amount after interest
payments.raw_amount
required
number Payment amount before interest before rounding
payments.rate
required
number Applied interest rates
payments.down_payment
required
number Amount paid upfront
payments.monthly_installment
required
number Monthly installment offered by Kredivo to end user
payments.discounted_monthly_installment
required
number Monthly installment offered by Kredivo to end user after discount (if any)
payments.tenure
required
number Repayment term of installment in months
payments.id
required
string ID of installment type

Payment Callback Notification

Xendit notifies your system upon successful payments via callback. You need to provide an URL to receive callback. Please specify your URL in Callback Settings in Xendit Dashboard.

The payment notification will be sent as POST request to the URL you set. Xendit attach x-callback-token header that you can validate against Verification Token in Callback Settings to verify message authenticity.

Please response back with status 200 immediately. Xendit marks callback event as failed if there is no response within 30s. When events failed, automatic retry will kick-off for the next 24h. Alternatively, you can resend any event in Callback tab at anytime. You can also receive notification via email every 6h to check your callback health.

Learn more about Callback

Payment Callback Payload

Header Parameter Type Description
x-callback-token
required
string Your Xendit unique callback token to verify the origin of the callback

Example: Payment Callback Notification Request

{
  "external_id": "test-cardless-credit-01",
  "order_id": "75191237c81273jajsh7291c-test-cardless-credit-01",
  "transaction_id": "ashd7129-sh82-a9ks-js82-asj82912bajs",
  "amount": 800000,
  "transaction_status": "settlement",
  "payment_type": "3_months",
  "items": [
    {
      "id": "123123",
      "name": "Phone Case",
      "price": 200000,
      "type": "Smartphone",
      "url": "http://example.com/phone/phone_case",
      "quantity": 2
    },
    {
      "id": "234567",
      "name": "Bluetooth Headset",
      "price": 400000,
      "type": "Audio",
      "url": "http://example.com/audio/bluetooth_headset",
      "quantity": 1
    }
  ],
  "customer_details": {
      "first_name": "customer first name",
      "last_name": "customer last name",
      "email": "customer@yourwebsite.com",
      "phone": "081513114262"
    },
    "shipping_address": {
      "first_name": "first name",
      "last_name": "last name",
      "address": "Jalan Teknologi No. 12",
      "city": "Jakarta",
      "postal_code": "12345",
      "phone": "081513114262",
      "country_code": "IDN"
    },
  "cardless_credit_type": "KREDIVO",
  "callback_authentication_token": "MuaJALKJSDK12LASHD123kSAKSDHzjahwUWjkasJSDSA12KSNAK21n=="
}
Body Parameter Type Description
external_id string Your transaction identifier that you specified in on the Generate Checkout URL request.
order_id string Unique Identifier that we gave to the cardless credit payment partner.
transaction_id string Transaction ID given by Cardless Credit partner.
transaction_status string Transaction status, the value is:
settlement: Transaction is successful
pending: End-User has not completed the transaction
deny: Transaction has been denied by our Cardless Credit Partner
cancel: Transaction has been cancelled
expire: End-User did not complete transaction in 24 hours, thus transaction is expired
payment_type string the type of installment.
amount number Amount that you specified in on the Generate Checkout URL request.
items array of item List of items / products that you specified in on the Generate Checkout URL request.
item object
item detail Details of an item, it should contains: id [string], name [string], price [number], type [string], url [string], quantity [number]
customer_details object Details of the customer, it should contains: first_name [string], last_name [string], email [string], phone [string]
shipping_address object Details of the shipping address, it should contains: first_name [string], last_name [string], address [string], city [string], postal_code [string], phone [string], country_code [string]
cardless_credit_type string The type of cardless-credit.
Supported Cardless Credit types: KREDIVO
callback_authentication_token string Your Callback Verfication API Key that you can found on your Xendit Dashboard. You need to verify if this had the same value.