PHP code example of rwbuild / guhemba-web-element

1. Go to this page and download the library: Download rwbuild/guhemba-web-element 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/ */

    

rwbuild / guhemba-web-element example snippets


    \RWBuild\Guhemba\Facades\Guhemba::partnerKeys([
        'GUHEMBA_PUBLIC_PARTNER_KEY' => 'request-this-on-guhemba',
        'GUHEMBA_PARTNER_KEY' => 'request-this-on-guhemba',
        'GUHEMBA_BASE_URL' => 'guhemba-base-url'// Ask guhemba support team
    ]);

    Guhemba::dynamicMerchant([
        'GUHEMBA_API_KEY' => 'wallet-merchant-integration-api-key',

        'GUHEMBA_MERCHANT_KEY' => 'wallet-merchant-key',

        'GUHEMBA_PUBLIC_KEY' => 'wallet-merchant-integration-public-key',

        'GUHEMBA_REDIRECT_URL' => 'your-dynamic-url'
    ]);

    $amount = 1000;

    $paymentReference = 'order_id';

    $confirmPaymentKey = 'Unique_key';

    $qrcode = Guhemba::generateQrcode(
        $amount,
        $paymentReference,
        $confirmPaymentKey
    )->getQrcode();

    [
        'payment_reference' => 'Your-provided-payment-ref',
        'transaction_token' => 'string',
        'confirm_payment_key' => 'string'
    ]

    function redirectToGuhemba()
    {
        $qrcodeSlug ='91da-5a565f0b173c';
        $paymentRef = 6;

        return Guhemba::redirect($qrcodeSlug, $paymentRef)
    }

    function redirectToGuhemba()
    {
        $qrcodeSlug ='91da-5a565f0b173c';
        $paymentRef = 6;
        $paymentOption = "card";// can be:  mtn,card or choice(the default)

        return Guhemba::redirect($qrcodeSlug, $paymentRef,$paymentOption)
    }

    function redirectToGuhemba()
    {
        $qrcodeSlug ='91da-5a565f0b173c';
        $paymentRef = 6;

        return Guhemba::dump()->redirect($qrcodeSlug, $paymentRef)
    }

    function redirectToGuhemba()
    {
        $qrcodeSlug ='91da-5a565f0b173c';
        $paymentRef = 6;

        return Guhemba::shouldLog()->redirect($qrcodeSlug, $paymentRef)
    }

    function guhembaCallback()
    {
        $transaction = Guhemba::transaction()->getTransaction();
    }

    function guhembaCallback()
    {
        $transaction = Guhemba::stateless()->transaction()->getTransaction();
    }

  $token = 'S-7578987654';

  $transaction = Guhemba::transactionFromToken(
                    $token
                )->getTransaction();


    $paymentRef = "2";
    $paymentConfirmKey = "09876545";
    $response = Guhemba::transactionFromPaymentReference(
        $paymentRef,
        $paymentConfirmKey
    );

    if (!$response->isOk()) dd($response->getMessage());

    $transaction = $response->getTransaction();

    $qrcodeId = 4;
    $response = Guhemba::transactionFromQrcode(
        $qrcodeId
    );

    if (!$response->isOk()) dd($response->getMessage());

    $transaction = $response->getTransaction();

    $amount = 1000;
    $response = Guhemba::generateQrcode($amount)->getResponse();

    $amount = 1000;
    $generateQrcode = Guhemba::generateQrcode($amount);

    if (! $generateQrcode->isOk()) return $generateQrcode->getMessage();

    $qrcode = $generateQrcode->getQrcode();

 php artisan vendor:publish --tag=config