Via Composer
$ composer require selimsalihovic/pikpay-php
To use the package first grab your credentials from your PikPay account. You will need your Authenticity Token (API_KEY) and Key (SECRET_KEY). Before any request, an instance of Gateway has to be constructed.
$gateway = new Gateway(getenv('ENDPOINT'), getenv('API_KEY'), getenv('SECRET_KEY'));
For each Request, a data array is needed. See the PikPay Docs to see which values need to be included for which request. Note: you do not need to include the 'digest' parameter as it is calculated for you on each request based on the data array.
Here is an example of a valid data array.
$data = [
'amount' => 5500,
'expiration-date' => 1707,
'cvv' => 286,
'pan' => 5464000000000008,
'ip' => '128.93.108.112',
'order-info' => 'Test Order',
'ch-address' => '1419 Westwood Blvd',
'ch-city' => 'Los Angeles',
'ch-country' => 'USA',
'ch-email' => 'john.doe@gmail.com',
'ch-full-name' => 'John Doe',
'ch-phone' => '636-48018',
'ch-zip' => '90024',
'currency' => 'USD', //EUR, BAM, HRK
'order-number' => 'order-d234djflq0wz',
'language' => 'en',
];
$response = $gateway->authorize($data);
if ($response->isSuccessfull()) {
//handle success case
} else {
//display error
}
Capture requests are sent only for previously authorized transactions.
$gateway->authorize($data);
$response = $gateway->capture($data);
The purchase request does both.
$response = $gateway->purchase($data);
$response = $gateway->refund($data);
$response = $gateway->void($data);
To run the tests be sure to have all the dev dependencies from composer.json installed.
$ cd pikpay-php && cp example.phpunit.xml.dist phpunit.xml.dist
$ nano phpunit.xml.dist #update your credentials and save them
$ vendor/bin/phpunit