🍸 Mojito Mixers
👨💻 React components for the Mojito Platform, Reference App and third-party projects, including Mojito's Checkout / Payment UI and payment sandbox / test app to easily test credit card, ACH, Wire and Crypto payments with Circle, 3DS, Plaid, Vertex and TaxJar integrations.
🚀 Check it out at https://payments-staging.mojito.xyz/!
Mixer v1 to Mixer v2 Migration
Using this library in your project Mixer v2
You can install this project with one of these commands:
npm install --save @mojito-inc/mixers
yarn add @mojito-inc/mixers
Alternatively, once you've built the library using yarn build
, you can install it locally in another project adding
this line to your package.json
's dependencies. If you update it, make sure you remove the entry from yarn.lock
and
re-install it.
"@mojito-inc/mixers": "file:../mojito-mixers"
Also, make sure you install the following dependencies:
react
react-dom
@mui/material
And also, keep in mind:
-
@emotion/react
is not needed.
-
@emotion/styled
is needed as stated in MUI's docs:
Keep @emotion/styled
as a dependency of your project. Even if you never use it explicitly, it's a peer dependency of @mui/material
.
-
styled-components
is needed as stated in react-payment-inputs
' docs, but it's not used:
Note: requires styled-components to be installed as a dependency.
By default, React Payment Inputs does not have built-in styling for it's inputs. However, React Payment Inputs comes with a styled wrapper which combines the card number, expiry & CVC fields...
Usage:
Fist, you need to create a CheckoutComponent: React.FC<PUICheckoutProps>
component that renders MojitoCheckout
and passes it all required props. Simply copy the following file and adapt it to your needs:
You can find an example here: app/src/layout/CheckoutLayout.tsx.
You'll use this CheckoutComponent
component in your code instead of MojitoCheckout
just so that you don't have to
repeat properties that rarely change, like the theme DefaultThemes
Note:
In the _app.tsx
file, please add the following line: <Script src="https://cdn.checkout.com/js/framesv2.min.js" />
. if it was not added, credit card payments won't work.
import { useAuth0 } from '@auth0/auth0-react';
import { MojitoCheckout } from '@mojito-inc/mixers';
const { isAuthenticated, getIdTokenClaims } = useAuth0();
const theme = {
font: {
primary: 'Sneak',
secondary: 'Sneak',
},
color: {
primary: '#6663FD',
secondary: '#FFFFFF',
background: '#FAFAFC',
errorBackground: '#FEE3E5',
text: '#000000',
cardBackground: '#FFFFFF',
checkout: {
continueButtonBackground: '#6663FD',
continueButtonTextColor: '#FFFFFF',
disableButtonBackground: '#DADAE9',
},
placeholder: '#BABEC5',
costBreakdown: {
applyButtonBackground: '#DADAE9',
applyButtonTextColor: '#FFFFFF',
},
},
};
const getAuthenticationToken = useCallback(async () => {
const token = await getIdTokenClaims();
return token?.__raw || '';
}, [getIdTokenClaims]);
const handleClickGoToMarketPlace = useCallback(async () => {
}, []);
const onEvent = (e:string)=>{
console.log("EVENT",e)
}
<MojitoCheckout
uri={ undefined }
apolloClient={ undefined }
userInfo: {
email: user?.email,
},
checkoutOptions={{
orgId: 'd086ea16-d40d-454c-84a4-64b5e940670a',
lotId: '17cd1000-323d-4a20-8e5f-7a8598ffae2a',
quantity: 1,
paymentId,
collectionItemId: '64e99437-ac2e-45bc-b4a6-4750985b4e81',
discountCode: 'ZZTO',
errorURL: `${window.location.origin}/payments/error`,
successURL: `${window.location.origin}/payments/success`,
}}
theme={ theme }
events={
onEvent:onEvent,
onCatch:onCatch,
onError:onError,
}
walletDetails={{
wallet: {
account: '0xAf464aFCe8820C8AbDb9271Cea8A76430b6bDD6',
chainId: 11155111,
connected: true,
balance: 0.2874,
providerType: 'Metamask',
},
saveWalletData: saveWalletData ,
onDisconnect:onDisconnect
}}
uiConfiguration={
global:{
logoSrc: require('./logo.svg),
loaderImageSrc: require('./loading.svg),
errorImageSrc: require('./error.svg),
}
billing: {
isEnableExpressCheckout: true,
gpay: true,
applepay: true,
walletConnect: true,
metaMask: true,
},
payment: {
creditCard: true,
gpay: true,
applepay: true,
walletConnect: true,
wire: true,
coinbase: true
},
costBreakdown: {
showDiscountCode: true
},
paymentConfirmation: {
onGoToMarketPlace: () => handleClickGoToMarketPlace(),
onGoTo: () => handleClickGoToMarketPlace(),
creditCardInstructions: (
<CreditCardInstructions email={user?.email ?? ""} />
),
metamaskInstructions: (
<MetamaskInstructions email={user?.email ?? ""} />
),
wireTransferInstructions: (
<WireTransferInstructions email={user?.email ?? ""} />
),
},
delivery: {
showConnectWallet:true,
creditCard: {
enableConnectWallet: true,
enableMultiSig: true,
checkoutApiKey: Configuration.CHECKOUT_API_KEY,
},
},
walletConnect: {
orgId: Configuration.ORGANIZATION_ID,
projectId: Configuration.PROJECT_ID,
paperClientId: Configuration.PAPER_CLIENT_ID,
isWeb2Login?: false; // if true it will work as web2 login (Auth0)
skipSignature?: false; // if true it will skip the signature process
},
walletOptions: {
enableEmail: false,
enableMetamask: true,
enableWalletConnect: true,
},
sardineConfig: {
sardineHost: Configuration.SardineHost,
sardineClientId: Configuration.sardineClientId,
sardineEnvironment: Configuration.sardineEnvironment,
};
}
enableSardine={false}
show={ show }
getAuthenticationToken={ getAuthenticationToken } />
Checkout Options
Address Validation & Tax Calculation with Vertex or TaxJar
If you'd like address to be validated and taxes to be calculated during the checkout process, particularly in the Billing
Information step, you need a Vertex or TaxJar account. Once you have it, you need to configure it in Mojito Mint.
Alternatively, set the following prop to disable those calls to the backend: vertexEnabled = false
.
<MojitoCheckout
checkoutOptions={{
orgId: 'd086ea16-d40d-454c-84a4-64b5e940670a',
lotId: '17cd1000-323d-4a20-8e5f-7a8598ffae2a',
quantity: 1,
paymentId: '<payment id>',
collectionItemId: '64e99437-ac2e-45bc-b4a6-4750985b4e81',
discountCode: 'ZZTO',
vertexEnabled: false,
}} />
Supported Countries
We use Checkout for payments, so the supported countries depend on which payment method is going to be used, as described here:
(Secret) Debug Mode
If you quickly click the logo in the top-right corner 16 times, the debug mode will be enabled (toggled, actually), even in production and regardless of
the initial value you passed for the debug
prop.
The debug mode will, among logging/displaying some other less relevant pieces of data:
Error page
Create an error page with the page path /payments/error
:
Success page
Create an success page with the page path /payments/success
:
Retrieve the paymentId
from the query parameters of the URL and pass it as a parameter to the MojitoCheckout
component
<MojitoCheckout
userInfo={{
email: 'Showrisrinivas@ionixxtech.com',
}}
checkoutOptions={{
paymentId,
}}
show
uiConfiguration={{
paymentConfirmation: {
onGoTo: onClickGoToMarketPlace,
},
}} />
Theme
You can use the themeOptions or theme props to pass a custom theme or theme options object:
themeOptions (preferred) will merge Mojito's default theme with your custom one
If none is provided, the default Mojito theme will be used.
const DefaultThemes: ThemeConfiguration = {
font: {
primary: 'Sneak',
secondary: 'Sneak',
},
color: {
primary: '#6663FD',
secondary: '#FFFFFF',
background: '#FAFAFC',
errorBackground: '#FEE3E5',
text: '#000000',
cardBackground: '#FFFFFF',
checkout: {
continueButtonBackground: '#6663FD',
continueButtonTextColor: '#FFFFFF',
},
placeholder: '#BABEC5',
costBreakdown: {
applyButtonBackground: '#DADAE9',
applyButtonTextColor: '#FFFFFF',
},
},
};
Note that using MUI's ThemeProvider from your project won't work as expected and you will end up seeing Mojito's default theme:
<MojitoCheckout theme={ theme }
Mixer development
Development setup