PHP code example of coolerproyt / razerms-php

1. Go to this page and download the library: Download coolerproyt/razerms-php 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/ */

    

coolerproyt / razerms-php example snippets


use CoolerProYT\RazermsPHP\PaymentChannel;

$rms = new PaymentChannel('YOUR_MERCHANT_ID','YOUR_VERIFY_KEY','SANDBOX_MODE'); // SANDBOX_MODE default value is false

$response = $rms->createPayment([
    'MerchantID' => 'YOUR_MERCHANT_ID',
    'ReferenceNo' => 'YOUR_REFERENCE_NO',
    'TxnType' => 'SALS', //Refer to the API documentation for the full list of TxnType
    'TxnChannel' => 'CREDIT7', //Refer to the API documentation for the full list of TxnChannel
    'TxnCurrency' => 'MYR',
    'TxnAmount' => '1.00', //Amount your customer needs to pay
    'Signature' => md5('TnxAmount'.'YOUR_MERCHANT_ID'.'YOUR_REFERENCE_NO'.'YOUR_VERIFY_KEY'),
    'CC_PAN' => '5555555555554444', //Credit Card Number for sandbox mode
    'CC_CVV2' => '444', //Credit Card CVV for sandbox mode
    'CC_MONTH' => '12', //Credit Card Expiry Month for sandbox mode, can be any future date
    'CC_YEAR' => '26', //Credit Card Expiry Year for sandbox mode, can be any future date
    //Other optional and conditional parameters, refer to the API documentation for the full list
],'AUTO_REDIRECT'); //AUTO_REDIRECT will redirect the user to the payment page, default value will be false

$response = $rms->createPayment([
    'MerchantID' => 'YOUR_MERCHANT_ID',
    'ReferenceNo' => 'YOUR_REFERENCE_NO',
    'TxnType' => 'SALS', //Refer to the API documentation for the full list of TxnType
    'TxnChannel' => 'TNG-EWALLET', //Refer to the API documentation for the full list of TxnChannel
    'TxnCurrency' => 'MYR',
    'TxnAmount' => '1.00', //Amount your customer needs to pay
    'Signature' => md5('TnxAmount'.'YOUR_MERCHANT_ID'.'YOUR_REFERENCE_NO'.'YOUR_VERIFY_KEY'),
],'AUTO_REDIRECT'); //AUTO_REDIRECT will redirect the user to the payment page, default value will be false

    'ReturnURL' => '',
    'NotificationURL' => '',
    'CallbackURL' => '',
    'FailedURL' => '',

$rms->redirectToPaymentPage(json_decode($response)->TxnData);

namespace App\Livewire;

use Livewire\Component;
use CoolerProYT\RazermsPHP\PaymentChannel;

class Payment extends Component
{
    public function pay(){
        $rms = new PaymentChannel('YOUR_MERCHANT_ID','YOUR_VERIFY_KEY','SANDBOX_MODE');

        $response = $rms->createPayment([
            'MerchantID' => 'YOUR_MERCHANT_ID',
            'ReferenceNo' => '1',
            'TxnType' => 'SALS', //Refer to the API documentation for the full list of TxnType
            'TxnChannel' => 'CREDITZ', //Refer to the API documentation for the full list of TxnChannel
            'TxnCurrency' => 'MYR',
            'TxnAmount' => '1.00', //Amount your customer needs to pay
            'Signature' => md5('TnxAmount'.'YOUR_MERCHANT_ID'.'YOUR_REFERENCE_NO'.'YOUR_VERIFY_KEY'),
            'CC_PAN' => '5555555555554444', //Credit Card Number for sandbox mode
            'CC_CVV2' => '444', //Credit Card CVV for sandbox mode
            'CC_MONTH' => '12', //Credit Card Expiry Month for sandbox mode, can be any future date
            'CC_YEAR' => '26', //Credit Card Expiry Year for sandbox mode, can be any future date
            //Other optional and conditional parameters, refer to the API documentation for the full list
        ]); //AUTO_REDIRECT will redirect the user to the payment page, default value will be false

        $response = json_decode($response);

        return redirect()->route('pay')->with(['postData' => $response->TxnData]);
    }

    public function render()
    {
        return view('livewire.payment');
    }
}

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use CoolerProYT\RazermsPHP\DirectPayment;

class PaymentController extends Controller
{
    public function pay(Request $request){
        $rms = new PaymentChannel('YOUR_MERCHANT_ID','YOUR_VERIFY_KEY','SANDBOX_MODE');
        
        $rms->redirectToPaymentPage($request->session()->get('postData'));
    }
}

$response = $rms->checkChannelAvailability($merchantID);

use CoolerProYT\RazermsPHP\ApiChannel;

$rms = new ApiChannel('YOUR_MERCHANT_ID','YOUR_VERIFY_KEY','SANDBOX_MODE'); // SANDBOX_MODE default value is false

$response = $rms->directStatusRequery([
    'amount' => 'TRANSACTION_AMOUNT_OF_THE_txID',
    'txID' => 'YOUR_txID',
    'domain' => 'YOUR_MERCHANT_ID',
    'skey' => md5('YOUR_txID'.'YOUR_MERCHANT_ID'.'YOUR_VERIFY_KEY'.'TRANSACTION_AMOUNT_OF_THE_txID')
]);

$response = $rms->directStatusRequery([
    'amount' => 'TRANSACTION_AMOUNT_OF_THE_txID',
    'txID' => 'YOUR_txID',
    'domain' => 'YOUR_MERCHANT_ID',
    'skey' => md5('YOUR_txID'.'YOUR_MERCHANT_ID'.'YOUR_VERIFY_KEY'.'TRANSACTION_AMOUNT_OF_THE_txID')
]);

$response = $rms->staticQr([
    'merchantID' => 'YOUR_MERCHANT_ID',
    'channel' => 'DuitNowSQR',
    'orderid' => 'YOUR_ORDER_ID',
    'currency' => 'MYR',
    'bill_name' => 'Item name',
    'bill_desc' => 'Item description',
    'checksum' => md5('YOUR_MERCHANT_ID'.'DuitNowSQR'.'YOUR_ORDER_ID'.'MYR'.'YOUR_VERIFY_KEY')
]);

$response = $rms->cardBin([
    'domain' => 'YOUR_MERCHANT_ID',
    'skey' => md5('YOUR_MERCHANT_ID'.'YOUR_SECRET_KEY','BIN'),
    'BIN' => '555566' //First 6-digit number of the PAN
]);

$response = $rms->voidPending([
    'tranID' => 'TRANSACTION_ID',
    'amount' => 'AMOUNT_OF_THE_TRANSACTION',
    'merchantID' => 'YOUR_MERCHANT_ID',
    'checksum' => md5('TRANSACTION_ID'.'AMOUNT_OF_THE_TRANSACTION'.'YOUR_MERCHANT_ID'.'YOUR_VERIFY_KEY')
]);

$response = $rms->refund([
    'RefundType' => 'P',
    'MerchantID' => 'YOUR_MERCHANT_ID',
    'RefID' => 'ORDER_ID',
    'TxnID' => 'TRANSACTION_ID',
    'Amount' => 'AMOUNT_TO_REFUND',
    'Signature' => md5('P'.'YOUR_MERCHANT_ID'.'REF_ID'.'TXN_ID'.'AMOUNT_TO_REFUND'.'YOUR_SECRET_KEY')
]);

$response = $rms->refundStatus([
    'TxnID' => 'TRANSACTION_ID',
    'MerchantID' => 'YOUR_MERCHANT_ID',
    'Signature' => md5('TRANSACTION_ID'.'YOUR_MERCHANT'.'YOUR_VERIFY_KEY')
]);
bash
composer