-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathstripe-mock.js
103 lines (93 loc) · 2.46 KB
/
stripe-mock.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class StripeMock {
publishableKey;
options;
constructor(publishableKey, options) {
this.publishableKey = publishableKey;
this.options = options;
}
elements() {
return {
create() {
return {
mount() {},
on() {},
unmount() {},
};
}
};
}
redirectToCheckout() {}
confirmCardPayment() {}
confirmAlipayPayment() {}
confirmAuBecsDebitPayment() {}
confirmBancontactPayment() {}
confirmEpsPayment() {}
confirmFpxPayment() {}
confirmGiropayPayment() {}
confirmGrabPayPayment() {}
confirmIdealPayment() {}
confirmOxxoPayment() {}
confirmP24Payment() {}
confirmSepaDebitPayment() {}
confirmSofortPayment() {}
handleCardAction() {}
retrievePaymentIntent() {}
confirmCardSetup() {}
confirmAuBecsDebitSetup() {}
confirmBacsDebitSetup() {}
confirmBancontactSetup() {}
confirmIdealSetup() {}
confirmSepaDebitSetup() {}
confirmSofortSetup() {}
retrieveSetupIntent() {}
createPaymentMethod() {}
paymentRequest() {}
createToken() {}
createSource() {}
retrieveSource() {}
handleCardPayment() {}
confirmPaymentIntent() {}
handleCardSetup() {}
confirmSetupIntent() {}
handleFpxPayment() {}
}
const cardArgs = {
elementType: "card"
}
const baseArgs = {
...cardArgs,
"error": undefined,
"value": {
"postalCode": ""
},
"empty": true,
"complete": false,
"brand": "unknown"
}
const stripeError = {
message: "Your card number is invalid.",
type: "validation_error",
code: "invalid_number"
}
const argsError = {
...baseArgs,
error: stripeError,
"brand": "visa",
"value": {
"postalCode": "12345"
}
}
const argsComplete = {
...baseArgs,
"complete":true,
}
export const stripeEventUtils = {
triggerReady : function(stripeElement) { stripeElement._emitEvent('ready'), cardArgs},
triggerBlur : function(stripeElement) { stripeElement._emitEvent('blur', cardArgs)},
triggerFocus : function(stripeElement) { stripeElement._emitEvent('focus', cardArgs)},
triggerIncomplete: function(stripeElement) { stripeElement._emitEvent('change', baseArgs)},
triggerError : function(stripeElement, userArgs = {}) { stripeElement._emitEvent('change', {...argsError, ...userArgs})},
triggerComplete : function(stripeElement) { stripeElement._emitEvent('change', argsComplete)},
triggerChange : function(stripeElement, userArgs = {}) { stripeElement._emitEvent('change', {...baseArgs, ...userArgs})}
}
export default StripeMock;