molpay php_OmniPay:一个框架混合了多网关支付处理的库

Omnipay

An easy to use, consistent payment processing library for PHP

68747470733a2f2f7472617669732d63692e6f72672f7468657068706c65616775652f6f6d6e697061792d636f6d6d6f6e2e7376673f6272616e63683d6d617374657268747470733a2f2f706f7365722e707567782e6f72672f6f6d6e697061792f636f6d6d6f6e2f76657273696f6e68747470733a2f2f706f7365722e707567782e6f72672f6f6d6e697061792f636f6d6d6f6e2f642f746f74616c

Omnipay is a payment processing library for PHP. It has been designed based on ideas from Active Merchant, plus experience implementing dozens of gateways for [CI Merchant]. It has a clear and consistent API, is fully unit tested, and even comes with an example application to get you started.

Why use Omnipay instead of a gateway's official PHP package/example code?

Because you can learn one API and use it in multiple projects using different payment gateways

Because if you need to change payment gateways you won't need to rewrite your code

Because most official PHP payment gateway libraries are a mess

Because most payment gateways have exceptionally poor documentation

Because you are writing a shopping cart and need to support multiple gateways

TL;DR

Just want to see some code?

use Omnipay\Omnipay;

$gateway = Omnipay::create('Stripe');

$gateway->setApiKey('abc123');

$formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '123');

$response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send();

if ($response->isRedirect()) {

// redirect to offsite payment gateway

$response->redirect();

} elseif ($response->isSuccessful()) {

// payment was successful: update database

print_r($response);

} else {

// payment failed: display message to customer

echo $response->getMessage();

}

As you can see, Omnipay has a consistent, well thought out API. We try to abstract as much as possible the differences between the various payments gateways.

Package Layout

Omnipay is a collection of packages which all depend on the omnipay/common package to provide a consistent interface. There are no dependencies on official payment gateway PHP packages - we prefer to work with the HTTP API directly. Under the hood, we use the popular and powerful PHP-HTTP library to make HTTP requests. A Guzzle adapter is required by default, when using league/omnipay.

New gateways can be created by cloning the layout of an existing package. When choosing a name for your package, please don't use the omnipay vendor prefix, as this implies that it is officially supported. You should use your own username as the vendor prefix, and prepend omnipay- to the package name to make it clear that your package works with Omnipay. For example, if your GitHub username was santa, and you were implementing the giftpay payment library, a good name for your composer package would be santa/omnipay-giftpay.

Installation

Omnipay is installed via Composer. For most uses, you will need to require league/omnipay and an individual gateway:

composer require league/omnipay:^3 omnipay/paypal

If you want to use your own HTTP Client instead of Guzzle (which is the default for league/omnipay), you can require league/common and any php-http/client-implementation (see PHP Http)

composer require league/common:^3 omnipay/paypal php-http/buzz-adapter

Upgrade from v2 to v3

If your gateway is supported for v3, you can require that version. Make sure you require league/omnipay or a separate Http Adapter.

If there is no version for v3 yet, please raise an issue or upgrade the gateways yourself and create a PR. See the Upgrade guide for omnipay/common

Note: The package name has been changed from omnipay/omnipay to league/omnipay for v3

Payment Gateways

All payment gateways must implement GatewayInterface, and will usually extend AbstractGateway for basic functionality.

The following gateways are available:

Gateway

2.x

3.x

Composer Package

Maintainer

dilab/omnipay-2c2p

-

omnipay/2checkout

-

academe/omnipay-adyen

-

agmscode/omnipay-agms

lokielse/omnipay-global-alipay

lokielse/omnipay-alipay

-

x-class/omnipay-99bill

-

delatbabel/omnipay-alliedwallet

-

academe/omnipay-authorizenetapi

-

cimpleo/omnipay-authorizenetrecurring

ampeco/omnipay-bankart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值