Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Optional for all following configuration
skipReceipt: false,
collectSignature: true,
allowSplitTender: false,
delayCapture: false,
note: 'Hello 💳 💰 World!',
tipSettings: {
showCustomTipField: true,
showSeparateTipScreen: false,
tipPercentages: [15, 20, 30],
},
additionalPaymentTypes: ['cash', 'manual_card_entry', 'other'],
};
try {
const checkoutResult = await startCheckoutAsync(checkoutParams);
// Consume checkout result from here
const currencyFormatter = this.props.globalize.getCurrencyFormatter(
checkoutResult.totalMoney.currencyCode,
{ minimumFractionDigits: 0, maximumFractionDigits: 2 },
);
const formattedCurrency = currencyFormatter(checkoutResult.totalMoney.amount / 100);
Alert.alert(`${formattedCurrency} Successfully Charged`, 'See the debugger console for transaction details. You can refund transactions from your Square Dashboard.');
console.log(JSON.stringify(checkoutResult));
} catch (ex) {
let errorMessage = ex.message;
switch (ex.code) {
case CheckoutErrorCanceled:
// Handle canceled transaction here
console.log('transaction canceled.');
break;
case CheckoutErrorSdkNotAuthorized: