NOTE: Before using this guide please ask us about getting your Storeganise account connected to your Stripe account.

Contents


Overview

The way we recommend setting up Stripe for a customer is as below:

  1. Create a User account for the customer via the Storeganise API

  2. Follow the instructions here to capture the customer's payment details using the Stripe Web UI, and connect the card to the Storeganise user account.

  3. Create the order; when the order is completed the invoice date is set for the customer; this tells the system which day of the month to create an invoice and charge the customer's card.


Implementation

1. Show the customer the Stripe Web UI

When configuring Stripe Web you'll need your publishable key, which you can get programmatically via the Storeganise API:

Example request

GET /v1/billing/stripe/settings
Authorization: Bearer 380afb97ced808

Example response

200 OK

{
  "publishableKey": "pk_test_3g4y2ty4yger..."
}


You'll also need to request a payment token before the customer submits their card details:

Example request

POST /v1/billing/stripe/token
Authorization: Bearer 380afb97ced808

Example response

200 OK

{
  "id": "seti_1FME3RAXX...",
  "clientSecret": "seti_1FME3RAXX..._secret_FrxzN..."
}


2. Submit the Stripe form

Then you're able to call Stripe Web's handleCardSetup()/confirmCardSetup()  with the token.secretToken obtained previously to save the card.

See the Stripe Web documentation for details: 

3. Send back the token id to Storeganise

Finally, send the field token.id (which is equal to result.setupIntent.id obtained above in handleCardSetup result) back to Storeganise to confirm the payment method creation.

Example request

POST /v1/billing/stripe/sources
Authorization: Bearer 380afb97ced808
Content-Type: application/json;charset=UTF-8

{
  "token": "seti_1FME3RAXX..."
}

Example response

200 OK


4. Check that the customer has a payment method set up

At this point it's finished, you can get updated userinfo that will confirm that the customer has a payment method set up (see the billingMethod attribute).

Example request

GET /v1/auth/userinfo?include=billingMethod
Authorization: Bearer 380afb97ced808

Example response

200 OK

{
  "firstName": "John",
  "lastName": "Smith",
  ...
  "billingMethod": "stripe"
}


You can also retrieve the specific payment methods that have been set up:

Example request

GET /v1/billing/stripe/sources
Authorization: Bearer 380afb97ced808

Example response

200 OK

[
  {
    "id": "card_44w432gr...",
    "brand": "Visa",
    "exp_month": 12,
    "exp_year": 2019,
    "last4": "1111",
    ...
  }
]


Here's a simplified demo, summarizing these steps: https://repl.it/@caub/storeganise-stripe-nodejs


If you are experiencing issues that none of our articles has helped you solve, please contact us:


🚀 USEFUL LINKS

🔎 WANT TO KNOW MORE?

If you'd like to know more, click on the chat icon to connect with us 😊

Did this answer your question?