PHP code example of payrightmy / payment-php

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

    

payrightmy / payment-php example snippets


 

use Payright\Client;
use GuzzleHttp\Client as HttpClient;

$payright = Client::make(new HttpClient(),[
    'api_key' => 'secret',
    'sandbox' => true
]);

$response = $payright->collections('v1')
 ->create([
  'name' => 'Collection name',
  'status' => 'active'
 ]);

echo $response->getStatusCode();
echo $response->getBody();


 

use Payright\Client;
use GuzzleHttp\Client as HttpClient;

$payright = Client::make(new HttpClient(),[
    'api_key' => 'secret',
    'sandbox' => true
]);

$response = $payright->bills('v1')
->create([
    'collection' => '2Rjzopem',
    'biller_name' => 'Muhammad Imran',
    'biller_email' => '[email protected]',
    'biller_mobile' => '60121234567',
    'description' => 'Example bill description',
    'amount' => 100,
    'callback_url' => 'https://webhook.site/4370e625-4197-4059-911c-f4e16d6489f6',
    'redirect_url' => 'https://example.com/redirect/',
    'due_at' => '2021-12-01'
]);

echo $response->getStatusCode();
echo $response->getBody();


 

use Payright\Client;
use GuzzleHttp\Client as HttpClient;

$payright = Client::make(new HttpClient(),[
    'api_key' => 'secret',
    'sandbox' => true
]);

$response = $payright->bills('v1')
->get('7BeQgzGP');

echo $response->getStatusCode();
echo $response->getBody();

bash
composer