razmiksaghoyan / omnipay-yandexmoney
Omnipay支付处理库的Yandex Money网关
dev-master
2018-12-28 14:10 UTC
Requires
This package is auto-updated.
Last update: 2024-09-19 01:53:33 UTC
README
Omnipay Laravel支付处理库的Yandex Money驱动程序
Omnipay是一个与框架无关的多网关支付处理库,适用于PHP 5.5+。本包实现了Omnipay对Yandex Money的支持。
安装
Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json
文件中
{ "require": { "razmiksaghoyan/omnipay-yandexmoney": "dev-master" } }
然后运行composer以更新您的依赖项
composer update
或者您可以直接运行
composer require razmiksaghoyan/omnipay-yandexmoney
基本用法
- 使用Omnipay网关类
use Omnipay\Omnipay;
- 初始化Yandex Money网关并创建购买
$gateway = Omnipay::create('YandexMoney'); // Getway name $gateway->setShopId(env('SHOP_ID')); // Should be your Yandex Shop Id $gateway->setSecretKey(env('SECRET_KEY')); // Should be your Yandex Secrect Key $gateway->setReturnUrl(env('RETURN_URL')); // The URL to which you will be redirected after completing the purchase $gateway->setAmount(10); // Amount to charge $gateway->setCurrency('RUB'); // Currency $purchaseData->setDescription('Your Description'); // Payment Description $purchaseData->setConfirmationType('redirect'); // Redirect Only $purchaseData->setSavePaymentMethod(true/false); // Saving Payment Method $purchaseData->setCapture(true/false); // Automatic acceptance of received payment $purchaseData->setClientIp('Your Ip'); // Client Ip Address $purchase = $gateway->purchase()->send(); if ($purchase->isRedirect()) { // resturn RedirectUrl and OrderId, or write Your logic return [ 'redirectUrl' => $response->getRedirectUrl(), // Redirection to previously generated unique URL 'orderId' => $response->getOrderId() // Payment Id ]; } else { throw new Exception($purchase->getMessage()); }
- 完成支付
您将被重定向到YandexMoney表单页面。填写并提交信用卡(Yandex Money)数据后,YandexMoney页面将通过webhookhttp://example.com/xxx(也参考第2点)
$gateway = Omnipay::create('YandexMoney'); // Getway name $gateway->setShopId(env('SHOP_ID')); // Should be your Yandex Shop Id $gateway->setSecretKey(env('SECRET_KEY')); // Should be your Yandex Secrect Key$$webService = $gateway->completePurchase([ $response = $gateway->completePurchase( $paymentId, // Payment Id $amount // Amount to charge ); if ($response->isSuccessful()) { // resturn order Id, description and payment data, or write Your logic return [ 'orderId' => $response->getOrderId(), 'description' => $response->getDescription(), 'paymentdata' => $response->getPaymentMethodData() ]; }
出于测试目的,您应仅使用AMD货币,并且收费不超过10 AMD
有关一般使用说明,请参阅Omnipay的主要仓库。
支持
如果您遇到Omnipay的一般问题,我们建议在Stack Overflow上发布。请确保添加omnipay标签,以便更容易找到。
如果您想及时了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的邮件列表。
如果您认为您已经发现了一个错误,请使用GitHub问题跟踪器报告,或者更好的办法是,分支库并提交一个pull请求。