Skip to main content
Version: 1.0.0

SubscriptionCreateModal

Used to make users pay for new subscriptions.

Loading...
info

SubscriptionCreateModal requires the product and plan to be set.
If you're using our default flow, the user selects those before moving to payment already.
But if you have your own custom flow, you can use the usePelcro hook to set them before switching to the payment view like in the following example.

Usage#

import React from "react";
import {
SubscriptionCreateModal,
PelcroModalController,
usePelcro,
} from "@pelcro/react-pelcro-js";
import "@pelcro/react-pelcro-js/dist/pelcro.css";
export const SubscriptionCreateExample = () => {
const { switchToPaymentView, setProduct, setPlan } = usePelcro();
useEffect(() => {
setProduct(123);
setPlan(1234);
}, []);
return (
<>
<button onClick={() => switchToPaymentView()}>Pay for plan 1234</button>
<PelcroModalController>
<SubscriptionCreateModal />
</PelcroModalController>
</>
);
};

Reference#

Props#

onDisplay#

() โ‡’ void

Callback function called when the modal is first displayed.

onClose#

() โ‡’ void

Callback function called when the modal is closed.

onSuccess#

(userObject) โ‡’ void

Callback function called when the user subscribes succesfully.

onFailure#

(errorObject) โ‡’ void

Callback function called when the subscription creation fails.