oxygenzsas/composer_lib_paypal
Composer 安装命令:
composer require oxygenzsas/composer_lib_paypal
包简介
Une librairie de gestion de paiement Paypal
README 文档
README
Une librairie paypal pour une integration rapide des paiements en utilisant les CardFields du SDK javascript v5 de paypal
Installation
Via composer
composer require oxygenzsas/composer_lib_paypal
Exemple d'utilisation
Controller PHP
<?php require __DIR__ . '/vendor/autoload.php'; /** Paypal config et création de classe anonyme pour l'heritage */ $client = new class( 'xxxxxxxxxxx' /* clientID */ ,'xxxxxxxxxxxxx' /* SecretID */ , 'https://api-m.sandbox.paypal.com' /* url API sandox vs prod */ , 'EUR' /* devise */ , 'https://sandbox.paypal.com/sdk/js' /* url sdk js */ ,'http://localhost:8080' /* url de la page unique de paiement */ , true /* active SSL */ ) extends \OxygenzSAS\Paypal\Paypal { protected function getAmountFromAttribute(string $attribute) :int { $data = json_decode($attribute, true); /** @todo recuperer ici le montant du paiement a partir des données de attributes */ return 1234; // return amount } protected function getAdressFromAttribute(string $attribute) :array { /** @todo recuperer ici l'adresse de facturation a partir des données de attributes */ return [ 'name' => 'Dupond Thomas', 'adress_line_1' => '15 rue des oliviers', 'adress_line_2' => 'Batiment 3', 'admin_area_2' => 'Vire', 'admin_area_1' => 'Calvados', 'postal_code' => '14500', 'country_code' => 'FR' ]; } }; /** Database config (PDO) */ \OxygenzSAS\Paypal\Database::setDsn('sqlite:'.__DIR__.'/database.db'); \OxygenzSAS\Paypal\Database::setUsername(null); \OxygenzSAS\Paypal\Database::setPassword(null); \OxygenzSAS\Paypal\Database::setOptions([]); /** init database if necessary */ $client->initDatabase(); /** doi etre appelé sur la page de paiement car il creer les routes sur cette meme page */ $client->initRoute();
Template HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Paypal test</title> <script src="/vendor/oxygenzsas/composer_lib_paypal/js/script.js"></script> <!-- @todo utiliser le script js depuis les sources composer --> </head> <body> <div id="paypal-card-form"> <div id="card-name"></div> <div id="card-number"></div> <div id="card-expiry"></div> <div id="card-cvv"></div> <button id="card-submit">Payer</button> </div> <script type="text/javascript"> new PaypalCustom( { paypal_sdk_url: "<?php echo $client->getUrlJsSdk(); ?>" ,client_id: "<?php echo $client->getClientID(); ?>" ,currency: "<?php echo $client->getCurrency(); ?>" ,attributes: {id_commande: 45623} /** donnée pour identifier le paiement dans la classe paypal */ ,url_paiement: "<?php echo $client->getUrlBack(); ?>" }); document.addEventListener('paypalOrderCreated', (event) => { console.log('Order created:', event.detail.order); }); document.addEventListener('paypalOrderCompleted', (event) => { console.log(`Thank you for your payment of ${event.detail.amount.value} ${event.detail.amount.currency_code}`); }); document.addEventListener('paypalOrderCancelled', (event) => { console.log('Order cancelled!'); }); document.addEventListener('paypalError', (event) => { console.error('PayPal Error:', event.detail.message); }); document.addEventListener('paypalButtonsInitialized', () => { console.log('PayPal buttons have been initialized and are ready for interaction.'); }); </script> </body> </html>
Faire un remboursement d'un paypal_capture_id
Le 4ieme paramètreest le text qui apparaitra sur les relevé bancaire des deux parties
<?php $client->refundCapture('xxxxxx', 5, 'EUR', 'remboursement test');
Faire une nouveau paiement a partir d'un paypal_vault_id
<?php if($client->createOrderFromToken('xxxxx', 100, 'EUR') === false){ throw new EXception('Echec de creation de la commande a partir du paypal_vault_id'); }
Ressources
Documentation API REST
https://developer.paypal.com/docs/api/payments/v2/
Documentation Standard Checkout
https://developer.paypal.com/docs/checkout/standard/customize/
Documentation SDK JS
https://developer.paypal.com/sdk/js/reference/
Dashboard Paypal
https://developer.paypal.com/dashboard/
Get client ID and client secret
Here's how to get your client ID and client secret:
- Select Log in to Dashboard and log in or sign up.
- Select Apps & Credentials.
- New accounts come with a Default Application in the REST API apps section. To create a new project, select Create App.
- Copy the client ID and client secret for your app.
oxygenzsas/composer_lib_paypal 适用场景与选型建议
oxygenzsas/composer_lib_paypal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「paypal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oxygenzsas/composer_lib_paypal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oxygenzsas/composer_lib_paypal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oxygenzsas/composer_lib_paypal 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PayPal SDK for ExpressCheckout and AdaptivePayments. Supports recurring payments, simple payments, parallel payments and chained payments.
A PayPal IPN (Instant Payment Notification) listener for PHP
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-11