-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInAppPayments.js
More file actions
41 lines (37 loc) · 1.18 KB
/
InAppPayments.js
File metadata and controls
41 lines (37 loc) · 1.18 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
41
import React, {createContext, useContext, useState, useEffect} from 'react'
import useInAppPay from './use_in_app_pay'
const InAppPaymentContext = createContext({})
export default function InAppPayments(props) {
const {
iapReady,
iapSetup,
iapStart,
iapProcessing,
iapFinish,
iapReset,
iapProducts, // pricing in local currency available here
iapSubscriptions, // pricing in local currency available here
iapPurchase, // The last purchase can be used in case the payment timed out initially
iapError // The last error for displaying to the user
} = useInAppPay(props)
return (
<InAppPaymentContext.Provider value={{
iapReady,
iapSetup,
iapStart,
iapProcessing,
iapFinish,
iapReset,
iapProducts, // pricing in local currency available here
iapSubscriptions, // pricing in local currency available here
iapPurchase, // The last purchase can be used in case the payment timed out initially
iapError // The last error for displaying to the user
}}
>
{props.children}
</InAppPaymentContext.Provider>
)
}
export function useInAppPayments() {
return useContext(InAppPaymentContext)
}