PHP code example of jagdish-j-p / billdesk-hmac

1. Go to this page and download the library: Download jagdish-j-p/billdesk-hmac 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/ */

    

jagdish-j-p / billdesk-hmac example snippets


BILLDESK_TRANSACTION_RESPONSE_PATH=billdesk/payments/transactions/callback
BILLDESK_MANDATE_RESPONSE_PATH=billdesk/payments/mandates/callback
BILLDESK_WEBHOOK_PATH=billdesk/payments/webhook

BILLDESK_MERCHANT_ID=
BILLDESK_CLIENT_ID=
BILLDESK_HMAC_KEY=
BILLDESK_MERCHANT_LOGO="${APP_URL}/assets/img/logo.jpg"
BILLDESK_RETRY_COUNT=3
BILLDESK_CHILD_WINDOW=false
BILLDESK_ITEM_CODE=DIRECT
BILLDESK_UAT_PREFIX="test-prefix"

    /**
     * This will be called after the user approve the mandate
     * @param Request $request
     *
     * @return Response
     */
    public function mandateCallback(MandateModifyResponseRequest $request, $id = null)
    {
        $response = $request->handle($id);

        if ($response['response_format'] == 'JSON') {
            return response()->json(['response' => $response, 'billdesk_response' => $request->all()]);
        }

        dd($response, $request); // Remove this line and modify as per your needs.
    }
    
    /**
     * This will be called after the user approve the payment
     * on the bank side
     *
     * @param Request $request
     * @return Response
     */
    public function callback(Request $request)
    {
        $response = $request->handle();

        if ($response['response_format'] == 'JSON')
            return response()->json(['response' => $response, 'billdesk_response' => $request->all()]);

        dd($response, $request); // Remove this line and modify as per your needs.
        // Update your order status
    }

    /**
     * This will handle any direct call from BillDesk
     *
     * @param Request $request
     * @return string
     */
    public function webhook(Request $request)
    {
        $response = $request->handle();

        // Update your order status

        return 'OK';
    }

	


use JagdishJP\BilldeskHmac\Facades\BilldeskHmac;

/**
 * Returns status of transaction
 * 
 * @param string $orderid reference order id
 * @return array
 */
$status = BilldeskHmac::getTransactionStatus($orderid);
bash
php artisan billdesk:publish
bash
php artisan migrate
bash
php artisan billdesk:transaction-status
bash
php artisan billdesk:transaction-status --orderid=orderid1 --orderid=orderid2 --orderid=orderid3