UNPKG

react-native-paystack-payment

Version:

[![NPM](https://img.shields.io/npm/v/react-native-paystack-payment.svg)](https://www.npmjs.com/package/react-date-time-formatter) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ![react

68 lines (63 loc) 1.44 kB
export function cardNumberFormatter( oldValue, newValue, ) { // user is deleting so return without formatting if (oldValue.length > newValue.length) { return newValue; } return newValue .replace(/\W/gi, '') .replace(/(.{4})/g, '$1 ') .substring(0, 30); } export function expirationDateFormatter( oldValue, newValue, ) { // user is deleting so return without formatting if (oldValue.length > newValue.length) { return newValue; } return newValue .replace(/\W/gi, '') .replace(/(.{2})/g, '$1/') .substring(0, 5); } export function cvvFormatter( oldValue, newValue, ) { // user is deleting so return without formatting if (oldValue.length > newValue.length) { return newValue; } return newValue .replace(/\W/gi, '') .substring(0, 3); } export function currencyFormatter(cur,amount){ if(cur.toUpperCase() === "GHS"){ return { cur:"GHS", amount: parseInt(amount) * 100 } }else if(cur.toUpperCase() === "USD"){ return { cur:"USD", amount: parseInt(amount) * 100 } } else if(cur.toUpperCase() === "ZAR"){ return { cur:"ZAR", amount: parseInt(amount) * 100 } } else{ return { cur:"NGN", amount: parseInt(amount) * 100 } } }