boxpay-checkout-web-sdk 1.0.0-beta.2 → 1.0.0-beta.3
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/README.md +67 -76
- package/dist/boxpay-checkout-web-sdk.js +2 -1889
- package/dist/boxpay-checkout-web-sdk.js.LICENSE.txt +1 -0
- package/dist/boxpay.esm.js +2 -1847
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ A lightweight, secure, and customizable checkout experience for payments — bui
|
|
|
20
20
|
### Via CDN
|
|
21
21
|
|
|
22
22
|
```html
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/boxpay-checkout-js-sdk@1.0.0-beta.
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/boxpay-checkout-js-sdk@1.0.0-beta.2/dist/boxpay-checkout-js-sdk.min.js"></script>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Local Script
|
|
@@ -47,7 +47,7 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
47
47
|
### **HTML**
|
|
48
48
|
|
|
49
49
|
```html
|
|
50
|
-
<div id="payment-element"
|
|
50
|
+
<div id="payment-element"></div>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### **JS Integration**
|
|
@@ -55,13 +55,10 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
55
55
|
```html
|
|
56
56
|
<script>
|
|
57
57
|
const shopperDetails = {
|
|
58
|
-
dateOfBirth: null,
|
|
59
58
|
email: "example@boxpay.com",
|
|
60
59
|
firstName: "John",
|
|
61
60
|
lastName: "Doe",
|
|
62
|
-
|
|
63
|
-
uniqueReference: "reference123",
|
|
64
|
-
phoneNumber: "+919890990909",
|
|
61
|
+
phoneNumber: "+919999999999",
|
|
65
62
|
deliveryAddress: {
|
|
66
63
|
address1: "123 Main St",
|
|
67
64
|
address2: "Suite 1",
|
|
@@ -79,7 +76,7 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
79
76
|
async function mountBoxpayCheckout() {
|
|
80
77
|
checkoutInstance = await boxPay.elements({
|
|
81
78
|
container: "payment-element",
|
|
82
|
-
paymentMethods: ['card'],
|
|
79
|
+
paymentMethods: ['card'],
|
|
83
80
|
shopperDetails: shopperDetails,
|
|
84
81
|
mode: "development", // "production"
|
|
85
82
|
|
|
@@ -99,11 +96,11 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
99
96
|
|
|
100
97
|
options: {
|
|
101
98
|
payButton: {
|
|
102
|
-
show: false,
|
|
99
|
+
show: false,
|
|
103
100
|
onPaymentButtonValidity: handlePayButtonValidity,
|
|
104
101
|
},
|
|
105
102
|
},
|
|
106
|
-
onLoad: handlePaymentElementLoad,
|
|
103
|
+
onLoad: handlePaymentElementLoad // fires when payment element is loaded,
|
|
107
104
|
onPayment: handleOnPayment
|
|
108
105
|
});
|
|
109
106
|
}
|
|
@@ -111,11 +108,13 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
111
108
|
mountBoxpayCheckout();
|
|
112
109
|
|
|
113
110
|
function handlePaymentElementLoad(data) {
|
|
114
|
-
console.log(
|
|
111
|
+
console.log(data);
|
|
112
|
+
// Add logic of your pay button and when pay button is clicked
|
|
113
|
+
const resp = await checkoutInstance.initiatePayment();
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
function handleOnPayment(response) {
|
|
118
|
-
console.log(
|
|
117
|
+
console.log(response);
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
function handlePayButtonValidity(isValid) {
|
|
@@ -124,6 +123,63 @@ This method renders the checkout UI directly into a container on your webpage.
|
|
|
124
123
|
</script>
|
|
125
124
|
```
|
|
126
125
|
|
|
126
|
+
## 🧭 Shopper Details Format
|
|
127
|
+
| Property | Type | Required | Description |
|
|
128
|
+
| -------- | ---- | -------- | ----------- |
|
|
129
|
+
| `email` | `String` | Yes | Shopper’s email address |
|
|
130
|
+
| `firstName` | `String` | Yes | Shopper’s first name |
|
|
131
|
+
| `lastName` | `String` | Yes | Shopper’s last name |
|
|
132
|
+
| `phoneNumber` | `String` | Yes | Shopper’s mobile number including country code |
|
|
133
|
+
| `deliveryAddress` | `Object` | Yes | Delivery or billing address details |
|
|
134
|
+
| `deliveryAddress.address1` | `String` | Yes | Primary address line |
|
|
135
|
+
| `deliveryAddress.address2` | `String` | No | Secondary address line (apartment, suite, etc.) |
|
|
136
|
+
| `deliveryAddress.city` | `String` | Yes | City name |
|
|
137
|
+
| `deliveryAddress.state` | `String` | Yes | State or region |
|
|
138
|
+
| `deliveryAddress.countryCode` | `String` | Yes | ISO 2-letter country code<br>Example: `US`, `IN` |
|
|
139
|
+
| `deliveryAddress.postalCode` | `String` | Yes | ZIP or postal code |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 🎨 Appearance Customization
|
|
144
|
+
|
|
145
|
+
| Property | Type | Required | Description |
|
|
146
|
+
| -------- | ---- | -------- | ----------- |
|
|
147
|
+
| `appearance` | `Object` | No | Controls the visual styling of the checkout UI |
|
|
148
|
+
| `appearance.primaryColor` | `String` | No | Primary theme color used across the checkout UI |
|
|
149
|
+
| `appearance.secondaryColor` | `String` | No | Secondary color used for accents and highlights |
|
|
150
|
+
| `appearance.primaryTextColor` | `String` | No | Color for primary text elements |
|
|
151
|
+
| `appearance.secondaryTextColor` | `String` | No | Color for secondary or helper text |
|
|
152
|
+
| `appearance.payButton` | `Object` | No | Custom styling options for the Pay button |
|
|
153
|
+
| `appearance.payButton.borderRadius` | `String` | No | Border radius of the Pay button<br>Example: `"8px"` |
|
|
154
|
+
| `appearance.payButton.color` | `String` | No | Text color of the Pay button |
|
|
155
|
+
| `appearance.payButton.width` | `String` | No | Width of the Pay button<br>Example: `"100%"` |
|
|
156
|
+
| `appearance.payButton.fontSize` | `String` | No | Width of the Pay button<br>Example: `"1rem"` |
|
|
157
|
+
| `appearance.payButton.padding` | `String` | No | Width of the Pay button<br>Example: `"0.5rem 1rem"` |
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## ⚙ Options
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
options: {
|
|
166
|
+
payButton: {
|
|
167
|
+
show: false,
|
|
168
|
+
onPaymentButtonValidity: (isValid) => {},
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 📡 Callback Events
|
|
176
|
+
|
|
177
|
+
| Event | Required | Description |
|
|
178
|
+
| -------------------------| -------- | ------------------------------------------------------- |
|
|
179
|
+
| `onLoad` | Yes | Triggered when the checkout UI is mounted |
|
|
180
|
+
| `onPayment` | Yes | Triggered after payment success or failure |
|
|
181
|
+
| `onPaymentButtonValidity`| Yes, (only when show is false) | Called whenever the form becomes valid or invalid that helps your pay button to enable or disable click. |
|
|
182
|
+
|
|
127
183
|
---
|
|
128
184
|
|
|
129
185
|
# 2️⃣ Full-Page Hosted Checkout (In-site)
|
|
@@ -160,71 +216,6 @@ This automatically loads the checkout and triggers callbacks on success/cancel.
|
|
|
160
216
|
|
|
161
217
|
---
|
|
162
218
|
|
|
163
|
-
## 🧭 Shopper Details Format
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"email": "example@boxpay.com",
|
|
168
|
-
"firstName": "John",
|
|
169
|
-
"lastName": "Doe",
|
|
170
|
-
"panNumber": "ABCDE1234F",
|
|
171
|
-
"uniqueReference": "reference123",
|
|
172
|
-
"phoneNumber": "+919890990909",
|
|
173
|
-
"dateOfBirth": null,
|
|
174
|
-
"deliveryAddress": {
|
|
175
|
-
"address1": "123 Main St",
|
|
176
|
-
"address2": "Suite 1",
|
|
177
|
-
"city": "New York",
|
|
178
|
-
"state": "NY",
|
|
179
|
-
"countryCode": "US",
|
|
180
|
-
"postalCode": "10001"
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## 🎨 Appearance Customization
|
|
188
|
-
|
|
189
|
-
```js
|
|
190
|
-
appearance: {
|
|
191
|
-
primaryColor: "#ffd042",
|
|
192
|
-
secondaryColor: "#ff0000",
|
|
193
|
-
primaryTextColor: "#555",
|
|
194
|
-
secondaryTextColor: "#666",
|
|
195
|
-
payButton: {
|
|
196
|
-
borderRadius: "8px",
|
|
197
|
-
color: "#fff",
|
|
198
|
-
width: "100%"
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## ⚙ Options
|
|
206
|
-
|
|
207
|
-
```js
|
|
208
|
-
options: {
|
|
209
|
-
payButton: {
|
|
210
|
-
show: false,
|
|
211
|
-
onPaymentButtonValidity: (isValid) => {},
|
|
212
|
-
},
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## 📡 Callback Events
|
|
219
|
-
|
|
220
|
-
| Event | Description |
|
|
221
|
-
| ------------------------- | ------------------------------------------------------- |
|
|
222
|
-
| `onLoad` | Triggered when the checkout UI is mounted |
|
|
223
|
-
| `onPayment` | Triggered after payment success or failure |
|
|
224
|
-
| `onPaymentButtonValidity` | Called whenever the input form becomes valid or invalid |
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
219
|
## 🧪 Modes
|
|
229
220
|
|
|
230
221
|
```js
|