PHP code example of revlenuwe / gearer

1. Go to this page and download the library: Download revlenuwe/gearer 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');

/* Start to develop here. Best regards https://php-download.com/ */

    

revlenuwe / gearer example snippets

 php
// config/app.php

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


'aliases' => [
    ...
    Revlenuwe\Gearer\Facades\Gearer::class,
];
 bash
$ php artisan vendor:publish --provider="Revlenuwe\Gearer\GearerServiceProvider"
 php
$order = Gearer::createOrder($amount, $lastKeyChainId);
 php
$result = Gearer::cancelOrder($orderOrPaymentId);
 php
$lastKeyChainId = Gearer::getLastKeychainId();

// 1
 php
$websocketUrl = Gearer::getOrderWebsocketUrl($orderId);


// https://gateway.gear.mycelium.com/gateways/:api_gateway_id/orders/:orderId:/websocket

 php
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
        ]
        */
    }
}
 php
$gearer = Gearer::setConfig($gatewayId, $gatewaySecret);

$lastKeychainId = $gearer->getLastKeychainId();