swiftmade/omnipay-everypay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

swiftmade/omnipay-everypay

Composer 安装命令:

composer require swiftmade/omnipay-everypay

包简介

(Unofficial) payment gateway for Every Pay (Estonia)

README 文档

README

Latest Version on Packagist Software License Total Downloads

PHP EveryPay Client (for Omnipay)

Use this package to integrate EveryPay into your PHP application using Omnipay.

EveryPay is a payment gateway currently used by:

  • LHV
  • SEB
  • Swedbank

The package supports the following payment types:

  • One-off payments
  • Requesting card tokens
  • One-click / CIT (Customer Initiated Transactions) Payments
  • MIT (Merchant Initiated Transactions) Payments

Usage

Install the package using composer

composer require swiftmade/omnipay-everypay

Initialize the gateway

$gateway = Omnipay::create('EveryPay')->initialize([
  'username' => '', // EveryPay api username
  'secret' => '', // EveryPay api secret
  'accountName' => '', // merchant account ID
  'testMode' => true, // set to false for production!
  'locale' => 'en', // et=Estonian, see integration guide for more options.
]);

One-off Purchase

$purchase = $gateway
    ->purchase([
        'amount' => $amount,
        'paymentType' => PaymentType::ONE_OFF,
    ])
    ->setTransactionId($orderId) // unique order id for this purchase
    ->setReturnUrl($customerUrl) // the url to redirect if the payment fails or gets cancelled
    ->setClientIp($_SERVER['REMOTE_ADDR']) // optional, helps fraud detection
    ->setEmail(''); // optional, helps fraud detection

// Use this, if you want to make the payment using a previously stored card token
// Only applicable for MIT and CIT payment types.
$purchase->setCardReference($token);

// Uncomment if you want to store the card as a token after the payment
// (Only supported with One-off payment type)
$purchase->setSaveCard(true);

$response = $purchase->send();

// IMPORTANT: Store this payment data somewhere so that we can validate / process it later
$payment = $response->getData();

return $response->redirect(); // this will return a self-submitting html form to EveryPay Gateway API

Customer Initiated Transaction (One-click payment)

$purchase = $gateway
    ->purchase([
        'amount' => $amount,
        'paymentType' => PaymentType::CIT,
    ])
    ->setTransactionId($orderId) // unique order id for this purchase
    ->setCardReference('previously stored card token')
    ->setReturnUrl($customerUrl)
    ->setClientIp($_SERVER['REMOTE_ADDR']) // optional, helps fraud detection
    ->setEmail(''); // optional, helps fraud detection

$response = $purchase->send();

// Store the payment response data if you wish.
$payment = $response->getData();

if ($response->isSuccessful()) {
   // Payment done!
} else if($response->isRedirect()) {
   // 3DS Confirmation needed!
   // Redirect the user to 3DS Page.
   return $response->redirect();
} else {
  // Something went wrong!
  // Check $response->getMessage();
}

Complete Payment (handle Gateway redirect from EveryPay)

EveryPay will redirect the user to the returnUrl once the payment is finalized. You need to validate whether the payment went through.

// Here, pass the payment array that we previously stored when creating the payment
$response = $gateway->completePurchase()
    // These values are passed back to you by EveryPay
    ->setTransactionId($_GET['order_reference'])
    ->setTransactionReference($_GET['payment_reference'])
    ->send();

if (!$response->isSuccessful()) {
  // Payment failed!
  // Check $response->getMessage() for more details.
}

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

if ($card = $response->getCardToken()) {
  // You also got back a card token
  // Store this somewhere safe for future use!
}

Authorize & Capture Later

In EveryPay, when the payment will be captured is configured at the account level. If you want to authorize a payment without capturing it, then you need a Merchant Account configured accordingly.

To authorize a payment, simply substitue purchase and completePurchase methods with authorize and completeAuthorize. Then call capture to capture the funds.

// Here, pass the payment array that we previously stored when creating the payment
$gateway->authorize([
        'amount' => $amount,
        'paymentType' => PaymentType::CIT,
    ])
    ->setCardReference('previously stored card token')
    // Set all the other parameters. See previous examples ...
    ->send();

// Redirect the user to 3DS confirmation as necessary.

// When EveryPay redirects the user back, do this...
// This won't capture the payment yet, but makes sure the authorization is successful.
$authorizeResponse = $gateway->completeAuthorize()
    ->setTransactionId($_GET['order_reference'])
    ->setTransactionReference($_GET['payment_reference'])
    ->send();

// Hold on to this.. You'll use this reference to capture the payment.
$paymentReference = $authorizeResponse->getTransactionReference();

// When you're ready to capture, call:
$response = $gateway->capture([
  'amount' => $amount, // You can capture partially, or the whole amount.
  'transactionReference' => $paymentReference,
])->send();

if ($response->isSuccessful()) {
   // Payment captured!
} else {
  // Something went wrong!
  // Check $response->getMessage();
}

Security

If you discover any security related issues, please email hello@swiftmade.co instead of using the issue tracker.

Disclaimer

This package is not an official package by EveryPay AS nor by Omnipay.

License

The MIT License (MIT). Please see License File for more information.

swiftmade/omnipay-everypay 适用场景与选型建议

swiftmade/omnipay-everypay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.53k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2019 年 10 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 swiftmade/omnipay-everypay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 swiftmade/omnipay-everypay 我们能提供哪些服务?
定制开发 / 二次开发

基于 swiftmade/omnipay-everypay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

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