PHP code example of webpayby / webpayby-payment-json-sdk

1. Go to this page and download the library: Download webpayby/webpayby-payment-json-sdk 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/ */

    

webpayby / webpayby-payment-json-sdk example snippets


        $merchantId = 'YOUR_MERCHANT_ID';
        $secretKey = 'YOUR_SECRET_KEY';
        
        $payment = new Payment($merchantId);
        
        $payment
            ->setTest(1)
            ->setCurrencyId(Currency::BYN)
            ->setLanguageId(Language::EN)
            ->setOrderNum(uniqid(time()))
            ->setInvoiceItem('Item1', 4.5)
            ->setInvoiceItem('Item2', 2, 2)
            ->setTotal(8.5)
            ->setReturnUrl('http://example.com/success')
            ->setCancelReturnUrl('http://example.com/cancel')
            ->setNotifyUrl('http://example.com/notify');
        
        
        $gate = new Gateway($secretKey, RequestPoint::SANDBOX_PAYMENT);
        $response = $gate->sendRequest($payment);

        $redirectUrl = $response['redirectUrl'] ?? '';