-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.ts
74 lines (68 loc) · 2.09 KB
/
checkout.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
interface Window {
FlutterwaveCheckout: (params: FlutterwavePayload) => void;
}
declare const FlutterwaveCheckout: (param: FlutterwavePayload) => void;
type FlutterwavePayload = {
public_key: string;
tx_ref: string;
amount: number;
currency: string;
payment_options: string;
meta: object;
payload_hash?: string;
customer: {
email: string;
name: string;
phone_number: string;
},
customizations: {
title: string;
description: string;
logo: string;
},
callback: (response: { status: string, tx_ref: string, id: number }) => void,
onclose: (is_payment_complete: boolean) => void
}
type FlutterwaveCheckoutFunction = (payload: FlutterwavePayload) => void
type FlutterwaveHashGeneratorFunction = (
amount: number,
currency: string,
email: string,
tx_ref: string,
secret_key: string
) => string
const generate_hash: FlutterwaveHashGeneratorFunction = (amount, currency, email, tx_ref, secret_key) => {
return ''
}
const paymentbutton = document.querySelector('button') as HTMLButtonElement;
paymentbutton.addEventListener('mousedown', () => {
FlutterwaveCheckout({
public_key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X",
tx_ref: "titanic-5394759348934985rdj",
amount:200,
currency: "NGN",
payload_hash: 'ae67f65421fa6db86663f2174f01025fee4dc74ebc136aa3721f326c4a42c366',
payment_options: "card, mobilemoneyghana, ussd",
// redirect_url: "https://glaciers.titanic.com/handle-flutterwave-payment",
meta: {
consumer_id: 23,
consumer_mac: "92a3-912ba-1192a",
},
customer: {
email: "johndoe@example.com",
phone_number: "08102909304",
name: "Rose DeWitt Bukater",
},
customizations: {
title: "Abraham's test",
description: "Order Payment",
logo: "",
},
callback: function (response) {
console.log(response);
},
onclose: function(incomplete) {
console.log(incomplete)
}
});
})