ewertondaniel / standard-paypal-php-sdk
PayPal Standard PHP SDK
dev-master
2022-12-07 22:20 UTC
Requires
- php: >=8.1
- echosistema/simple-http-request: >=1.0
- guzzlehttp/guzzle: >=7.0
- ramsey/uuid: >=4.6
Requires (Dev)
- phpunit/phpunit: >=7.5
This package is auto-updated.
Last update: 2024-09-08 18:41:13 UTC
README
PayPal Standard PHP SDK
此库为开发者提供了一组简单的绑定,帮助您将 PayPal Standard 集成到网站中,并开始接收支付。
🛠 要求
php >= 8.1
guzzlehttp/guzzle >= 7.0.1
echosistema/simple-http-request" >= 1.0.1
📢 即将推出适用于 PHP versions < 8.1
的包。
💻 安装
是第一次使用 PayPal 吗?如果您还没有,请在 PayPal 中创建您的 PayPal 账户。
如果尚未安装,请下载 Composer
在您的项目目录中,在命令行上运行 "composer require ewertondaniel/paypal-standard-php-sdk"
用于 PHP 8.1
;
这就完成了!PayPal Standard PHP SDK 已成功安装!
🧑💻 示例
🔓 获取授权
use EwertonDaniel\PayPal\Auth; $authentication = new Auth($client_id, $client_secret, $is_production); $authentication->getScopes(); $authentication->getAccessToken(); $authentication->getTokenType(); $authentication->getAppId(); $authentication->getExpiresIn(); $authentication->getNonce();
💲 创建订单
use EwertonDaniel\PayPal\Order; $order = new Order($authentication); //Set Purchase Unit $order->setPaypalRequestId() ->setIntent('CAPTURE') ->purchaseUnit() ->setCurrencyCode('BRL') ->addItemWithBasicData('Blacksaber Mandalore', 1, 29900) // string $name, int $quantity, int $value ->setReferenceId() ->setDescription('I can write up to one hundred and twenty seven characters as a description...'); // Set Payment Source $order->pushPurchaseUnit() ->paymentSource() ->paypal() ->experienceContext() ->setPaymentMethodPreference('IMMEDIATE_PAYMENT_REQUIRED') ->setBrandName('Bounty Hunters Guild (BHG)') // Company name ->setLocale('pt-BR') ->setLandingPage('LOGIN') ->setShippingPreference('NO_SHIPPING') ->setUserAction('PAY_NOW') ->setReturnUrl('https://example.com/returnUrl') ->setNotificationUrl('https://example.com/notifyUrl') ->setCancelUrl('https://example.com/cancelUrl'); $response = $order->create();
ℹ 订单详情
use EwertonDaniel\PayPal\Order; $order_id = $_POST['token']; $detail = $order->setOrderId($order_id)->detail();