payrex/payrex-php

PayRex PHP Library

v1.0.1 2024-10-02 15:07 UTC

This package is auto-updated.

Last update: 2024-11-02 15:23:46 UTC


README

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.

Requirements

PHP 5.6.0 and later.

Composer

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');

Manual Installation

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');

Dependencies

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.

Getting Started

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;

Handle errors

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>";
}