1.0.0 • Published 6 years ago
hapi-gocart v1.0.0
hapi-gocart
Installation
npm install hapi-gocart
Usage
var GOCart = require('hapi-gocart')
server.register({
register: GOCart,
options: options,
}, function (err) {})
options
Object
corsOrigins
[String]
Sets the CORS headers for your routes. Default
['*']
.schemaUri
String
The URI for the gocart schema. Required.
stripeSecretKey
String
The Stripe secret key. Required.
License
See LICENSE.
gocart-schema
A JSON schema utility for GOCart.
Installation
npm install gocart-schema
Usage
var schema = require('gocart-schema')
var validation = schema.validate(yourObj)
validation.value // the result (with defaults populated)
validation.error // the error (`null` if `yourObj` is valid)
Specification
Schema
GOCart Object
This is the root object for the specification.
Fixed Fields
Field Name | Type | Description |
---|---|---|
info | Info Object | Required. |
products | Products Object | Required. |
server | Server Object | Required. |
stripe | Stripe Object | Required. |
Info Object
Defines additional data about the store.
Fixed Fields
Field Name | Type | Description |
---|---|---|
name | String | Required. |
description | String |
Patterned Objects
Field Pattern | Type | Description |
---|---|---|
^x- | Any |
Products Object
Patterned Fields
Field Pattern | Type | Description |
---|---|---|
{id} | Product Object | Required. |
Product Object
Defines a product. In addition to the subset specified below, can contain the types specified in Stripe Object (these values will override the global Stripe configuration).
Fixed Fields
Field Name | Type | Description |
---|---|---|
amount | Number | Required. |
description | String | |
images | [String] | |
metadata | Any | |
name | String | |
plan | String |
Patterned Fields
Field Pattern | Type | Description |
---|---|---|
^x- | Any |
Server Object
Defines the GOCart server configuration.
Fixed Fields
Field Name | Type | Description |
---|---|---|
host | String | Required. |
pathname | String |
Stripe Object
Defines the global Stripe configuration. Values can be overriden by individual Product Objects.
Fixed Fields
Field Name | Type | Description |
---|---|---|
allowRememberMe | Boolean | |
billingAddress | Boolean | |
bitcoin | Boolean | |
capture | Boolean | |
currency | String | |
image | String | |
name | String | |
panelLabel | String | |
publishableKey | String | Required. |
receiptEmail | Boolean | |
shippingAddress | Boolean | billingAddress must be set to true . |
zipCode | Boolean |
License
See LICENSE.
gocart-service
The core GOCart service.
Installation
npm install gocart-service
Usage
var handleRequest = require('gocart-service')(yourStripeSecretKey, yourSchemaUri)
handleRequest(payload).then(function (res) {})
createHandler()
createHandler(stripeSecretKey: string, schemaUri: string): (payload: object) => Promise
The shape of the payload
object is specified in lib/validate.
License
See LICENSE.
1.0.0
6 years ago