Skip to main content

Payment Solution PH v1

Creating Payments

POSThttps://api-merchant.alikassa.com/v1/payment📋

Headers

HeaderValue
Content-Typeapplication/json
AccountYour account uuid, you can find in Accounts
SignRequest signature

Certificate Setup

Go to API Certificate Settings, generate "API certificate for payment", save the archive, and unpack it.

You'll get:

  • password.txt
  • private.pem
  • public.pem

We keep only public.pem for signature verification.

Signature Generation

Wrap all POST data in JSON (in the same order) and sign:

$data = json_encode($data);

$privateKey = openssl_pkey_get_private(
file_get_contents('private.pem'),
file_get_contents('password.txt')
);

if ($privateKey === false) {
throw new \Exception('Error cert.');
}

openssl_sign($data, $sign, $privateKey);
$sign = base64_encode($sign);
import { readFileSync } from 'fs';
import { createSign } from 'crypto';

const data = JSON.stringify(requestData);
const keyPem = readFileSync('private.pem', 'utf8');
const passphrase = readFileSync('password.txt', 'utf8').trim();

const signer = createSign('SHA256');
signer.update(data);
signer.end();
const sign = signer.sign({ key: keyPem, passphrase }, 'base64');
import json
import base64
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding

data = json.dumps(request_data).encode('utf-8')
password = open('password.txt','rb').read().strip()
private_key = serialization.load_pem_private_key(
open('private.pem','rb').read(),
password=password
)
signature = private_key.sign(data, padding.PKCS1v15(), hashes.SHA256())
sign = base64.b64encode(signature).decode('utf-8')
import java.security.Signature;
import java.util.Base64;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.bouncycastle.openssl.PEMEncryptedKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import com.fasterxml.jackson.databind.ObjectMapper;

ObjectMapper mapper = new ObjectMapper();
byte[] dataBytes = mapper.writeValueAsBytes(requestData);
char[] pass = Files.readString(Paths.get("password.txt")).toCharArray();
PEMParser parser = new PEMParser(Files.newBufferedReader(Paths.get("private.pem")));
PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) parser.readObject();
var privateKey = new JcaPEMKeyConverter()
.getKeyPair(ckp.decryptKeyPair(new JcePEMDecryptorProviderBuilder().build(pass)))
.getPrivate();
Signature sig = Signature.getInstance("SHA256withRSA");
sig.initSign(privateKey);
sig.update(dataBytes);
String sign = Base64.getEncoder().encodeToString(sig.sign());
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"io/ioutil"
)

data, _ := json.Marshal(requestData)
pemBytes, _ := ioutil.ReadFile("private.pem")
passBytes, _ := ioutil.ReadFile("password.txt")
block, _ := pem.Decode(pemBytes)
der, _ := x509.DecryptPEMBlock(block, passBytes)
priv, _ := x509.ParsePKCS1PrivateKey(der)
hash := sha256.Sum256(data)
sigBytes, _ := rsa.SignPKCS1v15(rand.Reader, priv, crypto.SHA256, hash[:])
sign := base64.StdEncoding.EncodeToString(sigBytes)

Pass the received sign in the Sign header.

Request Parameters

* - Required fields

NameTypeDescription
amount*decimal (11.2)Amount
order_id*string (128)Your id must be unique
service*string (100)Service type: online_banking_php_hpp, e_wallet_php_hpp
customer_ip*ipPayer's IP address
customer_code*string (100)Deposit Bank Code
success_redirect_idintId of redirect upon successful payment
fail_redirect_idintId of redirect in case of unsuccessful payment
notification_endpoint_idintNotification id
success_redirect_urlstring|max:255Link to redirect after successful payment
fail_redirect_urlstring|max:255Link to redirect after unsuccessful payment
notification_endpoint_urlstring|max:255Link to send a callback after the statuses are finalized

Response

NameDescription
urlLink to payment
payment_statusPayment status (wait — in the process of payment)
idAliKassa payment id
uuidAliKassa payment uuid
success_redirect_urlLink to your page for client redirect after successful payment
Important

When creating, always wait, check the payment status via the API or wait for a notification!

Example Response

Successful HTTP CODE 200:

{
"url": "https://pay-merchant.alikassa.com/bd291fe1-5c19-4113-ae62-a2d3c4d01d20",
"payment_status": "wait",
"id": 108465371,
"uuid": "bd291fe1-5c19-4113-ae62-a2d3c4d01d20",
"success_redirect_url": null
}

Unsuccessful HTTP CODE 400:

{
"message": "The given data was invalid.",
"errors": {
"..."
}
}

After receiving the URL, redirect the client to the link.

caution

If you passed notification_endpoint_id or notification_endpoint_url, you will receive a notification about the payment status change

Deposit Bank Codes

Online Banking PHP HPP (online_banking_php_hpp)

customer_codeBank Name
BDOBanco de Oro
BPIBank of the Philippine Islands
LBPLand Bank of the Philippines
RCBCRizal Commercial Banking Corporation
SBCSecurity Bank Corporation

E-Wallet PHP HPP (e_wallet_php_hpp)

customer_codeBank Name
GCASHGcash e-Wallet
PAYMAYAPayMaya e-Wallet

Creating Payouts

POSThttps://api-merchant.alikassa.com/v1/payout📋

Headers

HeaderValue
Content-Typeapplication/json
AccountYour account uuid, you can find in Accounts
SignRequest signature

Request Parameters

* - Required fields

NameTypeDescription
amount*decimal (11.2)Amount
order_id*string (128)Your unique order id (e.g., "1234")
service*string (100)payment_card_php
number*string (100)Recipient account number
customer_code*string (100)Payout Bank Code
customer_first_name*string (100)Payer's first name
customer_last_name*string (100)Payer's last name
notification_endpoint_idintNotification id
notification_endpoint_urlstring|max:255Link to send a callback after the statuses are finalized

Response

NameDescription
idAliKassa payment id
payment_statusPayment status (wait — in the process of payment)

Payout Bank Codes

Payment Card PHP (payment_card_php)

customer_codeBank Name
BDOEBANCO DE ORO Corporate
PNBePhilippine National Bank Biz
CBCChinabank
CBCeChinabank Biz
SBCeSecurity Bank Biz
DBPDevelopment Bank of the Philippines
SLBASterling Bank Asia
EWBEastwest Bank
PHPBBPhilippine Business Bank
SEABANKPHPSeaBank
MAYAMaya Bank Inc
GCASHGCASH
PAYMAYAPayMaya Philippines, Inc. (e-wallet)
BankComBank of Commerce
GOTYMEGOTYME Bank
KOMOKOMO Bank
CIMBPCIMB Bank Philippines
PSBPhilippine Savings Bank
RBCRobinsons Bank Corporation
HSBCPHSBC Philippines