bleumi / bleumi-pay-sdk-php
PHP SDK for Bleumi Pay REST API
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ~2.6
This package is auto-updated.
Last update: 2021-04-30 04:55:31 UTC
README
Bleumi Pay SDK for PHP
The Bleumi Pay SDK helps you integrate Algo, Algorand Standard Asset, Ethereum, ERC-20, RSK, RSK ERC-20 & xDai payments and payouts into your business or application. The SDK bundles Bleumi Pay API into one SDK to ease implementation and support.
bleumi-pay-sdk-php is a PHP library that provides an interface between your PHP application and Bleumi Pay API. This tutorial covers the basics, including examples, needed to use the SDK.
Getting Started
Pre-requisites
Development Environment
PHP 5.5 and later
Obtain An API Key
Bleumi Pay SDK uses API keys to authenticate requests. You can obtain an API key through the Bleumi Pay Dashboard.
Install Package
Composer
To install the bindings via Composer, add the following to composer.json
:
{
"require": {
"bleumi/bleumi-pay-sdk-php":"1.0.23"
}
}
Then run composer install
Manual Installation
Download the files and include autoload.php
:
require_once('/path/to/bleumi-pay-sdk-php/vendor/autoload.php');
Run Sample Code
The following code generates an unique checkout URL to accept payment from the buyer.
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: ApiKeyAuth $config = Bleumi\Pay\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', '<Your API Key>'); $apiInstance = new Bleumi\Pay\Api\HostedCheckoutsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $chain = new \Bleumi\Pay\Model\Chain(); try { $createReq = new \Bleumi\Pay\Model\CreateCheckoutUrlRequest(); // Checkout URL creation parameters. $createReq->setId("<ID>"); // string | Eg. '1' $createReq->setCurrency("<CURRENCY>"); // string | Eg. 'USD' $createReq->setAmount("<AMOUNT>"); // string | Eg. '10' $createReq->setSuccessUrl("<SUCCESS_URL>"); // string | Eg. https://demo.store/api/completeOrder $createReq->setCancelUrl("<CANCEL_ORDER_URL>"); // string | Eg. https://demo.store/api/cancelOrder $createReq->setToken("<TOKEN>"); // string | Replace <TOKEN> by anyone of the following values: 'ETH' or 'XDAI' or 'XDAIT' or ECR-20 Contract Address or 'RBTC' or RSK ECR-20 Contract Address or 'Asset ID' of Algorand Standard Asset. | Optional $createReq->setChain($chain::GOERLI); //Optional, but required if '<Token>' is specified; Replace GOERLI with the Chain as required $result = $apiInstance->createCheckoutUrl($createReq); echo json_encode($result, JSON_PRETTY_PRINT); } catch (Exception $e) { echo 'Exception when calling HostedCheckoutsApi->createCheckoutUrl: ', $e->getMessage(), nl2br (" \n "); echo 'Code: ', $e->getCode(), nl2br (" \n "); if (method_exists($e, 'getResponseBody')) { echo 'Response Body: ', $e->getResponseBody(), nl2br (" \n "); } } ?>
More examples can be found under each method in SDK Classes section.
SDK Classes
Class | Method | HTTP request | Description |
---|---|---|---|
HostedCheckoutsApi | createCheckoutUrl | POST /v1/payment/hc | Generate a unique checkout URL to accept payment. |
HostedCheckoutsApi | listTokens | GET /v1/payment/hc/tokens | Retrieve all tokens configured for the Hosted Checkout in your account in the Bleumi Pay Dashboard. |
HostedCheckoutsApi | validateCheckoutPayment | POST /v1/payment/hc/validate | Validate the GET parameters passed by Hosted Checkout in successUrl upon successfully completing payment. |
PaymentsApi | getPayment | GET /v1/payment/{id} | Retrieve the wallet addresses & token balances for a given payment |
PaymentsApi | listPayments | GET /v1/payment | Retrieve all payments created. |
PaymentsApi | settlePayment | POST /v1/payment/{id}/settle | Settle a specific amount of a token for a given payment to the transferAddress and remaining balance (if any) will be refunded to the buyerAddress |
PaymentsApi | refundPayment | POST /v1/payment/{id}/refund | Refund the balance of a token for a given payment to the buyerAddress |
PaymentsApi | getPaymentOperation | GET /v1/payment/{id}/operation/{txid} | Retrieve a payment operation for a specific payment. |
PaymentsApi | listPaymentOperations | GET /v1/payment/{id}/operation | Retrieve all payment operations for a specific payment. |
PayoutsApi | createPayout | POST /v1/payout | Create a payout. |
PayoutsApi | listPayouts | GET /v1/payout | Returns a list of payouts |
Documentation For Models
- AlgorandAddress
- AlgorandBalance
- AlgorandWalletAddress
- AlgorandWalletInputs
- BadRequest
- Chain
- CheckoutToken
- CreateCheckoutUrlRequest
- CreateCheckoutUrlResponse
- CreatePayoutRequest
- CreatePayoutResponse
- EthereumAddress
- EthereumBalance
- EthereumWalletAddress
- EthereumWalletInputs
- PaginatedPaymentOperations
- PaginatedPayments
- PaginatedPayoutItems
- Payment
- PaymentAddresses
- PaymentBalances
- PaymentOperation
- PaymentOperationInputs
- PaymentOperationResponse
- PaymentRefundRequest
- PaymentSettleRequest
- Payout
- PayoutItem
- PayoutItemInputs
- RskAddress
- RskBalance
- ValidateCheckoutRequest
- ValidateCheckoutResponse
- WalletBalance
Limitations
License
Copyright 2020 Bleumi, Inc.
Code licensed under the MIT License.