Kartris User Guide

17.20. Stripe Checkout

Stripe is a popular payment solution that supports many countries and provides a number of integration routes. Kartris implements "Stripe Checkout". Stripe support was added to Kartris with v3.3001. There are some small changes to the Checkout, CheckoutProcess, CheckoutComplete and Callback to handle it. Also, the Stripe.net library needs to be added to the bin folder too.

If you have v3.3001 or later installed, Stripe will be available in the payment gateways list already.

17.20.1. Setup within Kartris

In addition to the general settings most gateways have, Stripe requires these particular ones:

17.20.1.1. ApiKeyPublishable

This is the "publishable" API key that Stripe will generate for you inside your account. This key is used by Kartris when formatting the javascript that forwards user sessions over to Stripe for the payment. It will generally start with the letters "pk_". It is called "publishable" since this is used in client-side code so can be visible to users.

17.20.1.2. ApiKeySecret

This is the key that Kartris uses server-side to communicate with the Stripe servers. This will not be visible to the user's browser in any way during the process, and as such is "secret". It will generally start with the letters "sk_".

17.20.1.3. WebhookEndpointSecret

Webhooks are setup in Stripe to post information back to web sites when certain events happen. In our case, we're interested in getting notification when checkout sessions are completed (i.e. customer completes payment). More detail on setting these up below. But a secret value is used to secure these, and that should be entered here.

 

See @17.20.2. Setup within Stripe‍ for more details.

17.20.1.4. StripeJSSourceURL

A client-side javascript library is used to format javascript to redirect user sessions from Kartris over to Stripe's payment pages. This is the path to that library. In future, Stripe may require we link to newer libraries, hence we have this URL in the settings so it can be changed easily.

17.20.1.5. OrderDescription

For simplicity, we format the order as a single item with a value to send to Stripe. When users checkout, they will see this item on the left of the page with its value. The name shown to users will be [OrderDescription][OrderID]. You can change the OrderDescription part here to customize the order description to your own site's name.

17.20.2. Setup within Stripe

To receive notifications from Stripe to your Kartris store, a webhook is required. You should configure this point to [yoursiteURL]/callback-stripe.aspx

You will have to associate at least one event. You should choose "Checkout" followed by checking the box for checkout.session.completed

A webhook endpoint secret will be generated, and you should ensure you add this into your Stripe settings in Kartris. See @17.20.1.3. WebhookEndpointSecret‍ for more details.

This will be called "Signing secret" but you will have to click to reveal it. It should begin "whsec_".

17.20.2.1. Stripe API version

Stripe let's you choose the version of its API that you use. We have tested our integration with both these versions (which were default, and latest, at the time of writing) and both work fine.

2022-11-15
2020-08-27

17.20.3. Development and testing

If you are developing and testing locally, Stripe provides a useful tool in the shape of the CLI (Command Line Interface). At time of writing, the latest version is here: https://github.com/stripe/stripe-cli/releases/tag/v1.13.6

Copy the Stripe.exe file to your local machine, and then use a command prompt to navigate to it. If you run your Kartris on Visual Studio's built in server, you can get Stripe's CLI to listen for webhooks and forward them to your local development site's callback page (Kartris will map requests to callback-stripe.aspx to callback.aspx?g=stripe, which tells Kartris which gateway DLL to use for processing the callback). For example, something like this:

stripe listen --forward-to http://localhost:4242/callback-stripe.aspx

The CLI will give you the webhook endpoint secret to use. You need to add this in your settings, see @17.20.1.3. WebhookEndpointSecret‍ 

Once this is set, you can move through your checkout process, select Stripe as payment method, and go through to pay. If you have Stripe set to TEST mode, you will see some dev info on the page before you go to Stripe, and have a checkout button to push. This way, you can view the page source if you need to see what is being posted during development. This page does not show in LIVE mode, Kartris will format the javascript silently and submit it immediately.

You should see the order details to the left, and a payment form to the right. Use the following test card details:

 

4242 4242 4242 4242
any name

a date in the future

any three digit security code

 

Stripe should show the transaction as complete and forward you back to your development site.

 

You should see the order showing as paid in your back end, with the event ID added as the reference code. In the CLI window, you should see some indication that the webhook was triggered and received a 200 ok response.

The full CLI reference is here: https://stripe.com/docs/cli

 
powered by tomehost