-
Notifications
You must be signed in to change notification settings - Fork 16
/
redeem.html
59 lines (50 loc) · 2.1 KB
/
redeem.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voucherify Redeem</title>
</head>
<body>
<form id="redeemForm">
<fieldset>
<legend>Redeem Voucher</legend>
<p><label>Voucher Code (eg. test_voucher_1)</label>
<input type="text" name="code" id="voucherCode">
</p>
<p><input type="submit" name="submit" value="Save"></p>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qs/6.5.1/qs.min.js" crossorigin></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/@voucherify/[email protected]/dist/voucherifysdk.umd.production.min.js" crossorigin></script>
<script>
const voucherify = VoucherifySDK.VoucherifyClientSide({
clientApplicationId: "158106cb-c95a-42e8-bc73-01ba34e2e756",
clientSecretKey: "c84aaea9-9f4a-47b3-a49f-4a5c4bd37964",
origin: "example.com"
});
voucherify.setIdentity("[email protected]");
const redeemVoucher = (e) => {
e.preventDefault();
const voucherCode = document.getElementById("voucherCode").value;
voucherify
voucherify
.redeem(voucherCode, {
order: {
amount: 1000,
items: [{ product_id: 'prod_Bi7sRr3kwvxH2I', sku_id: null, quantity: 1 }],
},
})
.then((result) => {
console.log(result);
})
.catch(console.error);
};
document
.getElementById("redeemForm")
.addEventListener("submit", redeemVoucher, false);
</script>
</body>
</html>