Provide purchase data to Rebilly Instruments
Important
This topic requires that Rebilly Instruments is set up. If you have not already done so, Set up Rebilly Instruments.
This topic describes how to pass purchase data to RebillyInstruments.mount(), you must provide purchase data to complete the customer flow. It is mandatory to use one of the following properties that are detailed in this page:
To change the purchase data at runtime, use the RebillyInstruments.update() function.
RebillyInstruments.mount(items: [])
Use this option when a customer has selected multiple items, such as in a shopping cart, or when you have specific plans to offer to a customer.
Each object in theitems
array object must incluide a planId
and a quantity
property. For more information, see Create a product and pricing plan.Additionally, if Rebilly Instruments has been supplied with a summary
, items
may include a thumbnail.Example
RebillyInstruments.mount({
publishableKey: 'pk_sandbox_123',
organizationId: 'org-123',
websiteId: 'my-website-id',
apiMode: 'sandbox',
items: [
{
planId: 'plan-abc',
quantity: 1,
thumbnail: 'https://www.example.com/image.png' // this property is optional
}
]
});
RebillyInstruments.mount(money: {})
Use this option to permit a customer to make a purchase without additional configuration. Directly specify the amount to request from the customer.
Themoney
object must include amount
and currency
properties.Example
RebillyInstruments.mount({
publishableKey: 'pk_sandbox_123',
organizationId: 'org-123',
websiteId: 'my-website-id',
apiMode: 'sandbox',
money: {
amount: 50,
currency: 'USD'
}
});
RebillyInstruments.mount(invoiceId: " ")
Note
To use this property, you must:
- Host additional code on your own server to create an invoice and authenticate a customer.
- Provide
jwt
with access to theStorefrontGetInvoice
operation. - Authorize a customer to use
jwt
.
Use this option to directly make a payment on a specific invoice.
Authorize a customer to use jwt
- Create a customer.
- Create a secret API key.
- From the server, execute the PostAuthenticationToken operation, using the following required parameters:
mode
: Set aspasswordless
.customerId
: ID of the customer you created that you created in step 1.
- From the response, use the
token
value to execute the PostAuthenticationTokenExchange operation. This exchange must occur as closely as possible to when the customer will access the data. - From the response, use the
token
value as the JWT for customer authentication.
Note
- The
PostAuthenticationTokenExchange
token
and thePostAuthenticationToken
token
are different. - The
PostAuthenticationToken
token
must be treated securely and always set to expire.
Example
RebillyInstruments.mount({
publishableKey: 'pk_sandbox_123',
organizationId: 'org-123',
websiteId: 'my-website-id',
apiMode: 'sandbox',
invoiceId: 'an-invoice-id',
jwt: 'the-customer-jwt'
});
RebillyInstruments.mount(transactionId: " ")
Note
To use this property, you must:
- Host additional code on your own server to create an invoice and authenticate a customer.
- Provide
jwt
with access to theStorefrontGetTransaction
andStorefrontGetInvoice
operations. - Authorize a customer to use
jwt
.
Use this options to directly make a payment towards a specific transaction.
Authorize a customer to use `jwt`
- Create a customer.
- Create a secret API key.
- From the server, execute the PostAuthenticationToken operation, using the following required parameters:
mode
: Set aspasswordless
.customerId
: ID of the customer you created that you created in step 1.
- From the response, use the
token
value to execute the PostAuthenticationTokenExchange operation. This exchange must occur as closely as possible to when the customer will access the data. - From the response, use the
token
value as the JWT for customer authentication.
Note
- The
PostAuthenticationTokenExchange
token
and thePostAuthenticationToken
token
are different. - The
PostAuthenticationToken
token
must be treated securely and always set to expire.
Example
RebillyInstruments.mount({
publishableKey: 'pk_sandbox_123',
organizationId: 'org-123',
websiteId: 'my-website-id',
apiMode: 'sandbox',
transactionId: 'a-transaction-id',
jwt: 'the-customer-jwt'
});
RebillyInstruments.mount(jwt: " ")
Note
To use this property, you must:
- Host additional code on your own server to create an invoice or transaction and authenticate a customer.
- Authorize a customer to use
jwt
.
- Create a customer.
- Create a secret API key.
- From the server, execute the PostAuthenticationToken operation, using the following required parameters:
mode
: Set aspasswordless
.customerId
: ID of the customer you created that you created in step 1.
- From the response, use the
token
value to execute the PostAuthenticationTokenExchange operation. This exchange must occur as closely as possible to when the customer accesses the data.acl
: Include a scope with yourorganizationId
, thetransactionId
orinvoiceId
, and the followingpermissions
:PostToken
StorefrontGetAccount
StorefrontPatchAccount
StorefrontPostPayment
StorefrontGetTransaction
StorefrontPatchTransaction
StorefrontGetPaymentInstrumentCollection
StorefrontPostPaymentInstrument
StorefrontGetPaymentInstrument
StorefrontPatchPaymentInstrument
StorefrontPostPaymentInstrumentDeactivation
StorefrontGetWebsite
StorefrontGetInvoiceCollection
StorefrontGetInvoice
StorefrontGetProductCollection
StorefrontGetProduct
StorefrontPostReadyToPay
customClaims
: include thewebsiteId
as well as thetransactionId
orinvoiceId
.
- From the response, use the
token
value as the JWT for customer authentication.
Note
PostAuthenticationTokenExchange
token
and thePostAuthenticationToken
token
are different values.PostAuthenticationToken
token
must be treated securely and always set to expire.
Example
RebillyInstruments.mount({
apiMode: 'sandbox',
jwt: 'the-customer-jwt'
});