bleumi/bleumi-pay-sdk-php

This package is abandoned and no longer maintained. The author suggests using the bleumi/payment-sdk-php package instead.

PHP SDK for Bleumi Pay REST API

1.0.23 2020-06-10 17:10 UTC

This package is auto-updated.

Last update: 2021-04-30 04:55:31 UTC


README

BleumiPay.png

Bleumi Pay SDK for PHP

GitHub license

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

packagist (scoped)

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

Limitations

License

Copyright 2020 Bleumi, Inc.

Code licensed under the MIT License.