PayRex PHP library provides PHP applications an easy access to the PayRex API. Explore various PHP classes that represents PayRex API resources on object instantiation.
Check example.php see usage examples.
PHP 5.6.0 and later.
You can install the library via Composer. Run the following command:
composer require payrex/payrex-php
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
If you prefer to manually install the library instead of using composer, you can download the latest release. Then, to use the bindings, include the initialize.php
file.
require_once('/path/to/payrex-php/initialize.php');
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that the required extensions are available.
Simple usage looks like:
$client = new \Payrex\PayrexClient('Your PayRex secret api key');
$paymentIntent = $client->paymentIntents->create([
'amount' => 10000,
'currency' => 'PHP',
'payment_methods' => ['card']
]);
echo $paymentIntent->id;
try {
$client = new \Payrex\PayrexClient('Your PayRex secret api key');
$paymentIntent = $client->paymentIntents->create([
'amount' => 10000,
'currency' => 'PHP',
'payment_methods' => ['card']
]);
} catch(\Payrex\Exceptions\InvalidRequestException $e) {
print "<pre>";
print_r($e->getError());
print "</pre>";
}