Installing the Library

You can download it manually in your PHP project (download from here):

require_once 'path/to/paxexpay.php';

This library requires PHP5.6+, and cURL extensions to work.

Before you start using the PHP library in your code, initialize it like this:

$merchantId="XXXXXXX"; // Merchant ID here
$uniqueNumber="XXXXX"; // Merchant Unique Number here
$accessCode="XXXXX"; // Access code here
$version = 1; // The API version
$paxapi = new PaxPayapi($merchantId, $uniqueNumber, $accessCode, $version);

Now you're good to go.

Generate Address

Returns a newly generated address, and its unique(!) label generated by Paxexpay.com. You need to send unique label to generate address each time if it matches with any current lable then system will create a different lable and pass it in response.

You need to include callback URL where you wish to recieve callback for any activity for that generated address.

$newAddressInfo=$paxapi->get_new_address(array('label' => 'Demolabel', 'callback_url'=>'https://paxexpay.com/web/api'));
            

Sample Success and error response

Response: 200 SUCCESS

{
  "code":200,
  "status":"Success",
  "msg":"Address generated successfully.",
  "data":
    {
      "address":"PLj22frhqNGwVbhj786ghbnhjMijpyh2h",
      "label":"Demolabel",
      "callback_url":"https:\/\/paxexpay.com\/web\/api"
    }
}

Response: 201 ERROR

{
  "code":201,
  "status":"Failed",
  "msg":"Error Message Here"
}
            

Response will be sent in Json format.

Callback Validation

Callback will be sent on any activity for address. It will have option to authenticate keys to verify callback which we sent in Header of that callback with post data for much better sucurity of your callback and to be ensure that Callback is coming from right place.

Verification Process of Callback

We pass two keys MerchantID and Merchant Key/Auth Key in form of base64_encode with Header to validate. Which you need to validate like below example-

Key 1 - merchantidcallback //Merchant ID
Key 2 - merchantuniquecode // Merchant Unique Key

$merchantidcallback = base64_decode($_SERVER["HTTP_MERCHANTIDCALLBACK"]);
$merchantuniquecode = base64_decode($_SERVER["HTTP_MERCHANTUNIQUECODE"]);

$authid="AuthenticationID Here";
$authkey="Auth Key Here";
$authid=strtoupper(md5($authid));
$authkey=strtoupper(md5($authkey));

Compare these two with above Keys. If its correct then you can ensure that Callback is coming from right place.

Response will be sent in Json format as Post Data.

Sample Post data

{
  "Success":"1",
  "address":"PLj22frhqNGwVbhj786ghbnhjMijpyh2h",
  "network_fee":"0.0016312",
  "amount_received":"5000",
  "amount_sent":"5000",
  "txid":"6a97cb087c722524ec2b720a1bb221b486c6753af75cd24248f4394b11a7b727",
  "confirmations":"5",
  "uniquecode":"5168239740"
}

Verify Address

This API will be used to verify Paxexcoin Addresses

$VerifyAddress=$paxapi->verify_address(array('address' => 'PLj22frhqNGwVbhj786ghbnhjMijpyh2h'));

Sample Success and error response

Response: 200 SUCCESS

{
  "code":200,
  "status":"Success",
  "msg":"Address Valid"
}
Response: 201 ERROR

{
  "code":201,
  "status":"Failed",
  "msg":"Error Message Here"
}

Get Address Balance

This API Returns the balance of the specified addresses using Address label.

$Addressbalance=$paxapi->get_address_balance(array('label' => 'Demolabel'));

Sample Success and error response

Response: 200 SUCCESS

{
  "code":200,
  "status":"Success",
  "msg":"Address Balance.",
  "data":
    {
      "available_balance":"5000"
    }
}
              
Response: 201 ERROR

{
  "code":201,
  "status":"Failed",
  "msg":"Error Message Here"
}

Withdraw / Transfer

Withdraws / Transfer amount of coins from any addresses in your account.


$SendCoins=$paxapi->withdraw(array('label' => 'Demolabel','to_addresses' => 'PLj22frhqNGwVbhj786ghbnhjMijpyh2h','amount' => '5000','fees' => '5.5','uniquecode' => 'HUY78UIOP'));
              

Sample Success and error response

Response: 200 SUCCESS

{
  "code":200,
  "status":"Success",
  "msg":"Payment Sent.",
  "data":
    {
      "address":"PLj22frhqNGwVbhj786ghbnhjMijpyh2h",
      "amount":"5000",
      "fees":"5.5",
      "hash":"6a97cb087c722524ec2b720a1bb221b486c6753af75cd24248f4394b11a7b727"
    }
}
        
Response: 201 ERROR

{
  "code":201,
  "status":"Failed",
  "msg":"Error Message Here"
}
            

Get Transaction List

Using this you can get list of all Transaction performed on that Address/Label. You can also specify number of record you want to get.

$TransactionList=$paxapi->get_transaction(array('label' => 'Demolabel','record' => 50));

Sample Success and error response

Response: 200 SUCCESS

{
  "code":200,
  "status":"Success",
  "msg":"Transaction List.",
  "data":
    {
      "TO_ADDRESS/FROM_ADDRESS":"PLj22frhqNGwVbhj786ghbnhjMijpyh2h",
      "AMOUNT":"5000",
      "FEES":"5.5",
      "TX_ID":"6a97cb087c722524ec2b720a1bb221b486c6753af75cd24248f4394b11a7b727",
      "CONFIRMATION":"20",
      "MESSAGE":"Message Here",
      "TIME":"December 10, 2018 04:10",
      "TIMESTAMP":"2018-12-10 04:10:00"
    }
}

            
Response: 201 ERROR

{
  "code":201,
  "status":"Failed",
  "msg":"Error Message Here"
}