PHP code example of hellovoid / orangepay-php
1. Go to this page and download the library: Download hellovoid/orangepay-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' );
hellovoid / orangepay-php example snippets
use Hellovoid \Orangepay \Client ;
use Hellovoid \Orangepay \Configuration ;
$client = \Hellovoid\Orangepay\Client::create(
\Hellovoid\Orangepay\Configuration::apiKey(
$apiKey,
$apiUrl
)
);
use Hellovoid \Orangepay \Client ;
use Hellovoid \Orangepay \Configuration ;
use Hellovoid \Orangepay \Exception \UnauthorizedException ;
use Hellovoid \Orangepay \Exception \ValidationException ;
use Hellovoid \Orangepay \Exception \NotFoundException ;
use Hellovoid \Orangepay \Exception \RateLimitException ;
use Hellovoid \Orangepay \Exception \InternalServerException ;
use Hellovoid \Orangepay \Exception \HttpException ;
$client = \Hellovoid\Orangepay\Client::create(
\Hellovoid\Orangepay\Configuration::apiKey(
$apiKey,
$apiUrl
)
);
try {
$charge = $client->initializeCharge([
'amount' => 10.00 ,
'currency' => 'USD' ,
'pay_method' => 'card' ,
'description' => 'Test description' ,
'reference_id' => 'my_unique_reference_id' ,
'email' => 'client@domain.ltd' ,
]);
} catch (UnauthorizedException $exception) {
} catch (ValidationException $exception) {
} catch (NotFoundException $exception) {
} catch (RateLimitException $exception) {
} catch (InternalServerException $exception) {
} catch (HttpException $exception) {
}
$client->getBalance();
$client->getCharges([
'pay_method' => 'card' ,
'start_date' => '2018-01-01' ,
'end_date' => '2018-01-02' ,
]);
$client->getCharge($chargeId);
$client->initializeCharge([
'amount' => 10.00 ,
'currency' => 'USD' ,
'pay_method' => 'card' ,
'description' => 'Test description' ,
'reference_id' => 'my-unique-reference-id' ,
'email' => 'client@domain.ltd' ,
'return_success_url' => 'https://my-site.ltd/payment-gateway-success' ,
'return_error_url' => 'https://my-site.ltd/payment-gateway-error' ,
'callback_url' => 'https://my-site.ltd/payment-gateway-callback' ,
]);
$client->refund([
'charge_id' => '1499ae90-f860-11e6-a8b6-e74ae337c2e8' ,
'amount' => 10.00
]);
$client->getTransfers([
'pay_method' => 'card' ,
'start_date' => '2018-01-01' ,
'end_date' => '2018-01-02' ,
]);
$client->getTransfer($transferId);
$client->transferToCard([
'reference_id' => 'my-unique-reference-id' ,
'amount' => 10.00 ,
'currency' => 'USD' ,
'description' => 'Test description' ,
'name' => 'John Doe' ,
'card_number' => '4111111111111111' ,
'card_expiry_month' => '02' ,
'card_expiry_year' => '19' ,
'address_country' => 'US' ,
'address_city' => 'New York' ,
'address_line1' => '123 East 169th Street Apt. 2A Bronx, NY 10456' ,
'callback_url' => 'https://my-site.ltd/payment-gateway-callback'
]);
$client->transferToCard([
'charge_id' => '1173157c-db4d-11e7-9296-cec278b6b50a' ,
'reference_id' => 'my-unique-reference-id' ,
'amount' => 10.00 ,
'currency' => 'USD' ,
'description' => 'Test description' ,
'address_country' => 'US' ,
'address_city' => 'New York' ,
'address_line1' => '123 East 169th Street Apt. 2A Bronx, NY 10456' ,
]);
$client->transferToBitcoinAddress([
'reference_id' => 'my-unique-reference-id' ,
'amount' => 10000000 ,
'currency' => 'BTC' ,
'description' => 'Test description' ,
'address' => '3**********FR' ,
]);
$client->rates('BTC-EUR' );
composer