shaz3e / peach-payment
Peach payment hosted checkout
1.0.1
2023-11-27 15:34 UTC
This package is auto-updated.
Last update: 2024-11-10 15:33:43 UTC
README
Install Peach Payment in Laravel
composer require shaz3e/peach-payment
Add service provider
'providers' => [ Shaz3e\PeachPayment\Providers\PeachPaymentServiceProvider::class, ]
Publish the config file
php artisan vendor:publish --tag=peach-payment-config
Update .env Data
php artisan update:peach-payment-config
How to Use
Watch YouTube Video Tutorials with details instructions and customization
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'));
In your.view use the following code.
<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>
When you run php artisan update:peach-payment-config
it will ask you the following.
- What is your PEACHPAYMENT_ENVIRONMENT?
- What is your PEACHPAYMENT_ENTITY_ID?
- What is your PEACHPAYMENT_CLIENT_ID?
- What is your PEACHPAYMENT_CLIENT_SECRET?
- What is your PEACHPAYMENT_MERCHANT_ID?
- What is your PEACHPAYMENT_DOMAIN?
- What is your PEACHPAYMENT_CURRENCY?
After updating env data visit yourwebsite.com/peachpayment
and it will fatch token and initiate the checkout at PeachPayment
Test Credit Cards https://developer.peachpayments.com/docs/reference-test-and-go-live
Contributing
- If you have any suggestions please let me know : https://github.com/Shaz3e/peach-payment/pulls.
- Please help me improve code https://github.com/Shaz3e/peach-payment/pulls
License
Peach Payment Embed Checkout with Laravel is licensed under the MIT license. Enjoy!