digitickets/omnipay-payyo

Omnipay支付处理库的Payyo网关

3.0.1.1 2022-09-15 08:13 UTC

README

Payyo网关用于Omnipay PHP支付处理库。

Omnipay 是一个不依赖于框架的多网关支付处理库,适用于PHP 5.3+。

Payyo Omnipay库需要PHP 7.0+。

安装

可以使用 Composer 安装Omnipay。请参阅安装说明

运行以下命令安装omnipay和Payyo网关

composer require digitickets/omnipay-payyo

基本使用

以下参数是必需的

  • apiKey 您的Payyo API/公钥
  • secretKey 您的Payyo密钥
  • merchantId 您的Payyo商户ID
$gateway = Omnipay::create('Payyo');
$gateway->setApiKey('api_...');
$gateway->setSecretKey('sec_...');
$gateway->setMerchantId('1234');
$gateway->setTestMode(true);

// Send purchase request
$response = $gateway->purchase([
    'transactionId' => '123456',
    'description' => '1x Book',
    'amount' => '10.00',
    'currency' => 'USD',
    'paymentMethods' => ['credit_card'],    
    'returnUrl' => 'https://example.org/success',
    'cancelUrl' => 'https://example.org/abort',
])->send();

// This is a redirect gateway, so redirect right away
$response->redirect();

请求

购买

  • purchase() 调用 paymentPage.initialize,然后您应该进行重定向
  • completePurchase() 调用 transaction.getNextAction 和(如果需要) transaction.capture

授权 + 捕获

  • authorize() 调用 paymentPage.initialize,然后您应该进行重定向
  • completeAuthorize() 调用 transaction.getDetails
  • capture() 调用 transaction.getNextAction 和(如果需要) transaction.capture

取消/退款

  • void() 调用 transaction.void
  • refund() 调用 transaction.refund

测试

您可以通过运行 docker-compose up 并转到 https://127.0.0.1:8086/ 来在沙盒中执行测试支付。