How to remove Stripe and payments
In this guide, we will go through the minimum changes needed to make the booking flow work without Stripe. This is not an easy customization project.
The client-side code examples in this guide use the booking process. If you are removing Stripe from a purchase, negotiation or download process, you need to adjust the examples to match that process.
Removing Stripe
The Sharetribe Web Template works with specific transaction processes and payments are a core feature of the booking, purchase, and negotiation processes: the ubiquitous nature means that you need to touch several components and files. When you remove Stripe payments, you may need to customize some parts (e.g. transaction process, email templates, checkout page) more depending on your marketplace idea. For example, you might also want to remove unused Stripe components from your project to clean up the code.
The template supports the default-inquiry process, which does not include bookings or stock reservations. This process is the easiest way to use a marketplace without Stripe. However, if you do want to use bookings, stock reservations, or negotiation without Stripe, you will need to follow the steps in this guide.
To follow these instructions, the transaction process you are modifying needs to already exist in your marketplace.
If you want to add a new transaction process without Stripe actions (for
example default-booking-no-stripe/release-1) instead of making a new
version of your existing one (for example default-booking/release-1),
you first need to add an unmodified version of it to your marketplace by
following these instructions:
- Create a new transaction process with the Sharetribe CLI
- Change transaction process in Sharetribe Web Template
Update the transaction processes and remove Stripe related actions
You need to remove at least the following actions:
:action/stripe-create-payment-intent:action/stripe-capture-payment-intent:action/stripe-confirm-payment-intent:action/stripe-create-payout:action/stripe-refund-payment
If you are using the template default processes with strong customer
authentication (default-booking, default-purchase,
default-negotiation, default-download) you need to remove confirming
the payment. Otherwise, the transaction will get stuck. The simplest way
to do this is to remove the pending-payment and payment-expired
states and the confirm-payment and expire-payment transitions. Then
point request-payment and request-payment-after-inquiry, or
request-payment-to-accept-offer, directly to the following state:
preauthorizedindefault-bookingpurchasedindefault-purchaseanddefault-downloadoffer-acceptedindefault-negotiation
Whenever you remove transitions, double check what notifications you are sending in those transitions. If you want to keep the notification, you will need to send it in a different transition.
When you are building the transaction process for your marketplace, it may make sense to rename some of the states and transitions so that they make more sense in your use-case. For instance, preauthorized state refers to the state of payment - it is preauthorized to be captured. Without payments in the process, it can be a good idea to change the state name to something else.
This guide proceeds with the assumption that you have not changed state and transition names in your process. If you do change your transition and state names, you will need to double check all example code and files to make sure you have updated the transition and state names referenced in those files.
Edit the transaction process file to reflect the changes in your transaction process
The src/transactions/transaction.js has a number of helper functions that are used to determine which state the transaction is. Depending on the transaction process being used, the transaction.js file refers to either src/transactions/transactionProcessBooking.js, src/transactions/transactionProcessPurchase.js, src/transactions/transactionProcessDownload.js or src/transactions/transactionProcessNegotiation.js for the correct states in each process. The transaction process file should be updated to match the new transaction process. Read more about editing transaction related files.
For example, in the booking process graph, point REQUEST_PAYMENT and
REQUEST_PAYMENT_AFTER_INQUIRY to states.PREAUTHORIZED. Then remove
the states.PENDING_PAYMENT and states.PAYMENT_EXPIRED entries. If
you added a separate transaction process without Stripe, make these
changes in the transaction process file of that process instead.
[states.INITIAL]: {
on: {
[transitions.INQUIRE]: states.INQUIRY,
[transitions.REQUEST_PAYMENT]: states.PREAUTHORIZED,
},
},
[states.INQUIRY]: {
on: {
[transitions.REQUEST_PAYMENT_AFTER_INQUIRY]: states.PREAUTHORIZED,
},
},
[states.PREAUTHORIZED]: {
on: {
[transitions.DECLINE]: states.DECLINED,If your process works without Stripe, also set supportedPayments to an
empty object in the transaction process file. The listing wizard and
checkout use supportedPayments to decide whether a process uses
Stripe. A file copied from one of the default payment processes declares
card payments, so the listing wizard only accepts currencies that Stripe
supports. The default inquiry process in transactionProcessInquiry.js
uses an empty object for the same reason.
// This process does not support payments
export const supportedPayments = {};Remove Stripe checks from EditListingWizard handlePublishListing function
In
EditListingWizard.js
we check if a provider has a Stripe account with all the required
information before we allow them to publish listings.
- EditListingWizard.js
This check is done in the handlePublishListing function. If you are
removing all Stripe functionality from your marketplace, you can
simplify the whole function like this, and remove the unused code. The
function still checks that a listing with required files has all its
files uploaded and verified before publishing.
handlePublishListing(id) {
const {
onPublishListingDraft,
listing,
config,
fileUploadsDisabled,
allFilesUploadedAndVerified,
} = this.props;
const listingTypeConfig = getListingTypeConfig(listing, this.state.selectedListingType, config);
const filesRequired = requireListingFiles(listingTypeConfig);
// Listing should not be published if files are required and they are not fully
// uploaded and verified, or if file uploads have been disabled at the platform level.
// This is enforced by the submit on the last EditListingWizard tab; this is added protection.
if (filesRequired && (fileUploadsDisabled || !allFilesUploadedAndVerified)) {
return;
}
onPublishListingDraft(id);
}If you are adding an option to not use Stripe, for example a listing
type where you handle payments outside the Sharetribe transaction
process, you can instead add a new variable such as isNoStripeProcess
and use it to bypass the Stripe requirement while keeping it for other
listing types.
handlePublishListing(id) {
const {
onPublishListingDraft,
currentUser,
stripeAccount,
listing,
config,
fileUploadsDisabled,
allFilesUploadedAndVerified,
} = this.props;
const processName = listing?.attributes?.publicData?.transactionProcessAlias.split('/')[0];
const isInquiryProcess = processName === INQUIRY_PROCESS_NAME;
const isNoStripeProcess = processName === BOOKING_NO_STRIPE_PROCESS_NAME;
/* ... */
if (
isInquiryProcess ||
isNoStripeProcess ||
!isPayoutDetailsRequired ||
(stripeConnected && !stripeRequirementsMissing)
) {
onPublishListingDraft(id);
} else {
this.setState({
draftId: id,
showPayoutDetails: true,
});
}
}After changing the handlePublishListing you can remove unused code.
You also might want to clean up EditListingPage and remove the Stripe
related props we pass to EditListingWizard.
Remove Stripe checks from ListingPage.shared.js
The listing page components show a warning to listing authors if they need to add their Stripe payout details to start accepting orders. With a non-Stripe listing type, this logic needs to be modified.
- ListingPage.shared.js
const isNoStripeProcess = processName === BOOKING_NO_STRIPE_PROCESS_NAME;
const currentAuthor = authorAvailable ? currentListing.author : null;
const ensuredAuthor = ensureUser(currentAuthor);
const authorNeedsPayoutDetails =
(!isNoStripeProcess && ['booking', 'purchase'].includes(processType)) ||
(isNegotiation && unitType === OFFER);
const noPayoutDetailsSetWithOwnListing =
isOwnListing && (authorNeedsPayoutDetails && !currentUser?.attributes?.stripeConnected);
const payoutDetailsWarning = noPayoutDetailsSetWithOwnListing ? (
<span className={payoutDetailsWarningClassName}>
<FormattedMessage id="ListingPage.payoutDetailsWarning" values={{ processType }} />
<NamedLink name="StripePayoutPage">
<FormattedMessage id="ListingPage.payoutDetailsWarningLink" />
</NamedLink>
</span>
) : null;If you are removing Stripe entirely, you can omit the whole
payoutDetailsWarning logic instead. Remove the
authorNeedsPayoutDetails, noPayoutDetailsSetWithOwnListing and
payoutDetailsWarning constants, and their entries in the object that
getDerivedRenderData returns. The warning links to StripePayoutPage,
which we remove in a later step.
Remove Stripe checks from MakeOfferForm
If you are fully removing Stripe, or if you are removing Stripe payments
from a process that is based on default-negotiation, you also need to
modify the
MakeOfferForm.js .
- MakeOfferForm.js
This component has a limitation that providers cannot submit their offer
if they don’t have a Stripe account. You will need to remove the
references to stripeConnected in the form to remove this restriction.
Edit CheckoutPage
Removing Stripe from CheckoutPage is probably the most complicated
task in this list because the Strong Customer Authentication (SCA) and
ability to save payment method have added a lot of logic to the current
page.
By default, the CheckoutPage component uses two sub-components,
depending on the transaction process:
- CheckoutPageWithInquiryProcess is used with the default free inquiry process
- CheckoutPageWithPayment is used with the default processes that process payments
We can use an edited version of the CheckoutPageWithPayment component, titled CheckoutPageWithoutPayment, as a starting point for the modifications.
The CheckoutPageWithoutPayment.js component uses the default
transition variables REQUEST_PAYMENT and REQUEST_PAYMENT_AFTER_INQUIRY
in the fetchSpeculatedTransactionIfNeeded function, so if you have
edited your transition names, double check that this function calls the
right transitions.
The CheckoutPageWithoutPayment component also imports a SimpleOrderForm component. Let’s add the component to the existing StripePaymentForm folder.
- SimpleOrderForm.js
If you are removing Stripe entirely, you can replace the
CheckoutPageWithPayment component with the
CheckoutPageWithoutPayment one on CheckoutPage.js. Since release
v12.7.0Â ,
CheckoutPage.js also has elements for push payments, such as the
isReturnAfterRedirect branch that renders
CheckoutPageRedirectReturn. If you are using push payments with
another payment provider, you need to consider separately which of these
elements to remove and which to keep.
If you are adding a separate transaction process that works without
Stripe, you will need to add the CheckoutPageWithoutPayment to the
CheckoutPage return statement to take it into use.
Release v12.7.0+
Since release
v12.7.0Â ,
the return statement also has a branch for customers returning from a
redirect payment. Add the CheckoutPageWithoutPayment branch after the
inquiry branch.
const isNoStripeProcess = processName === BOOKING_NO_STRIPE_PROCESS_NAME;
return processName && isInquiryProcess ? (
<CheckoutPageWithInquiryProcess
config={config}
routeConfiguration={routeConfiguration}
intl={intl}
history={history}
processName={processName}
pageData={pageData}
listingTitle={listingTitle}
title={title}
onInquiryWithoutPayment={onInquiryWithoutPayment}
onSubmitCallback={onSubmitCallback}
showListingImage={showListingImage}
transactionFieldConfigs={transactionFieldConfigs}
{...props}
/>
) : processName && isNoStripeProcess && !speculateTransactionInProgress ? (
<CheckoutPageWithoutPayment
config={config}
routeConfiguration={routeConfiguration}
intl={intl}
history={history}
processName={processName}
sessionStorageKey={STORAGE_KEY}
pageData={pageData}
setPageData={setPageData}
listingTitle={listingTitle}
title={title}
onSubmitCallback={onSubmitCallback}
showListingImage={showListingImage}
transactionFieldConfigs={transactionFieldConfigs}
showTransactionFields={showTransactionFields}
{...props}
/>
) : isReturnAfterRedirect ? (
<CheckoutPageRedirectReturn {...props} />
) : processName && !isInquiryProcess && hasSpeculatedTransactionForRender ? (
<CheckoutPageWithPayment
config={config}
/* ... */To use CheckoutPageWithoutPayment, we also need to make these changes to existing components:
- Export a processCheckoutWithoutPayment function from src/containers/CheckoutPage/CheckoutPageTransactionHelpers.js
- CheckoutPageTransactionHelpers.js
export const processCheckoutWithoutPayment = (
orderParams,
extraParams
) => {
const {
onInitiateOrder,
pageData,
process,
setPageData,
sessionStorageKey,
} = extraParams;
const storedTx = ensureTransaction(pageData.transaction);
const processAlias =
pageData?.listing?.attributes?.publicData?.transactionProcessAlias;
////////////////////////////////////////////////
// Step 1: initiate order //
// by requesting booking from Marketplace API //
////////////////////////////////////////////////
const fnRequest = (fnParams) => {
// fnParams should be { listingId, deliveryMethod, quantity?, bookingDates?, protectedData }
const requestTransition =
storedTx?.attributes?.lastTransition ===
process.transitions.INQUIRE
? // =====================
// Double check that these transition names match the
// transition names in your transaction process!
// =====================
process.transitions.REQUEST_PAYMENT_AFTER_INQUIRY
: process.transitions.REQUEST_PAYMENT;
const isPrivileged = process.isPrivileged(requestTransition);
const orderPromise = onInitiateOrder(
fnParams,
processAlias,
storedTx.id,
requestTransition,
isPrivileged
);
orderPromise.then((order) => {
// Store the returned transaction (order)
persistTransaction(
order,
pageData,
storeData,
setPageData,
sessionStorageKey
);
});
return orderPromise;
};
return fnRequest(orderParams).then((order) => ({
orderId: order.id,
}));
};- Import and use loadInitialData instead of loadInitialDataForStripePayments in CheckoutPage.js.
- CheckoutPage.js
First, import CheckoutPageWithoutPayment and its loadInitialData
function. The CheckoutPageWithoutPayment component is also used in the
return statement above.
import CheckoutPageWithPayment, {
loadInitialDataForStripePayments,
} from './CheckoutPageWithPayment';
import CheckoutPageWithInquiryProcess from './CheckoutPageWithInquiryProcess';
import CheckoutPageWithoutPayment, { loadInitialData } from './CheckoutPageWithoutPayment';Then, call loadInitialData in the useEffect hook of CheckoutPage.
It takes pageData, fetchSpeculatedTransaction and config, so
fetchStripeCustomer is no longer passed.
Release v12.7.0+
Since release v12.7.0Â , the hook also skips loading data when the customer returns from a redirect payment.
// Do not fetch extra data if user is not active (E.g. they are in pending-approval state.)
// Return-after-redirect only resumes confirm — do not speculate or fetch StripeCustomer.
if (isUserAuthorized(currentUser) && !isReturnAfterRedirect) {
// This is for processes using payments with Stripe integration
// Inquiry process has no payment transitions; skip speculate/Stripe customer fetch.
if (getProcessName(data) !== INQUIRY_PROCESS_NAME) {
// Fetch StripeCustomer and speculateTransition for transactions that include Stripe payments
loadInitialData({
pageData: data || {},
fetchSpeculatedTransaction,
config,
});
}
}Hide or remove Stripe related pages
If you are not using Stripe at all, you should remove or at least hide the pages that are meant for managing the information saved to Stripe. These pages are StripePayoutPage and PaymentMethodsPage . Both of these pages are accessible through the account settings so we want to hide them from both navigation component and route configuration.
To hide the pages from account settings, modify the
LayoutWrapperAccountSettingsSideNav component. Destructure only
currentPage from accountSettingsNavProps, and replace the
payoutDetailsMaybe and paymentMethodsMaybe tab definitions with
empty arrays:
- LayoutWrapperAccountSettingsSideNav.js
const { currentPage } = accountSettingsNavProps;
const payoutDetailsMaybe = [];
const paymentMethodsMaybe = [];
const tabs = [In routeConfiguration.js, remove references to StripePayoutPage and
PaymentMethodsPage. Remove both from ACCOUNT_SETTINGS_PAGES. Then
remove the StripePayoutPage, StripePayoutOnboardingPage and
PaymentMethodsPage routes, so that the PasswordChangePage route is
followed by the ManageAccountPage route. Finally, remove the now
unused StripePayoutPage and PaymentMethodsPage imports at the top of
the file.
- routeConfiguration.js
export const ACCOUNT_SETTINGS_PAGES = [
'ContactDetailsPage',
'PasswordChangePage',
'ManageAccountPage'
];
/* ... */
{
path: '/account/change-password',
name: 'PasswordChangePage',
auth: true,
authPage: 'LoginPage',
component: PasswordChangePage,
},
{
path: '/account/manage',
name: 'ManageAccountPage',
auth: true,
authPage: 'LoginPage',
component: ManageAccountPage,
},Finally, you need to remove StripePayoutPage from the ModalMissingInformation.js component allowlist.
- ModalMissingInformation.js
const MISSING_INFORMATION_MODAL_WHITELIST = [
'LoginPage',
'SignupPage',
'ContactDetailsPage',
'EmailVerificationPage',
'PasswordResetPage',
];Extra: Removing unused exports
This is not a mandatory step to do but if you want to clean up the code
you can go through the components/index.js and containers/index.js,
and remove the Stripe components. After this, you should go through the
whole codebase and remove all the references to these components. We
have tried to follow the naming pattern where Stripe related components
have Stripe in their name but there are a couple of exceptions like
PaymentMethodsPage. All these components should be removed also from
examples.js.
Stripe related components:
- StripeBankAccountTokenInputField
- StripeConnectAccountStatusBox
- StripePaymentAddress
- StripePayoutPage
- PaymentMethodsPage
- PaymentMethodsForm
- StripePaymentForm
- StripeConnectAccountForm
Removing payments
If you want to remove payments completely from your marketplace, there are even more things to consider. Again it depends a lot on your use-case what kind of changes are needed. If you e.g. want to add a transaction process with free bookings or purchases, you need to build the conditional logic for showing pricing components when needed and hiding them when not. If you want to build the marketplace completely without payments, you most likely want to hide all the references to listing price.
More changes to the transaction process
Remove the actions related to payments, e.g.
:action/privileged-set-line-items and :action/calculate-full-refund
in the default processes. Read more about actions in the
transaction process actions reference article.
Remember to also update email templates that contain pricing
information.
Edit API calls in client app’s server
You will need to edit the API calls in your client app’s server. If
there are no payments used, there is most likely no need for calculating
line items, so we can remove transactionLineItems function calls from
API endpoints. Depending on your use case, you may or may not want to
use the privileged transitions at all. However, in case you are updating
e.g. transaction protected data, it is a good practice to do that safely
in the template’s backend.
Other code changes
Especially if you are removing the payment completely from your marketplace, you should also go through all these pages to hide or remove the parts related to payments.
- ListingPage, CheckoutPage, TransactionPage: Remove or hide
OrderBreakdowncomponent when the transaction is free - EditListingPage: remove pricing tab from
EditListingWizard - SearchPage: remove price filter & edit
ListingCardso that it doesn’t show the listing price