thecodingcompany / laravel-paypal-light
Laravel PayPal Light 库用于 Google App Engine。此库不需要 Curl。
v1.0.3
2016-11-06 14:13 UTC
Requires
- php: >=5.5.0
This package is not auto-updated.
Last update: 2024-09-14 19:47:50 UTC
README
Laravel PayPal Light 库用于 Google App Engine
使用 Composer 安装
composer require thecodingcompany/laravel-paypal-light
示例
创建支付示例
require_once __DIR__.'/src/PayPalLight/HttpRequest.php';
require_once __DIR__.'/src/PayPalLight/PayPalLight.php';
require_once __DIR__.'/src/PayPalLight/PayPalPayment.php';
require_once __DIR__.'/src/PayPalLight/CreditCardPayment.php';
require_once __DIR__.'/src/PayPalLight/PayPalTransaction.php';
use CodingCompany\PayPal\PayPalPayment as PayPalPayment;
use CodingCompany\PayPal\PayPalTransaction as PayPalTransaction;
$p = new PayPalPayment(array(
'client_id' => 'AddMFxCjj3QgJZT4kYgrgegbfdbgthre9Qj24o_P8Ldag7yeu2A',
'client_secret' => 'EFNXQgBjL9PQO0ZeuC5_4567547y6htet5ert34435_tct4nFU7g'
));
$p->set_endpoint("https://api.paypal.com");
$transaction = new PayPalTransaction();
$transaction->amount = array(
"total" => "1.00",
"currency" => "USD"
);
$transaction->description = "PayPal transaction";
$p->set_transaction($transaction);
$p->set_return_url("https://:8000/paypal/callback");
$p->set_cancel_url("https://:8000/paypal/cancel");
$response = $p->authorize_payment();
用户将被路由到 PayPal 进行支付授权。之后,用户将被重定向到提供的 'RETURN' URL。
授权支付示例
require_once __DIR__.'/src/PayPalLight/HttpRequest.php';
require_once __DIR__.'/src/PayPalLight/PayPalLight.php';
require_once __DIR__.'/src/PayPalLight/PayPalPayment.php';
require_once __DIR__.'/src/PayPalLight/CreditCardPayment.php';
require_once __DIR__.'/src/PayPalLight/PayPalTransaction.php';
use CodingCompany\PayPal\PayPalPayment as PayPalPayment;
use CodingCompany\PayPal\PayPalTransaction as PayPalTransaction;
$p = new PayPalPayment(array(
'client_id' => 'AddMFxCjj3QgJZT4kYgrgegbfdbgthre9Qj24o_P8Ldag7yeu2A',
'client_secret' => 'EFNXQgBjL9PQO0ZeuC5_4567547y6htet5ert34435_tct4nFU7g'
));
$p->set_endpoint("https://api.paypal.com");
$response = $p->execute_payment(array(
"paymentId" => "PAY-554",
"token" => "EC-45645",
"PayerID" => "455454"
));
$response 的样子如下
Array ( [id] => PAY-554 [intent] => sale [state] => approved [cart] => 10E457GK130324L [payer] => Array ( [payment_method] => paypal etc etc etc ) )