PHP code example of xenon / nagad-api

1. Go to this page and download the library: Download xenon/nagad-api 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/ */

    

xenon / nagad-api example snippets




use Xenon\NagadApi\Helper;
use Xenon\NagadApi\Base;

===========================
 * all configuration are used here for demo purpose.
 * for use in dev mode use 'development'
 * for use in production mode use 'production'
 * ===============================================================================
 **/
$config = [
    'NAGAD_APP_ENV' => 'development', // development|production
    'NAGAD_APP_LOG' => '1',
    'NAGAD_APP_ACCOUNT' => '016XXXXXXXX', //demo
    'NAGAD_APP_MERCHANTID' => '6800000025', //demo
    'NAGAD_APP_MERCHANT_PRIVATE_KEY' => 'MIIEvFAAxN1qfKiRiCL720FtQfIwPDp9ZqbG2OQbdyZUB8I08irKJ0x/psM4SjXasglHBK5G1DX7BmwcB/PRbC0cHYy3pXDmLI8pZl1NehLzbav0Y4fP4MdnpQnfzZJdpaGVE0oI15l',
    'NAGAD_APP_MERCHANT_PG_PUBLIC_KEY' => 'MIIBIjANBc54jjMJoP2toR9fGmQV7y9fzj',
    'NAGAD_APP_TIMEZONE' => 'Asia/Dhaka',
];

$nagad = new Base($config, [
    'amount' => 10,
    'invoice' => Helper::generateFakeInvoice(15, true),
    'merchantCallback' => 'https://example.com/payment/success/id=4',
]);

{
	merchantId: "683XXXX225",
	orderId: "CKH060JXXXXXFRA2",
	paymentRefId: "MXXXXXXXXtIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=",
	amount: "16",
	clientMobileNo: "016****5428",
	merchantMobileNo: "01XXXXXXX10",
	orderDateTime: "2021-11-23 23:48:22.0",
	issuerPaymentDateTime: "2021-11-23 23:50:08.0",
	issuerPaymentRefNo: "000XXXW",
	additionalMerchantInfo: null,
	status: "Success",
	statusCode: "000",
	cancelIssuerDateTime: null,
	cancelIssuerRefNo: null
}