Skip to content

revlenuwe/gearer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyceliumGear gateway Laravel

GEAR

Implementation MyceliumGear gateway payment processing support for Laravel

For more information check Mycelium Gear

Installation

Via Composer

$ composer require revlenuwe/gearer

Register the service provider and facade if you work with Laravel 5.4:

// config/app.php

'providers' => [
    ...
    Revlenuwe\Gearer\GearerServiceProvider::class,
];


'aliases' => [
    ...
    Revlenuwe\Gearer\Facades\Gearer::class,
];

For Laravel 5.5+ they will be registered automatically

You can publish the gearer.php config with:

$ php artisan vendor:publish --provider="Revlenuwe\Gearer\GearerServiceProvider"

Usage

Creating order:
$order = Gearer::createOrder($amount, $lastKeyChainId);
Canceling order:
$result = Gearer::cancelOrder($orderOrPaymentId);
Receiving Last Keychain ID:
$lastKeyChainId = Gearer::getLastKeychainId();

// 1
Checking Order Status Manually:
$orderData = Gearer::checkOrderStatusManually($paymentId);

/*
{
  "status": 2,
  "amount": 7894000,
  "address": "1NZov2nm6gRCGW6r4q1qHtxXurrWNpPr1q",
  "transaction_ids": ["f0f9205e41bf1b79cb7634912e86bb840cedf8b1d108bd2faae1651ca79a5838"],
  "id": 1,
  "payment_id": "y78033435ea02f024f9abdfd04adabe314a322a0d353c33beb3acb7d97f1bdeb",
  "amount_in_btc": "0.07894",
  "amount_paid_in_btc": "0.07894",
  "keychain_id": 3,
  "last_keychain_id": 3
}
*/
Order Websocket URL:
$websocketUrl = Gearer::getOrderWebsocketUrl($orderId);


// https://gateway.gear.mycelium.com/gateways/:api_gateway_id/orders/:orderId:/websocket
Receiving Order Status Change Callback:
public function handleCallback(Request $request)
{
    //Passing $request is optional
    $order = Gearer::handleOrderStatusCallback($request);

    if($order !== false){
        /*
        [
          "status": 2,
          "amount": 7894000,
          "address": "1NZov2nm6gRCGW6r4q1qHtxXurrWNpPr1q",
          "transaction_ids": ["f0f9205e41bf1b79cb7634912e86bb840cedf8b1d108bd2faae1651ca79a5838"],
          "id": 1,
          "payment_id": "y78033435ea02f024f9abdfd04adabe314a322a0d353c33beb3acb7d97f1bdeb",
          "amount_in_btc": "0.07894",
          "amount_paid_in_btc": "0.07894",
          "keychain_id": 3,
          "last_keychain_id": 3
        ]
        */
    }
}
Setting config on the fly:
$gearer = Gearer::setConfig($gatewayId, $gatewaySecret);

$lastKeychainId = $gearer->getLastKeychainId();

License

The MIT License (MIT). Please see License File for more information.