uc / payment-bundle
Symfony 3 扩展包,将 Stripe 和 PayPal SDK 集成到 Symfony 项目中
dev-master / 1.1.x-dev
2017-09-14 09:16 UTC
Requires
- stripe/stripe-php: ~3.23
- symfony/symfony: ~3.0
This package is not auto-updated.
Last update: 2024-09-29 04:03:27 UTC
README
安装
要安装此扩展包,运行以下命令,您将从 [Packagist][3] 获取最新版本。
composer require stripe/stripe-php ~3.23
composer require uc/payment-bundle dev-master
在 AppKernel.php 中加载所需扩展包
// app/AppKernel.php public function registerBundles() { $bundles = array( // [...] new Uc\PaymentBundle\UcPaymentBundle(), ); }
并设置所需配置
# app/config/config.yml uc_payment: stripe: app_id: '%uc_payment_stripe_app_id%' The Stripe app id key can be added as a symfony parameter app_secret: '%uc_payment_stripe_app_secret%' The Stripe secret key can be added as a symfony parameter public_key: '%uc_payment_stripe_public_key%' The Stripe public key can be added as a symfony parameter paypal: client_id: '%uc_payment_paypal_client_id%' The PayPal cleint id key can be added as a symfony parameter secret: '%uc_payment_paypal_secret%' The PayPal secret key can be added as a symfony parameter
创建一个收费(到平台或连接的 Stripe 账户)
/** * $chargeAmount (int) : The charge amount in cents, for instance 1000 for 10.00 (of the currency) * $chargeCurrency (string) : The charge currency (for instance, "eur") * $paymentToken (string) : The payment token obtained using the Stripe.js library * $applicationFee (int) : The amount of the application fee (in cents), default to 0 * $chargeDescription (string) : (optional) The charge description for the customer */ $stripeClient->createCharge($chargeAmount, $chargeCurrency, $paymentToken, $applicationFee, $chargeDescription);
退款
/** * $chargeId (string) : The Stripe charge ID (returned by Stripe when you create a charge) * $refundAmount (int) : The charge amount in cents (if null, the whole charge amount will be refunded) * $metadata (array) : additional informations about the refund, default [] * $reason (string) : The reason of the refund, either "requested_by_customer", "duplicate" or "fraudulent" * $refundApplicationFee (bool) : Wether the application_fee should be refunded aswell, default true * $reverseTransfer (bool) : Wether the transfer should be reversed (when using Stripe Connect "destination" parameter on charge creation), default false */ $stripeClient->refundCharge($chargeId, $refundAmount, $metadata, $reason, $refundApplicationFee, $reverseTransfer);