iqex/cashier-client-php

PHP REST API client for iqex.pro

dev-master 2021-04-19 08:39 UTC

This package is not auto-updated.

Last update: 2021-04-20 04:24:00 UTC


README

A simple API client, written with PHP for iqex.pro.

For additional information about API visit

IQEX.PRO API Terms of Service

Requirements

  • PHP >= 5.6
  • ext-json
  • guzzle ~7.0"

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require iqex/cashier-client-php

Example

use Iqex\CashierApi\CashierClient;

$client = CashierClient::getInstance();
$client->ping();

You can get last response (ResponseInterface::class) uses getLastResponse method:

use Iqex\CashierApi\Payment;
use Iqex\CashierApi\Configuration;

$checkoutData = [
     'order_id' => '92f91094',
     'products' => "[{'title':'My product title','price':1200,'thumb':'Path to product thumb'}]",
     'currency' => 'USD',
     'amount' => 1,
     'lang' => 'EN',
     'callback_url' => 'https://skortabeast.com/callback-url',
     'success_url' => 'https://skortabeast.com/success-url',
     'cancel_url' => 'https://skortabeast.com/cancel-url',
     'redirect_url' => 'https://skortabeast.com/redirect-url'
];

Configuration::setConfig([
    'merchant_id' => 7,
    'sec_key' => '07b32232ea89cc2324780b7e22e7bdddd08b66c473800ef10fb8ba09af7171b1',
    'environment' => 'sandbox'
]);

try {
    $data = Payment::make($checkoutData);
} catch (\Exception $e) {
   return $this->sendResponse([
     'success' => false,
        'error' => [
           'message' => $e->getMessage()
        ]
     ]);
}

return $this->sendResponse([
    'payment' => $data->getPaymentId(),
    'message' => 'Payment succesfully added.'
]);

Available methods

Ping

ping

Check API server status

$data = $client->ping();

Pay

create

Make invoice to your market (order_id, merchant_id, products, currency, amount, lang)

Description:

order_id - Your order id
merchant_id - Your ID from dashboard
products - JSON representation of a value in array. e.g.:  [{'title':'My product title','price':1200,'thumb':'Path to product thumb'}]
currency - Product currency code, e.g.: USD
amount
lang - Lang payment page, (e.g., EN)
$checkoutData = [
     'order_id' => '92f91094',
     'products' => "[{'title':'My product title','price':1200,'thumb':'Path to product thumb'}]",
     'currency' => 'USD',
     'amount' => 1,
     'lang' => 'EN',
     'callback_url' => 'https://skortabeast.com/callback-url',
     'success_url' => 'https://skortabeast.com/success-url',
     'cancel_url' => 'https://skortabeast.com/cancel-url',
     'redirect_url' => 'https://skortabeast.com/redirect-url'
];

Configuration::setConfig([
    'merchant_id' => 7,
    'sec_key' => '07b32232ea89cc2324780b7e22e7bdddd08b66c473800ef10fb8ba09af7171b1',
    'environment' => 'sandbox'
]);

$data = Payment::make($checkoutData);

Withdrawal

make

Make withdrawal(order_id, currency, amount, address, type, callback_url)

Description:

order_id - Your order id
merchant_id - Your ID from dashboard
currency - Product currency code, e.g.: USD
amount
address - Withdrawal address
type - Withdrawal type:
       1 - withdrawal,
       2 - refund,
       3 - payout,
$checkoutData = [
     'order_id' => '92f91094',
     'currency' => 'USD',
     'amount' => 1,
     'address' => 'your_address',
     'type' => 1,
     'callback_url' => 'https://skortabeast.com/callback-url',
];

Configuration::setConfig([
    'merchant_id' => 7,
    'sec_key' => '07b32232ea89cc2324780b7e22e7bdddd08b66c473800ef10fb8ba09af7171b1',
    'environment' => 'sandbox'
]);

$data = Checkout::make($checkoutData);

Validate callback

make

Validate callback

Description:

Configuration::setConfig([
   'merchant_id' => 7,
   'sec_key' => '46d2b976fcc93146f13b5ccc30839d64bcee53f8317f7810a126773af3f4b12e',
   'environment' => 'sandbox'
]);

//withdrawal
$checkoutPayload = [
   'payment_id' => 'your payment id',
   'status' => 1,
   'order_id' => '92f91094',
   'signature' => 'your signature'
];

//or
//withdrawal

$checkoutWithdrawal = [
   'currency_code' => 'USD',
   'withdrawal_currency_code' => 'USD',
   'address' => '1231',
   'amount' => 1,
   'withdrawal_amount' => 1,
   'hash' => '1231',
   'order_id' => '92f91094',
   'status' => '45',
   'error_msg' => 'iternal error',
   'signature' => 'your signature'
];

if ((new SignatureValidate())->isValidSignature($checkoutWithdrawal)) {
   return $success;
}

License

iqex/cashier-client-api is released under the MIT License. See the bundled LICENSE for details.