payment4/cryptogateway

Payment4 Crypto Payment Gateway for Laravel

v1.0.2 2024-09-03 11:36 UTC

This package is auto-updated.

Last update: 2024-10-03 12:15:08 UTC


README

Payment4 revolutionizes the way businesses transact. Seamlessly accept a variety of digital currencies, ensuring swift, secure, and borderless transactions to empower your global enterprise.

  • Streamlined and Efficient
  • Promises/A+ Compatibility
  • Secure Sandboxing

Installation

You can install the package via composer:

composer require payment4/cryptogateway

Next, you should publish the configuration file using the vendor:publish Artisan command. The configuration file will be placed in your application's config directory.

 php artisan vendor:publish --provider="Payment4\CryptoGateway\Payment4ServiceProvider"

Requirements

  • php "^7.2|^8.0|^8.1|^8.2|^8.3"
  • laravel-framework "^7.0|^8.0|^9.0|^10.0|^11.0"
  • Register for Free or Login on the https://payment4.com
  • Create new gateway and get apiKey

Configuration

Add your APIKEY in Payment4 config.

'apiKey' => env('PAYMENT4_API_KEY', ''),

furthermore, you can add your APIKEY to .env file, please look at to following example:

PAYMENT4_API_KEY= __YOUR_API_KEY

If you use callbackUrl as static url you can set it here, otherwise, leave it blank.

'callbackUrl' => env('PAYMENT4_CALLBACK_URL', ''),

If you use webhookUrl as static url you can set it here, otherwise, leave it blank.

'webhookUrl' => env('PAYMENT4_WEBHOOK_URL', ''),

languages

'language' => 'EN',

Supported Languages :

  • FR
  • ES
  • AR
  • TR
  • FA
  • EN

Note : non-sensitive to uppercase or lowercase

currency

'currency' => 'USD',

Supported Currencies :

  • USD
  • EUR
  • TRY
  • GBP
  • AED
  • IRT

Note : non-sensitive to uppercase or lowercase

  • sandBox

to activation set True

'sandBox' => false,

Usage

Create Payment4 instance

Ex1:

/**
* apiKey and sandBox are optional if already set them to config file.
*/

$initParams = [
'apiKey' => '######',
'sandBox' => false,
];

$paymentInstance = Payment4($initParams);

Ex2:

$paymentInstance = Payment4();

Requesting a Payment

/**
 * amount is required
 * callbackParams, webhookParams, webhookUrl, language, currency are optional.
 * callbackUrl is optional if already set it to config file.
 * If no language is provided, the default language is set to 'en'.
 * If no currency is provided, the default currency is set to 'USD'.
 */
 
$amount = 10;
$options = [
  'callbackUrl' => "https://your-domain.com/callback",
  'callbackParams' => [
    'your key' => 'your value',
    'your key' => 'your value',
  ],
  'webhookUrl' => "https://your-domain.com/webhook",
  'webhookParams' => [
    'your key' => 'your value',
    'your key' => 'your value',
  ],
  'language' => 'EN',
  'currency' => 'USD',
];

$response = $paymentInstance->requestPayment($amount, $options);

if ($createPayment->status) {
    return responseSuccess(
        [
            'url' => $createPayment->data->paymentUrl,
        ]
    );
} else {
   return responseError(
        [
            'message' => $createPayment->message ?? '',
        ]
    );
}

Verifying a Payment

/**
 * amount and paymentUid are required
 */
 
$paymentUid = '';
$amount = 10;
$options = [
  'currency' => 'USD',
];

$response = $paymentInstance->verifyPayment($paymentUid, $amount, $options);

Powered by Payment4