tps / paypal-bundle
此包的最新版本(dev-master)没有可用的许可证信息。
Symfony2 的 wrapper-bundle,用于 rest-api-sdk-php 和 paypal 的经典 API
dev-master
2014-10-29 09:58 UTC
Requires
- php: >=5.3.2
- paypal/adaptivepayments-sdk-php: dev-issue-23 as dev-master
- paypal/merchant-sdk-php: v3.6.106
- paypal/rest-api-sdk-php: v0.7.1
- symfony/framework-bundle: >=2.0.16
Requires (Dev)
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2024-09-29 03:36:31 UTC
README
tpsPaypalBundle
本插件旨在同时为 RESTful-API 和经典 API 提供包装。目前正在开发中^^ 目前已完成的
安装
将以下行添加到您的 composer.json 中
require: "tps/paypal-bundle": "dev-master"
然后运行 composer install
配置
tps_paypal: client: HjaksuIHAsuhhamisecretKLJSisduijhdfJKHsdhiohdjklsjd90sdfjsdj secret: KLJsd9f0jfiammuchmoresecretindeedKJLSKdjs890dfjij2309sdujifj mode: live http: ConnectionTimeOut: 30 Retry: 1 log: LogEnabled: true FileName: PayPal.log LogLevel: FINE classic_api: acct1: Username: yourPayPaylClassicApiUser Password: yourPayPaylClassicApiPass Signature: yourPayPaylClassicApiSignature mode: live
使用
检查
public function checkoutAction() { $returnUrl = 'http://myapp/success'; $cancelUrl = 'http://myapp/cancel/order123'; $payment = $this->get('tps_paypal.paypal_service')->setupPayment(); $orderItems = array( new TransactionItem('Something sold', 18.99, 'USD', 1) ); $payment->addTransaction($orderItems, 'USD', 'Order no. 123'); $payment->setUrls($returnUrl, $cancelUrl); $payment->createPaypalPayment(); save_checkout_id($payment->getCheckoutId()); redirect($payment->getApprovalUrl()); }
这将创建一个付款。在将用户重定向之前保存付款 ID,您稍后会需要此 ID 以执行实际付款。注意:您也可以通过调用服务来创建 "tps\PaypalBundle\Entity\Payment" 的实例,但如果是这样,您将不得不自己处理 API 上下文。
事务执行
public function returnAfterCheckoutUrlAction() { $checkoutId = load_checkoutId(); //to be implemented elsewhere $paypalService = $this->get('tps_paypal.paypal_service'); $paypalService->executeTransaction($checkoutId, $payerId); }
列出付款
public function paypalOverviewAction() { $transactions = $this->paypalService->listTransactions(); return $this->render('Acme:PaypalAdmin:overview.html.twig', array('payments' => $transactions->getPayments()) ); }
下一步
- 美化部分