Skip to content

Latest commit

 

History

History
31 lines (18 loc) · 3.53 KB

File metadata and controls

31 lines (18 loc) · 3.53 KB

This transaction process enables automatic off-session payments on your marketplace. If you want to use this process in your Sharetribe Web Template, you will need to make the following modifications:

1. Push the process into your Sharetribe marketplace using Sharetribe CLI

You can see the instructions in this tutorial article. Once you have pushed the process into your marketplace, you will be able to see it in Console > Build > Transaction processes.

2. Configure the template to use this new process

There are a number of configurations in the template that are necessary for taking the new process into use.

  • Add a new listing type in src/config/configListing.js, and add your automatic off-session payment as the transaction type.
  • Add a transactionProcessOffSession.js file to src/transactions folder. The file should describe the states and transitions of the process. You can model this file after this example, or according to transactionProcessBooking.js in the same folder.
  • Modify transaction.js file in the same folder to return the off-session process information when necessary
  • Add a src/containers/TransactionPage/TransactionPage.stateDataOffSession.js file to return the correct state information for each state of the process. You can model this file after this example, or according to TransactionPage.stateDataBooking.js in the same folder.
  • Use TransactionPage.stateDataOffSession.js in the TransactionPage.stateData.js file to return state data for the correct process.
  • Add a src/containers/InboxPage/InboxPage.stateDataOffSession.js file to return the correct state information for each state of the process. You can model this file after this example, or according to InboxPage.stateDataBooking.js in the same folder.
  • Use InboxPage.stateDataOffSession.js in InboxPage.stateData.js file to return state data for the correct process.

3. Trigger the transaction directly from listing page

In the template, CheckoutPage.js is configured to handle payments. However, in the off-session process, the payment intent is not created upon booking. Therefore, the simplest way to handle the off-session flow is to add a logic that triggers the transaction for the off-session process directly from the listing page, and then redirects to TransactionPage.

If the automatic payment does not happen for some reason (e.g. insufficient funds or missing payment method), redirect the customer from TransactionPage to CheckoutPage and modify the fnRequestPayment function in handlePaymentIntent to trigger the correct transition for the automatic off-session payment process.

4. Add relevant notifications

By default, the web template shows a provider notification when they have a transaction to accept. For the automatic off-session payment process, you will need to add a logic to src/ducks/user.duck.js to fetch both customer and provider transactions where the next transitions require user action. You then need to add the notifications to src/containers/TopbarContainer/TopbarContainer.js and src/containers/InboxPage/InboxPage.js.

Customer action is required when the automatic payment fails and the customer needs to update their payment method and trigger the payment manually.