NOTE: Before using this guide please ask us about getting your Storeganise account connected to your Braintree account.
These instructions are for the Javascript v2 SDK

Contents

Overview

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

1. Create the customer's Storeganise account via the Storeganise API

2. Create the Braintree account for the customer using the Braintree Drop-in UI. See:

3. Pass the generated Braintree nonce to the Storeganise API which connects Braintree to the user account (see below for details).

4. 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 Braintree Drop-in UI

See the Braintree documentation for details: https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v2

When configuring Braintree you'll need your client authorization token, which you can get programmatically via the Storeganise API:

Example request

GET /v1/billing/braintree/token
Authorization: Bearer 380afb97ced808

Example response

200 OK

eyJ2ZXJzaW9...oib2ZmIn0

2. Submit the card nonce to Storeganise

Once the customer has gone through the flow to add their card details you'll receive a card nonce which should be passed to Storeganise.

Example request

POST /v1/billing/braintree/payment-methods
Authorization: Bearer 380afb97ced808
Content-Type: application/json;charset=UTF-8

{
  "nonce": "tokencc_bc_tz9r...h8z"
}

Example response

200 OK

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

After a payment source has been added 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": "braintree"
}

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

Example request

GET /v1/billing/braintree/payment-methods
Authorization: Bearer 380afb97ced808

Example response

200 OK

[
  {
    "cardType": "Visa",
    "expirationDate": "12/2019",
    "last4": "1111",
    "imageUrl": "https://assets.braintreegateway.com/payment_method_logo/visa.png"
    ...
  }
]
Did this answer your question?