Installation
Require the composer package
Publish the configuration
This will publish the configuration underconfig/lunar/stripe.php.
Publish the views (optional)
Lunar Stripe comes with some helper components for you to use on your checkout, if you intend to edit the views they provide, you can publish them.Enable the driver
Set the driver inconfig/lunar/payments.php
Add your Stripe credentials
Make sure you have the Stripe credentials set inconfig/services.php
Keys can be found in your Stripe account https://dashboard.stripe.com/apikeys
Configuration
Below is a list of the available configuration options this package uses inconfig/lunar/stripe.php
| Key | Default | Description |
|---|---|---|
policy | automatic | Determines the policy for taking payments and whether you wish to capture the payment manually later or take payment straight away. Available options manual or automatic |
sync_addresses | true | When enabled, the Stripe addon will attempt to sync the billing and shipping addresses which have been stored against the payment intent on Stripe. |
Backend Usage
Create a PaymentIntent
Fetch an existing PaymentIntent
Syncing an existing intent
If a payment intent has been created and there are changes to the cart, you will want to update the intent so it has the correct totals.Update an existing intent
For when you want to update certain properties on the PaymentIntent, without needing to recalculate the cart. See https://docs.stripe.com/api/payment_intents/updateCancel an existing intent
If you need to cancel a PaymentIntent, you can do so. You will need to provide a valid reason, those of which can be found in the Stripe docs: https://docs.stripe.com/api/payment_intents/cancel. Lunar Stripe includes a PHP Enum to make this easier for you:Update the address on Stripe
So you don’t have to manually specify all the shipping address fields you can use the helper function to do it for you.Charges
Retrieve a specific charge
Get all charges for a payment intent
Webhooks
The add-on provides an optional webhook you may add to Stripe. You can read the guide on how to do this on the Stripe website https://stripe.com/docs/webhooks/quickstart. The events you should listen to arepayment_intent.payment_failed, payment_intent.succeeded.
The path to the webhook will be http:://yoursite.com/stripe/webhook.
You can customise the path for the webhook in config/lunar/stripe.php.
You will also need to add the webhook signing secret to the services.php config file:
Storefront Examples
First we need to set up the backend API call to fetch or create the intent, this isn’t Vue specific but will likely be different if you’re using Livewire.Vuejs
This is just using Stripe’s payment elements, for more information check out the Stripe guidesPayment component
Extending
Webhook event params
In order to process the payment intent and link it to an order, we need the PaymentIntent ID and an optional Order ID. By default Lunar Stripe will look for the PaymentIntent ID via the Stripe Event and try and determine whether an existing order ID has been defined on the PaymentIntent meta. You can customise this behaviour by overriding theProcessesEventParameters instance.