amsify42 / paypal-masspayment
这是一个用于简单执行 PayPal 大额支付的 Laravel 5 扩展包。
1.0
2018-11-07 11:59 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-20 02:22:25 UTC
README
Laravel 5 PayPal 大额支付
这是一个仅用于 PayPal 大额支付的 Laravel 5 扩展包。
安装
composer require amsify42/paypal-masspayment
[或者]
将 PaypalMassPayment 扩展包添加到您的 composer.json
文件中
{ "require": { "amsify42/paypal-masspayment": "dev-master" } }
服务提供者
在您的应用程序配置中,将 PaypalMassPaymentServiceProvider
添加到 providers 数组中。
'providers' => [ 'Amsify42\PaypalMassPayment\PaypalMassPaymentServiceProvider', ];
门面(可选)
如果您想使用门面,请将其添加到应用程序配置中的 aliases 数组中。
'aliases' => [ 'PaypalMassPayment' => 'Amsify42\PaypalMassPayment\PaypalMassPaymentFacade', ];
发布文件
$ php artisan vendor:publish
现在将以 paypalmasspayment.php 命名的文件复制到 Config/ 目录中,您可以在其中添加设置。
有关在此配置文件中可用的所有选项的用法,请参阅 使用大额支付 API
在需要使用 PaypalMassPayment 的任何类顶部添加此行
use PaypalMassPayment;
支付数组看起来像这样
有关在支付数组中使用的参数,请参阅 使用 NVP 的 MassPay API 使用 SOAP 的 MassPay API
$receivers = array( 0 => array( 'ReceiverEmail' => "something@somewhere.com", 'Amount' => "0.01", 'UniqueId' => "id_001", 'Note' => " Test Streammer 1"), 1 => array( 'ReceiverEmail' => "something@somewhere.com", 'Amount' => "0.01", 'UniqueId' => "id_002", 'Note' => " Test Streammer 2"), ); $response = PaypalMassPayment::executeMassPay('Some Subject', $receivers);
或者您可以直接调用 PaypalMassPayment 而无需将其添加到顶部
$response = \PaypalMassPayment::executeMassPay('Some Subject', $receivers);
有关响应代码和错误,请参阅 MassPay 错误代码
在运行时为特定对象上下文传递自定义配置
$config = [ 'authentication' => 'api_signature', 'environment' => 'sandbox', 'operation_type' => 'nvp', 'api_vesion' => '51.0', 'receiver_type' => 'email', 'currency' => 'USD', 'sandbox' => [ 'api_username' => 'random-facilitator_api1.gmail.com', 'api_password' => 'FKJHS786JH3454', 'api_certificate' => '', 'api_signature' => 'sdfrfsf3rds3435432545df3124dg34tDFG#$sG23rfSD3', ], 'live' => [ 'api_username' => '', 'api_password' => '', 'api_certificate' => '', 'api_signature' => '', ], ]; $payment = PaypalMassPayment::setConfig($config); $response = $payment->executeMassPay('Some Subject', $receivers);
您也可以仅传递自定义配置中所需的关键字
$config = [ 'environment' => 'live', 'live' => [ 'api_username' => '', 'api_password' => '', 'api_certificate' => '', 'api_signature' => '', ], ]; $payment = PaypalMassPayment::setConfig($config); $response = $payment->executeMassPay('Some Subject', $receivers);