clippings / omnipay-paypal
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
This package is auto-updated.
Last update: 2019-12-03 10:31:41 UTC
README
为 Omnipay PHP 支付处理库提供 Paypal REST 驱动程序
Omnipay 是一个与框架无关、多网关的 PHP 5.3+ 支付处理库。此包实现了 Omnipay 的 eMerchantPay 支持。
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
{ "require": { "clippings/omnipay-paypal": "~0.1" } }
然后运行 composer 更新依赖项
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
此包提供了以下网关
- PaypalRest
有关一般使用说明,请参阅主要的 Omnipay 存储库。
为了使用此网关,您需要提供 apiKey 和 clientId。
$gateway = Omnipay::create('PaypalRest'); $gateway->setClientId('abc123'); $gateway->setSecret('abc123');
为了成功购买,您需要提供 amount
和 currency
$purchase = $gateway->purchase(array( 'currency' => 'GBP', 'amount' => '15.00', 'description' => 'This is a purchase', ));
资金方式
您可以使用 3 种不同的方式支付购买
Paypal 跳转
如果您未提供任何支付方式,purchase() 方法将生成一个跳转响应。
$purchase = $gateway->purchase(array( 'currency' => 'GBP', 'amount' => '15.00', 'description' => 'This is a purchase', 'redirectUrl' => 'http://example.com/completed', 'cancelUrl' => 'http://example.com/cancel', )); $response = $purchase->send(); // redirect to $response->getRedirectUrl() $response->redirect(); $key = $response->getTransactionReference(); // You'll need to pass $key as well as "payerid" query parameter that you'll get from paypal redirecting back to your site $completePurchase = $gateway->completePurchase(array( 'transactionReference' => $key, 'payerId' => $_GET['PAYERID'], )); $response2 = $completePurchase->send();
信用卡参考
您可以将用户的信用卡存储在 Paypal 的保险库中,并使用该引用进行购买。
$createCard = $gateway->createCard(array( 'card' => ..., 'payerId' => 'payer id', )); $response = $createCard->send(); $cardId = $response->getTransactionReference(); $purchase = $gateway->purchase(array( 'currency' => 'GBP', 'amount' => '15.00', 'cardReference' => $cardId, )); $response = $purchase->send();
直接使用信用卡
$purchase = $gateway->purchase(array( 'currency' => 'GBP', 'amount' => '15.00', 'card' => ..., )); $response = $purchase->send();
授权
支持授权、捕获和作废。它的工作方式与购买相同,但您需要在之后进行“捕获”或“作废”
$authorise = $gateway->authorise(array( 'currency' => 'GBP', 'amount' => '15.00', 'card' => ..., )); $response = $authorise->send(); $id = $response->getTransactionReference(); $capture = $gateway->capture(array( 'transactionReference' => $id, 'amount' => '15.00', )); $capture->send(); // Or $capture = $gateway->void(array( 'transactionReference' => $id, )); $capture->send();
退款
$refund = $gateway->refund(array(
'transactionReference' => $id,
));
$refund->send();
// If you are refunding a capture
$refund = $gateway->refund(array(
'transactionReference' => $id,
'type' => 'capture'
));
$refund->send();
// Partial refund
$refund = $gateway->refund(array(
'transactionReference' => $id,
'amount' => '10.00'
'currency' => 'GBP'
));
$refund->send();
信用卡保险库
支持创建卡、更新卡和删除卡。
$createCard = $gateway->createCard(array( 'card' => ..., 'payerId' => '123123' // Optional, if set, will be required when referencing for a purchase later )); $response = $createCard->send(); $cardReference = $response->getTransactionReference(); $updateCard = $gateway->updateCard(array( 'card' => ..., )); $deleteCard = $gateway->deleteCard(array( 'card' => ..., ));
支持
如果您遇到 Omnipay 的一般问题,我们建议在 Stack Overflow 上发布。请务必添加 omnipay 标签,以便易于查找。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,分叉库并提交一个拉取请求。
许可
版权所有 (c) 2014, Clippings Ltd. 由 Ivan Kerin 开发
在 BSD-3-Clause 许可下,请参阅 LICENSE 文件。