NAV undefined
bash php javascript java go

2019-02-04

Create Payment

Endpoint: Create EWallet Payment

POST https://api.xendit.co/ewallets

Request Parameters

Version

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

OVO

OVO:

Example: Create EWallet Payment Request

curl https://api.xendit.co/ewallets -X POST \
   -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
   -H "x-api-version: 2019-02-04" \
   -d external_id='ovo-ewallet' \
   -d amount=1000 \
   -d phone='08123123123'\
   -d ewallet_type='OVO'
<?php
  Xendit::setApiKey('xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==');

  $ovoParams = [
    'external_id' => 'demo_' . time(),
    'amount' => 32000,
    'phone' => '081298498259',
    'ewallet_type' => 'OVO'
  ];

  $createOvo = \Xendit\EWallets::create($ovoParams);
  var_dump($createOvo);
const x = new require('xendit-node')({ secretKey: 'xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==' });

const { EWallet } = x;
const ewalletSpecificOptions = {};
const ew = new EWallet(ewalletSpecificOptions);

const resp = await ew.createPayment({
  externalID: 'ovo-ewallet',
  amount: 1000,
  phone: '08123123123',
  ewalletType: EWallet.Type.OVO,
});
console.log(resp);
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
try {
  EWalletPayment ewal = EWalletPayment.createOvoPayment(
    "ovo-ewallet", //externalId
    1000,        //amount
    "08123123123"  //phone
  );
} catch (XenditException e) {
  e.printStackTrace();
}
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="

data := ewallet.CreatePaymentParams{
  ExternalID:  "ovo-ewallet",
  Amount:      1000,
  Phone:       "08123123123",
  EWalletType: xendit.EWalletTypeOVO,
  CallbackURL: "mystore.com/callback",
  RedirectURL: "mystore.com/redirect",
}

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

fmt.Printf("created payment: %+v\n", resp)

Example: Create EWallet Payment Success Response

{
  "transaction_date": "2019-04-07T01:35:46.658Z",
  "amount": 1000,
  "external_id": "ovo-ewallet",
  "ewallet_type": "OVO",
  "phone": "08123123123",
  "business_id": "585testd8d9791bd40096364",
  "ewallet_transaction_id": "7a718e47-fa8a-4f81-b642-37348dc5db18"
}
Header Parameter Type Description
X-API-VERSION
optional
string API version in date semantic (e.g. 2019-02-04). Attach this parameter when calling a specific API version. List of API versions can be found here.
for-user-id
optional
string The sub-account user-id that you want to make this transaction for.

This header is only used if you have access to xenPlatform. See xenPlatform for more information
Body Parameter Type Description
external_id
required
string An ID of your choice. Often it is unique identifier like a phone number, email or transaction ID.
Note: Only alphanumeric characters allowed.
Note: The only allowed punctuation is -.
Note: Maximum length allowed is 1000 characters.
amount
required
number Amount end-customer will pay.
Note: minimum amount is 1 IDR and maximum is 10,000,000 IDR
phone
required
string Phone number of end-customer (e.g. 08123123123)
Note: End-customer must have an active ewallet account registered to Indonesian phone number prior to payment request.
Note: Phone number format should always be "088889998888" (not using "+62").
ewallet_type
required
string ewallet_type must be in capital letters - 'OVO'

DANA

DANA:

Example: Create EWallet Payment Request

curl https://api.xendit.co/ewallets -X POST \
  -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
  -d external_id = 'dana-ewallet' \
  -d amount = 1001 \
  -d expiration_date = '2020-02-20T00:00:00.000Z' \
  -d callback_url = 'https://my-shop.com/callbacks' \
  -d redirect_url = 'https://my-shop.com/home' \
  -d ewallet_type = 'DANA'
<?php
  Xendit::setApiKey('xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==');

  $danaParams = [
    'external_id' => 'demo_' . time(),
    'amount' => 32000,
    'phone' => '081298498259',
    'expiration_date' => '2020-02-20T00:00:00.000Z',
    'callback_url' => 'https://my-shop.com/callbacks',
    'redirect_url' => 'https://my-shop.com/home',
    'ewallet_type' => 'DANA'
  ];

  $createDana = \Xendit\EWallets::create($danaParams);
  var_dump($createDana);
const x = new require('xendit-node')({ secretKey: 'xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==' });

const { EWallet } = x;
const ewalletSpecificOptions = {};
const ew = new EWallet(ewalletSpecificOptions);

const resp = await ew.createPayment({
  externalID: 'dana-ewallet',
  amount: 1001,
  expirationDate: new Date(2020, 1, 20),
  callbackURL: 'https://my-shop.com/callbacks',
  redirectURL: 'https://my-shop.com/home',
  ewalletType: EWallet.Type.DANA,
});
console.log(resp);
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
try {
  EWalletPayment ewal = EWalletPayment.createDanaPayment(
    "dana-ewallet", //externalId
    1000, //amount
    "08123123123", //phone
    "24-08-2019", //expirationDate
    "callback_url", //callbackUrl
    "redirect_url" //redirectUrl
  );    
} catch (XenditException e) {
  e.printStackTrace();
}
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="

data := ewallet.CreatePaymentParams{
  ExternalID:  "dana-ewallet",
  Amount:      20000,
  Phone:       "08123123123",
  EWalletType: xendit.EWalletTypeDANA,
  CallbackURL: "mystore.com/callback",
  RedirectURL: "mystore.com/redirect",
}

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

fmt.Printf("created payment: %+v\n", resp)

Example: Create EWallet Payment Success Response

{
  "external_id": "dana-ewallet",
  "checkout_url": "https://dana.id/m/portal/cashier/checkout?id=5d34079d51a9ed12c78a78d3",
  "amount": 1000,
  "ewallet_type": "DANA"
}
Header Parameter Type Description
for-user-id
optional
string The sub-account user-id that you want to make this transaction for.

This header is only used if you have access to xenPlatform. See xenPlatform for more information

Body Parameter Type Description
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 and maximum is 10,000,000 IDR
expiration_date
optional
string End-customer cannot complete the payment past the expiration date
Note: The default is 24 hours if not specified.
callback_url
required
string The URL to receive the callback after payment made by end-customer
redirect_url
required
string The URL to redirect to after payment made by end-customer
ewallet_type
required
string ewallet_type must be in capital letters - 'DANA'

LINKAJA

LINKAJA:

Example: Create EWallet Payment Request

curl https://api.xendit.co/ewallets -X POST \
  -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
  --header 'content-type: application/json' \
  --data '{
    "external_id": "linkaja-ewallet",
    "phone": "081245671234",
    "amount": 300000,
    "items": [
      {
        "id": "123123",
        "name": "Phone Case",
        "price": 100000,
        "quantity": 1
      },
      {
        "id": "345678",
        "name": "Powerbank",
        "price": 200000,
        "quantity": 1
      }
    ],
    "callback_url": "https://yourwebsite.com/callback",
    "redirect_url": "https://yourwebsite.com/order/123",
    "ewallet_type": "LINKAJA"
}'
<?php
  Xendit::setApiKey('xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==');

  $linkajaParams = [
    'external_id' => 'demo_' . time(),
    'amount' => 32000,
    'phone' => '081298498259',
    'items' => [
      [
        'id' => '123123',
        'name' => 'Phone Case',
        'price' => 100000,
        'quantity' => 1
      ],
      [
        'id' => '345678',
        'name' => 'Powerbank',
        'price' => 200000,
        'quantity' => 1
      ]
    ],
    'callback_url' => 'https =>//yourwebsite.com/callback',
    'redirect_url' => 'https =>//yourwebsite.com/order/123',
    'ewallet_type' => 'LINKAJA'
  ];

  $createLinkaja = \Xendit\EWallets::create($linkajaParams);
  var_dump($createLinkaja);
const x = new require('xendit-node')({ secretKey: 'xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==' });

const { EWallet } = x;
const ewalletSpecificOptions = {};
const ew = new EWallet(ewalletSpecificOptions);

const item = {
  id: "345678",
  name: "Powerbank",
  price: 200000,
  quantity: 1
};
const resp = await ew.createPayment({
  externalID: 'linkaja-ewallet',
  amount: 300000,
  items: [item, item],
  callbackURL: 'https://my-shop.com/callbacks',
  redirectURL: 'https://my-shop.com/home',
  ewalletType: EWallet.Type.LINKAJA
});
console.log(resp);
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
try {
  //items
  EWalletLinkajaItem items[] = new EWalletLinkajaItem[1];
  items[0] =
  EWalletLinkajaItem.builder()
      .id("123")
      .name("Phone Case")
      .price(200000)
      .quantity(1)
      .build();

  EWalletPayment ewal = EWalletPayment.createLinkajaPayment(
    "linkaja-ewallet", //externalId
    1000, //amount
    "08123123123", //phone
    items, //EWwalletLinkajaitem[]
    "callback_url", //callbackUrl
    "redirect_url" //redirectUrl
  );  
} catch (XenditException e) {
  e.printStackTrace();
}
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="

item1 := ewallet.Item {
  ID: "123123",
  Name: "Phone Case",
  Price: 100000,
  Quantity: 1,
}

item2 := ewallet.Item {
  ID: "345678",
  Name: "Powerbank",
  Price: 200000,
  Quantity: 1,
}

var items []ewallet.Item
items = append(items, item1)
items = append(items, item2)

data := ewallet.CreatePaymentParams{
  ExternalID:  "linkaja-ewallet",
  Amount:      300000,
  Phone:       "08123123123",
  EWalletType: xendit.EWalletTypeLINKAJA,
  CallbackURL: "mystore.com/callback",
  RedirectURL: "mystore.com/redirect",
  Items: items,
}

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

fmt.Printf("created payment: %+v\n", resp)

Example: Create EWallet Payment Success Response

{
  "checkout_url": "https://ewallet-linkaja-dev.xendit.co/checkouts/b0c464ab-dcdc-4426-9255-759a9450c9d2",
  "transaction_date": "2019-10-25T08:42:54.308Z",
  "amount": 300000,
  "external_id": "linkaja-ewallet",
  "ewallet_type": "LINKAJA"
}
Header Parameter Type Description
for-user-id
optional
string The sub-account user-id that you want to make this transaction for.

This header is only used if you have access to xenPlatform. See xenPlatform for more information

Body Parameter Type Description
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.
phone
required
string Phone number of end-customer (e.g. 08123123123)
Note: End-customer must have an active ewallet account registered to Indonesian phone number prior to payment request.
amount
required
number Amount end-customer will pay.
Note: minimum amount is 100 IDR and maximum is 10,000,000 IDR
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], quantity [number]
callback_url
required
string The URL to receive the callback after payment made by end-customer
redirect_url
required
string The URL to redirect to after payment made by end-customer
ewallet_type
required
string ewallet_type must be in capital letters - 'LINKAJA'

Error Codes

Example: Create EWallet Payment Error Response

OVO

OVO:

{
  "error_code": "USER_DID_NOT_AUTHORIZE_THE_PAYMENT",
  "message": "Payment was not authorized"
}
Error Code Description
API_VALIDATION_ERROR
422
There is invalid input in one of the required request fields.
USER_DID_NOT_AUTHORIZE_THE_PAYMENT
400
User did not authorize the payment request within time limit.
USER_DECLINED_THE_TRANSACTION
400
User declined the payment request.
PHONE_NUMBER_NOT_REGISTERED
400
Phone number the user tried to pay is not registered
EWALLET_APP_UNREACHABLE
400
The ewallet provider/server can't reach the user ewallet app/phone. Common cases are the ewallet app is uninstalled.
DUPLICATE_PAYMENT
400
The payment with the same external_id has already been made before.
OVO_TIMEOUT_ERROR
400
There was a connection timeout from the OVO app to the OVO server.
CREDENTIALS_ERROR
400
The merchant is not registered in e-wallet provider system.
ACCOUNT_AUTHENTICATION_ERROR
400
User authentication has failed.
ACCOUNT_BLOCKED_ERROR
400
Unable to process the transaction because the user account is blocked.
EWALLET_TYPE_NOT_SUPPORTED
422
Your requested ewallet_type is not supported yet
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

DANA

DANA:

{
  "error_code": "DUPLICATE_ERROR",
  "message": "Transaction with this external_id is already exist"
}
Error Code Description
API_VALIDATION_ERROR
422
There is invalid input in one of the required request fields.
DUPLICATE_ERROR
400
The payment with the same external_id has already been made before.
EWALLET_TYPE_NOT_SUPPORTED
422
Your requested ewallet_type is not supported yet
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

LINKAJA

LINKAJA:

{
  "error_code": "DUPLICATE_ERROR",
  "message": "Transaction with this external_id is already exist"
}
Error Code Description
API_VALIDATION_ERROR
400
There is invalid input in one of the required request fields.
GENERATE_CHECKOUT_TOKEN_ERROR
422
An error occured when generating the checkout_url.
DUPLICATE_PAYMENT_ERROR
400
The payment with the same external_id has already been made before.
EWALLET_TYPE_NOT_SUPPORTED
422
Your requested ewallet_type is not supported yet
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

Changelog

Version 2020-02-01

New OVO payment flow will process payments asynchronously vs previous synchronous flow.

Version 2019-02-04

Returns a response immediately without any callbacks returned.