承接 pwparsons/paygate 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pwparsons/paygate

最新稳定版本:2.2.0

Composer 安装命令:

composer require pwparsons/paygate

包简介

A Laravel package to integrate PayGate's PayWeb3 API.

README 文档

README

This repository will not be updated. The repository will be kept available in read-only mode.

d9fb0480-add4-11ea-91ec-99a6638a9496



Latest Version Tests Psalm Code Style Total Downloads Software License

This package provides an easy way to integrate PayGate's PayWeb3 API with Laravel.

The official documentation can be found here.

Compatibility Chart

Package Version Laravel PHP
2.0.0 7.15+ 7.4+
1.3.2 5.6 – 6.x 7.1+

Installation

You can install this package via composer using:

composer require pwparsons/paygate

The package will automatically register itself.

To publish the config file to config/paygate.php run:

php artisan vendor:publish --tag=paygate.config

Usage

After you've installed the package and filled in the values in the config file working with this package will be a breeze. All the following examples use the facade.

Creating a transaction

// Initiate transaction
$http = PayGate::initiate()
               ->withReference('pgtest_123456789')
               ->withAmount(32.99)
               ->withEmail('email@example.com')
               ->withCurrency('USD') // Optional: defaults to ZAR
               ->withCountry('USA') // Optional: defaults to ZAF
               ->withLocale('en-us') // Optional: defaults to 'en'
               ->withReturnUrl('https://website.com/return_url')
               ->withNotifyUrl('https://website.com/notify_url') // Optional
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

// Redirect to PayGate's payment page
return PayGate::redirect();

An example of the initiate response can be found in the documentation.

Querying a transaction

$http = PayGate::query()
               ->withPayRequestId('YOUR_PAY_REQUEST_ID_HERE')
               ->withReference('pgtest_123456789')
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

dd($http->all());

An example of the query response can be found in the documentation.

Tip

Paygate will post to the RETURN_URL and NOTIFY_URL. Exclude these URI's from CSRF verification by adding them to the VerifyCsrfToken middleware. E.g.

class VerifyCsrfToken extends Middleware
{
    protected $except = [
        'return_url',
        'notify_url',
    ];
}

Helpful Methods

The with magic method allows you to set a string after the word 'with' provided within the object it is being called on. This works in exactly the same way as the magic getter except it sets field values and returns the object so that you can chain setters, for example:

$object->withReference('pgtest_123456789')
       ->withAmount(32.99)
       ->withEmail('email@example.com')
       ->withReturnUrl('https://my.return.url/page');

Will result in the following:

{
    "REFERENCE": "pgtest_123456789",
    "AMOUNT": "3299",
    "EMAIL": "email@example.com",
    "RETURN_URL": "https://my.return.url/page"
}

The get magic method allows you to call any string after the word 'get' and it will return that value, for example:

{
    "PAYGATE_ID": "10011072130",
    "PAY_REQUEST_ID": "23B785AE-C96C-32AF-4879-D2C9363DB6E8",
    "REFERENCE": "pgtest_123456789"
}

Getting data from the object:

echo $object->getPaygateId();       // 10011072130
echo $object->getPayRequestId();    // 23B785AE-C96C-32AF-4879-D2C9363DB6E8
echo $object->getReference();       // pgtest_123456789

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email peterw.parsons@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the license file for more information.

统计信息

  • 总下载量: 601
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-10