arbory/omnipay-everypay

Every Pay omnipay 包

1.1.0 2021-02-10 22:02 UTC

This package is auto-updated.

Last update: 2024-09-12 14:52:30 UTC


README

Build Status Coverage Status

使用方法

使用 composer 安装该包

composer require arbory/omnipay-everypay

初始化网关

$gateway = Omnipay::create('EveryPay')->initialize([
  'username' => '', // EveryPay api username
  'secret' => '', // EveryPay api secret
  'accountName' => '', // merchant account name
  'gatewayUrl' => 'https://igw-demo.every-pay.com/api/v3', // use merchant provided url for production
]);

处理授权(网关)

$authorize = $gateway
    ->authorize([
      'amount' => '1.28',
      'transactionId' => uniqid(),
      'email' => 'user@example.com',
      'customerIp' => '1.2.3.4',
      'callbackUrl' => 'https://shop.example.com/cart',
      'customerUrl' => 'https://shop.example.com/cart'
    ]);

$response = $authorize->send();

// Gateway transaction reference
$response->getTransactionReference();

return $response->redirect(); // this will call redirect to payment portal

完成支付(处理 EveryPay 重定向)

支付完成后,EveryPay 将通过 GET 请求返回到您的回调 URL。您需要验证此响应并检查支付是否成功。

// Here, pass the payment array that we previously stored when creating the payment
$response = $gateway->completeAuthorize(['transactionReference' => 'foo')->send();

if ($response->isSuccessful()) {
  // Payment succeeded!
}

// Payment succeeded!
// Here's your payment reference number: $response->getTransactionReference()