# Provide purchase data to Rebilly Instruments Important This topic assumes that you have already completed one of the [Get started guides](/docs/dev-docs/get-started-integrate-payments), and are looking to customize or extend the functionality. 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: - `items` property. - `money` property. - `invoiceId` property. - `transactionId` property. - `deposit` property. - `payout` property. - `jwt` property. To change the purchase data at runtime, use the [RebillyInstruments.update()](/docs/dev-docs/reference-rebilly-instruments#rebillyinstruments.update) function. ## `items` property 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 the `items` array object must include a `planId` and a `quantity` property. For more information, see [Create a product and pricing plan](/docs/settings/products-and-pricing). Additionally, if Rebilly Instruments has been supplied with a `summary`, `items` may include a thumbnail. ### Example ```javascript RebillyInstruments.mount({ publishableKey: 'pk_123', organizationId: 'org-123', websiteId: 'my-website-id', items: [ { planId: 'plan-abc', quantity: 1, thumbnail: 'https://www.example.com/image.png', // this property is optional }, ], }); ``` ## `money` property Use this option to permit a customer to make a purchase without additional configuration. Directly specify the amount to request from the customer. The `money` object must include `amount` and `currency` properties. ### Example ```javascript RebillyInstruments.mount({ publishableKey: 'pk_123', organizationId: 'org-123', websiteId: 'my-website-id', money: { amount: 50, currency: 'USD', }, }); ``` ## `invoiceId` property 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 the `StorefrontGetInvoice` operation. - Authorize a customer to use `jwt`. Use this option to directly make a payment on a specific invoice. details summary Authorize a customer to use jwt 1. [Create a customer](/docs/dev-docs/api/customers/putcustomer). 2. [Create a secret API key](/docs/dev-docs/api-keys). 3. From the server, execute the [PostAuthenticationToken](/docs/dev-docs/api/customer-authentication/postauthenticationtoken) operation, using the following required parameters: - `mode`: Set as `passwordless`. - `customerId`: ID of the customer you created that you created in step 1. 4. From the response, use the `token` value to execute the [PostAuthenticationTokenExchange](/docs/dev-docs/api/customer-authentication/postauthenticationtokenexchange) operation. This exchange must occur as closely as possible to when the customer will access the data. 5. From the response, use the `token` value as the JWT for customer authentication. Note - The `PostAuthenticationTokenExchange` `token` and the `PostAuthenticationToken` `token` are different. - The `PostAuthenticationToken` `token` must be treated securely and always set to expire. ### Example ```javascript RebillyInstruments.mount({ invoiceId: 'an-invoice-id', jwt: 'the-customer-jwt', }); ``` ## `transactionId` property 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 the `StorefrontGetTransaction` and `StorefrontGetInvoice` operations. - Authorize a customer to use `jwt`. Use this options to directly make a payment towards a specific transaction. details summary Authorize a customer to use jwt 1. [Create a customer](/docs/dev-docs/api/customers/putcustomer). 2. [Create a secret API key](/docs/dev-docs/api-keys). 3. From the server, execute the [PostAuthenticationToken](/docs/dev-docs/api/customer-authentication/postauthenticationtoken) operation, using the following required parameters: - `mode`: Set as `passwordless`. - `customerId`: ID of the customer you created that you created in step 1. 4. From the response, use the `token` value to execute the [PostAuthenticationTokenExchange](/docs/dev-docs/api/customer-authentication/postauthenticationtokenexchange) operation. This exchange must occur as closely as possible to when the customer will access the data. 5. From the response, use the `token` value as the JWT for customer authentication. Note - The `PostAuthenticationTokenExchange` `token` and the `PostAuthenticationToken` `token` are different. - The `PostAuthenticationToken` `token` must be treated securely and always set to expire. ### Example ```javascript RebillyInstruments.mount({ transactionId: 'a-transaction-id', jwt: 'the-customer-jwt', }); ``` ## `deposit` property Note To use this property, you must: - Host additional code on your own server to create an invoice and authenticate a customer. - Authorize a customer to use `jwt`. Use this option to allow the customer to set the deposit amount. - `deposit` must be accompanied by [`jwt` property](#jwt-property). - `deposit` must provide the `depositRequestId` or `currency` property, all other properties are optional. For more information, see [Rebilly Instruments reference](/docs/dev-docs/reference-rebilly-instruments). ### Example ```javascript RebillyInstruments.mount({ deposit: { depositRequestId: 'a-deposit-request-id', }, jwt: 'the-customer-jwt', }); ``` or ```javascript RebillyInstruments.mount({ deposit: { currency: 'USD', }, jwt: 'the-customer-jwt', }); ``` ## `payout` property Note To use this property, you must: - Host additional code on your own server to create an invoice and authenticate a customer. - Authorize a customer to use `jwt`. - Issue a payout request to the customer. Use this option to allow the customer to set the deposit amount. - `payout` must be accompanied by [`jwt` property](#jwt-property). - `payout` must provide the `payoutRequestId`. ### Example ```javascript RebillyInstruments.mount({ payout: { payoutRequestId: 'a-payout-request-id', }, jwt: 'the-customer-jwt', }); ``` ## `jwt` property 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`. 1. [Create a customer](/docs/dev-docs/api/customers/putcustomer). 2. [Create a secret API key](/docs/dev-docs/api-keys). 3. From the server, execute the [PostAuthenticationToken](/docs/dev-docs/api/customer-authentication/postauthenticationtoken) operation, using the following required parameters: - `mode`: Set as `passwordless`. - `customerId`: ID of the customer you created that you created in step 1. 4. From the response, use the `token` value to execute the [PostAuthenticationTokenExchange](/docs/dev-docs/api/customer-authentication/postauthenticationtokenexchange) operation. This exchange must occur as closely as possible to when the customer accesses the data. - `acl`: Include a scope with your `organizationId`, the `transactionId` or `invoiceId`, and the following `permissions`: - `PostToken` - `PostDigitalWalletValidation` - `StorefrontGetAccount` - `StorefrontPatchAccount` - `StorefrontPostPayment` - `StorefrontGetTransactionCollection` - `StorefrontGetTransaction` - `StorefrontGetPaymentInstrumentCollection` - `StorefrontPostPaymentInstrument` - `StorefrontGetPaymentInstrument` - `StorefrontPatchPaymentInstrument` - `StorefrontPostPaymentInstrumentDeactivation` - `StorefrontGetWebsite` - `StorefrontGetInvoiceCollection` - `StorefrontGetInvoice` - `StorefrontGetProductCollection` - `StorefrontGetProduct` - `StorefrontPostReadyToPay` - `StorefrontPostReadyToPayout` - `StorefrontGetPaymentInstrumentSetup` - `StorefrontPostPaymentInstrumentSetup` - `StorefrontGetDepositRequest` - `StorefrontGetDepositStrategy` - `StorefrontGetPayoutRequest` - `StorefrontGetPayoutRequestCollection` - `StorefrontPatchPayoutRequest` - `customClaims`: include the `websiteId` as well as the `transactionId` or `invoiceId`. 5. From the response, use the `token` value as the JWT for customer authentication. Note - `PostAuthenticationTokenExchange` `token` and the `PostAuthenticationToken` `token` are different values. - `PostAuthenticationToken` `token` must be treated securely and always set to expire. ### Example ```javascript RebillyInstruments.mount({ jwt: 'the-customer-jwt', }); ```