项目作者: nekofar

项目描述 :
ZarinPal driver for the Omnipay PHP payment processing library
高级语言: PHP
项目地址: git://github.com/nekofar/omnipay-zarinpal.git
创建时间: 2019-08-31T00:04:38Z
项目社区:https://github.com/nekofar/omnipay-zarinpal

开源协议:MIT License

下载


Omnipay: ZarinPal

ZarinPal driver for the Omnipay PHP payment processing library

Packagist Version
PHP from Packagist
Packagist Downloads
Tests Status
Coverage Status
License
Twitter: nekofar

Omnipay is a framework agnostic, multi-gateway payment
processing library for PHP. This package implements ZarinPal support for Omnipay.

Installation

Omnipay is installed via Composer. To install, simply require
league/omnipay and nekofar/omnipay-zarinpal with Composer:

  1. composer require league/omnipay nekofar/omnipay-zarinpal

Basic Usage

The following gateways are provided by this package:

  • ZarinPal

For general usage instructions, please see the main Omnipay
repository.

Example

Purchase

The result will be a redirect to the gateway or bank.

  1. use Omnipay\Omnipay;
  2. $gateway = Omnipay::create('ZarinPal');
  3. $gateway->setMerchantId('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
  4. $gateway->setReturnUrl('https://www.example.com/return');
  5. // Send purchase request
  6. $response = $gateway->purchase([
  7. 'amount' => 100,
  8. 'description' => 'Some description'
  9. ])->send();
  10. // Process response
  11. if ($response->isRedirect()) {
  12. // Redirect to offsite payment gateway
  13. $response->redirect();
  14. } else {
  15. // Payment failed: display message to customer
  16. echo $response->getMessage();
  17. }

On return, the usual completePurchase will provide the result of the transaction attempt.

The final result includes the following methods to inspect additional details:

  1. // Send purchase complete request
  2. $response = $gateway->completePurchase([
  3. 'amount' => 100,
  4. 'authority' => $_REQUEST['Authority'],
  5. )->send();
  6. // Process response
  7. if ($response->isSuccessful()) {
  8. // Payment was successful
  9. print_r($response);
  10. } else {
  11. // Payment failed: display message to customer
  12. echo $response->getMessage();
  13. }

Testing

  1. composer test

Support

If you are having general issues with Omnipay, we suggest posting on
Stack Overflow. Be sure to add the
omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project,
or ask more detailed questions, there is also a mailing list which
you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker,
or better yet, fork the library and submit a pull request.