PHP code example of ilrwebservices / cardpointe-gateway-rest-api-client

1. Go to this page and download the library: Download ilrwebservices/cardpointe-gateway-rest-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ilrwebservices / cardpointe-gateway-rest-api-client example snippets




ardPointeGateway\CardPointeGatewayRestClient;

$client = new CardPointeGatewayRestClient([
  'cp_user' => $_ENV['CARDPOINTE_GATEWAY_API_USER'],
  'cp_pass' => $_ENV['CARDPOINTE_GATEWAY_API_PASS'],
  'cp_site' => 'fts',
]);

$client_response = $client->request('GET', 'https://<cp_site>.cardconnect.com/cardconnect/rest/inquireMerchant/<merchid>');

$client_response = $client->request('GET', 'inquireMerchant/<merchid>');

$client_response = $client->get('inquireMerchant/<merchid>');

$client_data_raw = (string) $client_response->getBody();

// Returns:
// {
//   "site": "fts",
//   "acctupdater": "N",
//   "cvv": "N",
//   "cardproc": "RPCT",
//   "fee_type": "N",
//   "enabled": true,
//   "echeck": "N",
//   "merchid": "xxxxxxxxxxxx",
//   "avs": "N"
// }

$client_data = $client_response->getData();

// Returns:
// Array
// (
//     [site] => fts
//     [acctupdater] => N
//     [cvv] => N
//     [cardproc] => RPCT
//     [fee_type] => N
//     [enabled] => 1
//     [echeck] => N
//     [merchid] => xxxxxxxxxxxx
//     [avs] => N
// )

$new_client_response = $client->post('auth', [
  'json' => [
    'merchid' => 'xxxxxxxxxxxx',
    'amount' => '20.01',
    'expiry' => 'MMYY',
    'account' => '4111111111111111',
    'cvv2' => '123',
  ],
]);

try {
  $new_client_response = $client->post('auth', [
    'json' => [
      'merchid': 'xxxxxxxxxxxx',
      'amount': '20.01',
      'expiry': 'MMYY',
      'account': '4111111111111111',
      'cvv2': '123',
    ],
  ]);
}
// Could not connect to server or other network issue.
catch (\GuzzleHttp\Exception\ConnectException $e) {
  print_r($e->getMessage());
}
// 4xx error. This is either a 400 Bad Request (e.g. invalid syntax) or
// 401 Unauthorized (e.g. bad credentials).
catch (\GuzzleHttp\Exception\ClientException $e) {
  print_r($e->getResponse()->getData());
  print_r($e->getMessage());
}
// 5xx error. This is an 'Internal Server Error'.
catch (\GuzzleHttp\Exception\ServerException $e) {
  print_r($e->getResponse()->getData());
  print_r($e->getMessage());
}