Created
March 19, 2020 15:36
-
-
Save waptik/775bd9c50c33567545c6ac0fbc118cbd to your computer and use it in GitHub Desktop.
Select preferred payment method based on user's location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paymentService, {paymentServiceType} from '@/services/paymentService' | |
import locationService, {locationServiceType} from '@/services/locationService' | |
// import paymentService from '@/services/paymentService' | |
const payWith: paymentServiceType = new paymentService() | |
export const locate: locationServiceType = new locationService() | |
// 2 letters country code | |
const ISO2: string = locate.getLocation().country(2) | |
export default () { | |
const isPayStack: boolean = payWith.payStackCountries.map( | |
(country: string) => ISO2 === country) | |
const isRavepay: boolean = payWith.ravepayCountries.map( | |
(country: string) => ISO2 === country) | |
// const isPaddle = !isPayStack && !isRavepay | |
if(isRavepay) return payWith.ravepay() | |
if(isPayStack) return payWith.payStack() | |
return payWith.paddle() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment