forked from danielsogl/awesome-cordova-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
221 lines (214 loc) · 4.47 KB
/
index.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
export interface CkoCardTokenRequest {
/**
* The card number
*/
number: string;
/**
* The expiry month of the card
*/
expiry_month: string;
/**
* The expiry year of the card
*/
expiry_year: string;
/**
* The card verification value/code. 3 digits, except for Amex (4 digits)
*/
cvv?: string;
/**
* The cardholder's name
*/
name?: string;
/**
* The cardholder's billing address
*/
billing_address?: Address;
/**
* The cardholder's phone number
*/
phone?: Phone;
}
export interface CkoCardTokenResponse {
/**
* The token type
*/
type: string;
/**
* The token value
*/
token: string;
/**
* The expiration datetime of the token
*/
expires_on: string;
/**
* The expiry month of the card
*/
expiry_month: number;
/**
* The expiry year of the card
*/
expiry_year: number;
/**
* The cardholder's name
*/
name: string;
/**
* The card scheme
*/
scheme: string;
/**
* The last 4 digit of the card number
*/
last4: string;
/**
* The bin range of the card
*/
bin: string;
/**
* The card type
*/
card_type: string;
/**
* The card category
*/
card_category: string;
/**
* The card issuer name
*/
issuer: string;
/**
* The card issuer country (two-letter ISO)
*/
issuer_country: string;
/**
* The card product id
*/
product_id: string;
/**
* The card product type
*/
product_type: string;
/**
* The cardholder's billing address
*/
billing_address: Address;
/**
* The cardholder's phone number
*/
phone: Phone;
}
export interface Address {
/**
* The first line of the address
*/
address_line1?: string;
/**
* The second line of the address
*/
address_line2?: string;
/**
* The address city
*/
city?: string;
/**
* The address state
*/
state?: string;
/**
* The address zip/postal code
*/
zip?: string;
/**
* The two-letter ISO country code of the address
*/
country?: string;
}
export interface Phone {
/**
* The international country calling code. Required for some risk checks
*/
country_code: string;
/**
* The phone number
*/
number: string;
}
/**
* @name Checkout
* @description
* Checkout.com cordova plugin
*
* @usage
* ```typescript
* import { Checkout } from '@ionic-native/checkout/ngx';
*
*
* constructor(private checkout: Checkout) { }
*
* ...
*
*
* this.checkout.initSandboxClient("pk_test_7d395871-0d66-4b62-85b6-8424df78b125")
* .then(() => this.label = "CKO init completed")
* .catch(err => this.label = err)
*
* ...
*
* let tokenRequest: CkoCardTokenRequest = {
* number: "4543474002249996",
* cvv: "010",
* expiry_month: "08",
* expiry_year: "2025",
* billing_address: {
* country: "FR"
* }
* }
*
*
* this.cko.generateToken(tokenRequest)
* .then(tokenResponse => this.label = "Token: " + tokenResponse.token)
* .catch(err => this.label = err)
* ```
*/
@Plugin({
pluginName: 'Checkout',
plugin: '@checkout.com/cordova-plugin-checkout',
pluginRef: 'cordova.plugins.Checkout',
repo: 'https://github.com/checkout/frames-cordova',
install: '',
installVariables: [],
platforms: ['Android', 'iOS'],
})
@Injectable()
export class Checkout extends IonicNativePlugin {
/**
* Initialize Frames plugin in Sandbox mode
* @param publicKey {string} Merchant's sandbox public key
* @return {Promise<any>} Returns a promise that resolves when Frames initiation is completed
*/
@Cordova()
initSandboxClient(publicKey: string): Promise<any> {
return;
}
/**
* Initialize Frames plugin in Live mode
* @param publicKey {string} Merchant's live public key
* @return {Promise<any>} Returns a promise that resolves when Frames initiation is completed
*/
@Cordova()
initLiveClient(publicKey: string): Promise<any> {
return;
}
/**
* Exchange card details for a reference token that can be used later to request a card payment from your backend. Tokens are single use and expire after 15 minutes.
* @param ckoCardTokenRequest {CkoCardTokenRequest} Card tokenization request object
* @return {Promise<CkoCardTokenResponse>} Returns a promise that resolves when Token response object
*/
@Cordova()
generateToken(ckoCardTokenRequest: CkoCardTokenRequest): Promise<CkoCardTokenResponse> {
return;
}
}