-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativePayments.js
More file actions
40 lines (36 loc) · 1.16 KB
/
NativePayments.js
File metadata and controls
40 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, {createContext, useContext} from 'react'
import { Platform } from 'react-native'
import useNativePay from './use_native_pay' // This is going to be a problem if Apple makes us rip native payments out of our code again. The reason this is not a problem is because we started doing physical good purchases so Apple is okay with the native payment module.
const NativePaymentContext = createContext({})
export default function NativePayments(props) {
console.log('Platform.OS', Platform.OS)
// if (Platform.OS !== 'ios' && Platform.OS !== 'android') return (
// <></>
// )
const {
npReady,
npSetup,
npStart,
npProcessing,
npFinish,
npReset,
npFellback // Unable to use Google/Apple Pay, so asking directly for CC
} = useNativePay(props)
return (
<NativePaymentContext.Provider value={{
npReady,
npSetup,
npStart,
npProcessing,
npFinish,
npReset,
npFellback, // Unable to use Google/Apple Pay, so asking directly for CC
}}
>
{props.children}
</NativePaymentContext.Provider>
)
}
export function useNativePayments() {
return useContext(NativePaymentContext)
}