shaz3e / peach-payment
桃支付托管结账
1.0.1
2023-11-27 15:34 UTC
This package is auto-updated.
Last update: 2024-09-10 15:07:44 UTC
README
在 Laravel 中安装桃支付
composer require shaz3e/peach-payment
添加服务提供者
'providers' => [ Shaz3e\PeachPayment\Providers\PeachPaymentServiceProvider::class, ]
发布配置文件
php artisan vendor:publish --tag=peach-payment-config
更新 .env 数据
php artisan update:peach-payment-config
使用方法
观看 YouTube 视频教程,获取详细说明和自定义信息
use Shaz3e\PeachPayment\Helpers\PeachPayment; // Use the following code within your controller method /** * Update in .env previously and get it from config */ $entityId = config('peach-payment.entity_id'); /** * Dynamic amount should be float * It can be passed via request */ $amount = (float) $request->amount; /** * Return URL is optional * If you want user to redirect to another URL of your approved domain you can use the following * Do not use / at the beginnig of the $return_url as it will generate URL i.e. config('peach-payment.domain').'/'.$return_url.'/?PeachPaymentOrder='.$order_number */ $return_url = 'after-main-domain/route/sub-route/?PeachPaymentOrder=OID123456789'; // Optional /** * Create new request for PeachPayment helper */ $peachPayment = new PeachPayment(); /** * Generate token and initiate the request */ $checkoutData = $peachPayment->createCheckout($amount); /** * Optional * Get Order Number if you want to update record in database * suggest me this is just for reconcile purpose * $checkoutData['order_number'] = OID.time() */ $order_number = $checkoutData['order_number']; /** * CheckoutId is unique id generated by PeachPayment * This should be passed to render the form in blade template */ $checkoutId = $checkoutData['checkoutId']; return view('your.view', compact('entityId', 'checkoutId'));
在您的.view中使用以下代码。
<div id="payment-form"></div> <script src="{{ config('peach-payment.' . config('peach-payment.environment') . '.embedded_checkout_url') }}"></script> <script> const checkout = Checkout.initiate({ key: "{{ $entityId }}", checkoutId: "{{ $checkoutId }}", }); checkout.render("#payment-form"); </script>
当您运行 php artisan update:peach-payment-config
时,它将询问以下内容。
- 您的 PEACHPAYMENT_ENVIRONMENT 是什么?
- 您的 PEACHPAYMENT_ENTITY_ID 是什么?
- 您的 PEACHPAYMENT_CLIENT_ID 是什么?
- 您的 PEACHPAYMENT_CLIENT_SECRET 是什么?
- 您的 PEACHPAYMENT_MERCHANT_ID 是什么?
- 您的 PEACHPAYMENT_DOMAIN 是什么?
- 您的 PEACHPAYMENT_CURRENCY 是什么?
更新 env 数据后,访问 yourwebsite.com/peachpayment
,它将获取令牌并在 PeachPayment 上启动结账。
测试信用卡 https://developer.peachpayments.com/docs/reference-test-and-go-live
贡献
- 如果您有任何建议,请告诉我:https://github.com/Shaz3e/peach-payment/pulls。
- 请帮助我改进代码 https://github.com/Shaz3e/peach-payment/pulls
许可证
桃支付嵌入结账与 Laravel 是基于 MIT 许可证。享受吧!