PHP code example of securionpay / securionpay-php

1. Go to this page and download the library: Download securionpay/securionpay-php 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/ */

    

securionpay / securionpay-php example snippets




  \SecurionPay\Util\SecurionPayAutoloader::register();

use SecurionPay\SecurionPayGateway;
use SecurionPay\Exception\SecurionPayException;

$gateway = new SecurionPayGateway('sk_test_[YOUR_SECRET_KEY]');

$request = array(
    'amount' => 499,
    'currency' => 'EUR',
    'card' => array(
        'number' => '4242424242424242',
        'expMonth' => 11,
        'expYear' => 2022
    )
);

try {
    $charge = $gateway->createCharge($request);

    // do something with charge object - see https://securionpay.com/docs/api#charge-object
    $chargeId = $charge->getId();

} catch (SecurionPayException $e) {
    // handle error response - see https://securionpay.com/docs/api#error-object
    $errorType = $e->getType();
    $errorCode = $e->getCode();
    $errorMessage = $e->getMessage();
}
json
{
  "urionpay/securionpay-php": "^2.5.0"
  }
}