Kaspay API client for PHP
Just copy the content of dist to your project directory and include kaspay_api.combined.php file.
Login to Kaspay with your merchant account and directly go to Profile Setting Page to acquire both encryption key and MAC key. There should be API Keys section in that page.
Trouble getting merchant keys? API Keys section does not exist? Please contact us.
List of available services:
- Payment API
///Constructing the client
$client = new Kaspay_payment_api_client(
<your uaccount>, <your enc key>, <your MAC key>
);
$attempt = new stdClass();
$attempt->merchant_uaccount = <your uaccount>;
$attempt->approve_url = <your site approve URL>;
$attempt->reject_url = <your site reject URL>;
$product_1 = new Product();
$product_1->id = "product-1";
$product_1->name = "product-1";
$product_1->price = 100;
$product_1->quantity = 1;
$attempt->transaction_no = <your generated transaction ID>;
$attempt->timestamp = time();
$attempt->products = array(
$product_1,
clone $product_1,
clone $product_1,
);
$attempt->total = 10000;
///Calling the API
///You can comment the next line in production mode, for sandbox only
$client->set_as_development();
$client->create($attempt);
///Getting the response
$response = json_encode($client->get_response());
print_r($response);///Constructing the client
$client = new Kaspay_payment_api_client(
<your uaccount>, <your enc key>, <your MAC key>
);
///Calling the API.
///You can comment the next line in production mode, for sandbox only
$client->set_as_development();
$client->execute($id);
///Getting the response
$response = json_encode($client->get_response());
print_r($response);Applicable only for executed payments
///Constructing the client
$client = new Kaspay_payment_api_client(
<your uaccount>, <your enc key>, <your MAC key>
);
///Calling the API.
///You can comment the next line in production mode, for sandbox only
$client->set_as_development();
///$reference_no is acquired from execute() call response
$client->refund($reference_no);
///Getting the response
$response = json_encode($client->get_response());
print_r($response);