@getivy/react-sdk
v0.0.5
Published
Ivy checkout react library
Keywords
Readme
Ivy checkout react SDK
Installation
npm install @getivy/react-sdkUsage
- Import
IvyCheckoutcomponent and css styles:
import { IvyCheckout } from "@getivy/react-sdk";
import "@getivy/react-sdk/dist/index.css";- Render
IvyCheckoutcomponent and pass required props:
<IvyCheckout
checkoutUrl={checkoutUrl}
displayOptions={{
type: "embedded",
}}
onSuccess={({ redirectUrl, referenceId }) => {
handleSuccess({ redirectUrl, referenceId });
}}
onCancel={({ redirectUrl, referenceId }) => {
handleCancel({ redirectUrl, referenceId });
}}
/>Props
checkoutUrl
checkoutUrl: string
Ivy checkout url returned from POST https://api.getivy.de/api/service/checkout/session/create request
displayOptions
displayOptions: {
type: "embedded" | "modal"
maxHeight?: number
maxWidth?: number
}Configures how the checkout will be rendered:
embeddedtype renders checkout inside a wrappingJSXelement inheriting it's height and width.modaltype renders checkout as modal covering the current page content independent of the parent element stylesmaxWidthandmaxHeightlimits the size of rendered iframe / modal div element.embeddedtype by default takes 100% height and witdh of parent component.modaldefault max height is700pxand max width is520px
onSuccess
onSuccess: (data: { redirectUrl: string, referenceId: string}) => void
Callback fired after a successful payment. It provides the success redirectUrl configured in merchant dashboard and referenceId of the successful order.
onCancel
onCancel: (data: { redirectUrl: string, referenceId: string}) => void
Callback fired after cancelling payment. It provides the error redirectUrl configured in merchant dashboard and referenceId of the canceled order.
CSS Styles
@getivy/react-sdk/dist/index.css returns some basic styles for rendering embedded and modal IvyCheckout component:
.ivy-embedded-checkout-screen {
border: none;
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
}
.ivy-modal-content {
position: fixed;
z-index: 999999;
inset: 0;
color: #000;
background-color: rgba(10, 10, 10, 0.25);
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.ivy-modal-content .ivy-modal-iframe-container {
border: none;
margin: 0;
padding: 0;
overflow: hidden;
border-radius: 16px;
transform: translateZ(0);
width: 100%;
height: 100%;
background-color: transparent;
}
.ivy-modal-content .ivy-modal-checkout-screen {
border: none;
margin: 0;
padding: 0;
overflow: hidden;
width: 100% !important;
height: 100% !important;
}
@media (min-width: 450px) {
.ivy-modal-content {
padding: 16px 32px 32px;
}
}
@media (max-width: 450px) {
.ivy-modal-content .ivy-modal-iframe-container {
border-radius: 0px;
width: 100% !important;
height: 100% !important;
max-height: none !important;
}
}
