@flittpayments/js-sdk 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +178 -0
- package/dist/cjs/checkout.js +2377 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/checkout.js +2574 -0
- package/dist/umd/checkout.js +2 -0
- package/dist/umd/checkout.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 - present, Flitt JavaScript Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+

|
|
2
|
+
# Flitt JavaScript SDK
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/flitt-js-sdk)
|
|
5
|
+
[](https://www.npmjs.com/package/flitt-js-sdk)
|
|
6
|
+
[](https://github.com/flittpayments/flitt-js-sdk)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
### Node
|
|
11
|
+
|
|
12
|
+
If you’re using [Npm](https://npmjs.com/) in your project, you can add `@flittpayments/js-sdk` dependency to `package.json`
|
|
13
|
+
with following command:
|
|
14
|
+
|
|
15
|
+
```cmd
|
|
16
|
+
npm i --save @flittpayments/js-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or add dependency manually:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"dependency": {
|
|
24
|
+
"@flittpayments/js-sdk":"^1.2"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
### Manual installation
|
|
29
|
+
|
|
30
|
+
If you do not use NPM, you can download the
|
|
31
|
+
[latest release](https://github.com/flittpayments/flitt-js-sdk/releases).
|
|
32
|
+
Or clone from GitHub the latest developer version
|
|
33
|
+
```cmd
|
|
34
|
+
git clone git@github.com:flittpayments/js-sdk.git
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script src="https://unpkg.com/@flittpayments/js-sdk"></script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Basic template
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<!DOCTYPE html>
|
|
48
|
+
<html lang="en">
|
|
49
|
+
<head>
|
|
50
|
+
<meta charset="utf-8">
|
|
51
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
52
|
+
</head>
|
|
53
|
+
<body>
|
|
54
|
+
<script src="https://unpkg.com/@flittpayments/js-sdk"></script>
|
|
55
|
+
<script>
|
|
56
|
+
$checkout('Api').scope(function(){
|
|
57
|
+
this.request('api.checkout.form','request', { Parameters } ).done(function(model){
|
|
58
|
+
model.sendResponse();
|
|
59
|
+
console.log(model.attr('order'));
|
|
60
|
+
}).fail(function(model){
|
|
61
|
+
console.log(model.attr('error'));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## PaymentButton template (ApplePay/GooglePay)
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<!DOCTYPE html>
|
|
73
|
+
<html lang="en">
|
|
74
|
+
<head>
|
|
75
|
+
<meta charset="utf-8">
|
|
76
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<script src="https://unpkg.com/@flittpayments/js-sdk"></script>
|
|
80
|
+
<div class="payment-button-container"></div>
|
|
81
|
+
<script>
|
|
82
|
+
$checkout.get('PaymentButton', {
|
|
83
|
+
element: '.payment-button-container',
|
|
84
|
+
style: {
|
|
85
|
+
type: 'long', // short|long
|
|
86
|
+
color: 'black', // black|white
|
|
87
|
+
height: 38 // button height
|
|
88
|
+
},
|
|
89
|
+
data: { Parameters }
|
|
90
|
+
}).on('success', function(model) {
|
|
91
|
+
console.log('success', model);
|
|
92
|
+
}).on('error', function(model) {
|
|
93
|
+
console.log('error', model);
|
|
94
|
+
});
|
|
95
|
+
</script>
|
|
96
|
+
</body>
|
|
97
|
+
</html>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Parameters
|
|
101
|
+
|
|
102
|
+
### Host-to-host token
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"payment_system":"Supported payment systems: card, p24",
|
|
107
|
+
"token":"host-to-host generated token",
|
|
108
|
+
"card_number":"16/19-digits number",
|
|
109
|
+
"expiry_date":"Supported formats: MM/YY, MM/YYYY, MMYY, MMYYYY",
|
|
110
|
+
"cvv2":"3-digits number"
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Where token is value, returned in payment gateway response from API endpoint /api/checkout/token
|
|
115
|
+
(more details in API documentation: https://docs.flitt.com/api/create-order/ )
|
|
116
|
+
|
|
117
|
+
request example:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
curl -i -X POST \
|
|
121
|
+
-H "Content-Type:application/json" \
|
|
122
|
+
-d \
|
|
123
|
+
'{
|
|
124
|
+
"request": {
|
|
125
|
+
"server_callback_url": "http://myshop/callback/",
|
|
126
|
+
"order_id": "TestOrder1",
|
|
127
|
+
"currency": "USD",
|
|
128
|
+
"merchant_id": 1396424,
|
|
129
|
+
"order_desc": "Test payment",
|
|
130
|
+
"amount": 1000
|
|
131
|
+
}
|
|
132
|
+
}' \
|
|
133
|
+
'https://pay.flitt.com/api/checkout/token'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
response example:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"response": {
|
|
141
|
+
"response_status": "success",
|
|
142
|
+
"token": "7ddb3fbb03d60787b3972ef8d6fad0f97f7d2f86"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Client-side merchant ID
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"payment_system":"Supported payment systems: card, p24",
|
|
152
|
+
"merchant_id":"1396424",
|
|
153
|
+
"currency":"USD",
|
|
154
|
+
"amount":"100.20",
|
|
155
|
+
"card_number":"16/19-digits number",
|
|
156
|
+
"expiry_date":"Supported formats: MM/YY, MM/YYYY, MMYY, MMYYYY",
|
|
157
|
+
"cvv2":"3-digits number"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
optional merchant parameters:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"email":"customer email address",
|
|
166
|
+
"phone":"customer phone number"
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
## Usage example
|
|
170
|
+
|
|
171
|
+
https://jsfiddle.net/flitt/on8ydsgq/
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
License
|
|
176
|
+
Code released under [MIT LICENSE](https://github.com/flittpayments/flitt-js-sdk/blob/HEAD/LICENSE)
|
|
177
|
+
|
|
178
|
+
[](https://flitt.com/)
|