@strabl-engineering/strabl-pay 1.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/README.md +339 -0
- package/dist/components/strabl-card-form.element.d.ts +89 -0
- package/dist/components/strabl-input.element.d.ts +29 -0
- package/dist/constants/constants.d.ts +12 -0
- package/dist/font-assets.d.ts +7 -0
- package/dist/fonts.d.ts +16 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/icons.d.ts +16 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +33 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/lib/ApplePayIntegration.d.ts +23 -0
- package/dist/lib/EncryptCardData.d.ts +8 -0
- package/dist/lib/GetCardType.d.ts +26 -0
- package/dist/lib/GetTranslations.d.ts +50 -0
- package/dist/lib/ThreeDsAuth.d.ts +9 -0
- package/dist/lib/UserMetaData.d.ts +19 -0
- package/dist/lib/Validations.d.ts +1 -0
- package/dist/mount.d.ts +15 -0
- package/dist/network/HttpClient.d.ts +19 -0
- package/dist/network/PaymentService.d.ts +75 -0
- package/dist/network/ReportSdkUsage.d.ts +8 -0
- package/dist/react.d.ts +35 -0
- package/dist/react.js +26 -0
- package/dist/react.umd.cjs +1 -0
- package/dist/strabl-input.element-CbrtvlUF.cjs +1390 -0
- package/dist/strabl-input.element-DeXtiSuj.js +8173 -0
- package/dist/styles.d.ts +9 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Strabl PAY SDK
|
|
2
|
+
|
|
3
|
+
STRABL Pay SDK is the fastest way to embed secure, lightweight & PCI-DSS compliant card payments inside any website — providing a unified interface across modern web frameworks while keeping the payment experience smooth and seamless
|
|
4
|
+
|
|
5
|
+
For developers — Lightweight, framework-agnostic, and PCI-DSS compliant out of the box. Integrate in minutes, not days
|
|
6
|
+
For UI/UX designers — Every element is fully customizable. Match your checkout to your brand without any friction
|
|
7
|
+
For merchants & businesses — A unified, reliable payment experience that builds customer trust from the first transaction
|
|
8
|
+
|
|
9
|
+
## **Supported Frameworks:**
|
|
10
|
+
|
|
11
|
+
The STRABL Pay SDK is framework-agnostic and designed to integrate easily with a wide range of modern front-end technologies. It supports both module-based and script-based usage.
|
|
12
|
+
|
|
13
|
+
- **React**
|
|
14
|
+
- **Next.js**
|
|
15
|
+
- **Vue.js**
|
|
16
|
+
- **Angular**
|
|
17
|
+
- **Astro**
|
|
18
|
+
- **Laravel**
|
|
19
|
+
- **Plain JavaScript (ES6+)**
|
|
20
|
+
|
|
21
|
+
## **Installation:**
|
|
22
|
+
The STRABL STRABL Pay SDK can be installed and integrated using multiple methods depending on the project setup and preferred package manager.
|
|
23
|
+
|
|
24
|
+
**Using NPM:**
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @strabl-engineering/strabl-pay
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
**Using Yarn:**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
yarn add @strabl-engineering/strabl-pay
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Using CDN Script:**
|
|
38
|
+
|
|
39
|
+
Using jsDelivr CDN:
|
|
40
|
+
```html
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/@strabl-engineering/strabl-pay@latest/dist/index.js"></script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Using unpkg CDN:
|
|
45
|
+
```html
|
|
46
|
+
<script src="https://unpkg.com/@strabl-engineering/strabl-pay@latest/dist/index.js"></script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Supported Parameters
|
|
50
|
+
|
|
51
|
+
| Parameter | Type | Required | Description |
|
|
52
|
+
| :--- | :--- | :--- | :--- |
|
|
53
|
+
| `platformUuid` | `string` | **Yes** | Your unique platform identifier. |
|
|
54
|
+
| `apiKey` | `string` | **Yes** | Your public API key for authentication. You can create it from STRABL merchant dashboard |
|
|
55
|
+
| `currencyCode` | `string` | **Yes** | 3-letter ISO currency code (e.g., `"AED"`, `"SAR"`, `"USD"`). |
|
|
56
|
+
| `amount` | `number` | **Yes** | The total transaction amount to be charged. (e.g., `100`). |
|
|
57
|
+
| `language` | `"en" | "ar"` | Yes | Sets the display language. |
|
|
58
|
+
| `paymentMethods` | `PaymentMethod[]` | No | Array of allowed payment methods which will be shown to the cusotmer (e.g., ["card", "applepay"]). |
|
|
59
|
+
| `fieldInputStyle` | `"floating-label" | "outlined"` | No | Defines the visual style of the form input fields. |
|
|
60
|
+
| `customstyles` | `object` | No | Object containing the different properties to customize the UI. Full custom styles object is attached below |
|
|
61
|
+
| `customer` | `object` | No | Optional object containing customer name and email. |
|
|
62
|
+
| `onPaymentSubmission` | `() => Promise<boolean>` | No | Callback triggered before submission; return true to proceed. You can add your required validations here. If retruned false, it will not proceed to the payment submission.|
|
|
63
|
+
| `onPaymentSuccess` | `(orderShortCode: string) => void` | No | Callback triggered after a successful transaction. It will return STRABL order short code which you can store. |
|
|
64
|
+
| `onPaymentFailed` | `(failureReason: string) => void` | No | Callback triggered when a payment fails or is declined. It will return failure reason.|
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Customization Styles (customstyles)
|
|
68
|
+
You can pass the following properties within the customstyles object to match your brand's identity:
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Description |
|
|
71
|
+
| :--- | :--- | :--- |
|
|
72
|
+
| `textColor` | `string` | Sets the color for labels and standard text. |
|
|
73
|
+
| `errorColor` | `string` | Sets the color for validation and transaction error messages. |
|
|
74
|
+
| `accentColor` | `string` | Sets the primary color for buttons and active states. |
|
|
75
|
+
| `backgroundColor` | `string` | Sets the background color of the form container. |
|
|
76
|
+
| `btnRadius` | `string` | Sets the border-radius for the submit button (e.g., "4px"). |
|
|
77
|
+
| `btnPadding` | `string` | Sets the internal padding for the submit button. |
|
|
78
|
+
| `inputRadius` | `string` | Sets the border-radius for the input fields. |
|
|
79
|
+
| `inputBorderColor` | `string` | Sets the color of the input field borders. |
|
|
80
|
+
| `inputBorderWidth` | `string` | Sets the thickness of the input borders (e.g., "1px"). |
|
|
81
|
+
| `continerMaxWidth` | `string` | Limits the maximum width of the form container. |
|
|
82
|
+
| `fontFamily` | `string` | Sets the font stack for the entire component. |
|
|
83
|
+
|
|
84
|
+
In order to submit the payment, publish a custom `strabl-submit-card-form` event from your JavaScript code. The SDK will listen for this event and trigger the payment process.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
window.dispatchEvent(new CustomEvent("strabl-submit-card-form"));
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Events and Callbacks
|
|
91
|
+
The component provides two ways to handle transaction outcomes: Callbacks (props/properties) and Standard DOM Events. While both serve the same purpose, DOM events are particularly useful in Vanilla JS and Angular for decoupling logic.
|
|
92
|
+
|
|
93
|
+
#### 1. Payment Success
|
|
94
|
+
Triggered when the transaction is successfully authorized and completed.
|
|
95
|
+
|
|
96
|
+
- **Callback** (`onPaymentSuccess`): A function property that receives the orderShortCode as a string.
|
|
97
|
+
- **DOM Event** (`strablPaymentSuccess`): A standard event dispatched by the component. The orderShortCode is accessible via event.detail.
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
// Example using Event Listener
|
|
101
|
+
paymentForm.addEventListener("strablPaymentSuccess", (event) => {
|
|
102
|
+
console.log("Order Code:", event.detail);
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### 2. Payment Failed
|
|
107
|
+
Triggered when the payment is declined, cancelled, or encounters a processing error.
|
|
108
|
+
|
|
109
|
+
- **Callback** (`onPaymentFailed`): A function property that receives a failureReason string (e.g., "Insufficient funds" or "Invalid CVV").
|
|
110
|
+
- **DOM Event** (`strablPaymentFailed`): A standard event dispatched by the component. The failure reason is accessible via event.detail.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
// Example using Event Listener
|
|
114
|
+
paymentForm.addEventListener("strablPaymentFailed", (event) => {
|
|
115
|
+
console.error("Failure Reason:", event.detail);
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Usage
|
|
120
|
+
|
|
121
|
+
### 1. React
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { StrablCardPaymentForm } from "@strabl-engineering/strabl-pay/react";
|
|
125
|
+
|
|
126
|
+
export function Checkout() {
|
|
127
|
+
return (
|
|
128
|
+
<StrablCardPaymentForm
|
|
129
|
+
platformUuid="YOUR_PLATFORM_UUID"
|
|
130
|
+
apiKey="YOUR_PUBLIC_API_KEY"
|
|
131
|
+
amount={100}
|
|
132
|
+
language="en" // "en" or "ar"
|
|
133
|
+
currencyCode='AED'
|
|
134
|
+
paymentMethods={["card", "applepay"]}
|
|
135
|
+
onPaymentSubmission={async () => {
|
|
136
|
+
console.log("Submit Payment clicked");
|
|
137
|
+
// Perform any necessary validation or actions before submitting the payment form.
|
|
138
|
+
// Return true to proceed with the payment submission, or false to prevent it.
|
|
139
|
+
return true;
|
|
140
|
+
}}
|
|
141
|
+
fieldInputStyle='floating-label' // outlined or floating-label
|
|
142
|
+
onPaymentSuccess={(strablOrderShortCode) => {
|
|
143
|
+
// Handle post-payment success actions, such as displaying a confirmation message or redirecting the user.
|
|
144
|
+
console.log("Payment successful! Strabl Order short code:", strablOrderShortCode);
|
|
145
|
+
}}
|
|
146
|
+
onPaymentFailed={(failureReason) => {
|
|
147
|
+
// Handle post-payment failure actions, such as displaying a error message.
|
|
148
|
+
console.log("Payment Failed! reason:", failureReason);
|
|
149
|
+
}}
|
|
150
|
+
customer={{
|
|
151
|
+
email: "",
|
|
152
|
+
name: ""
|
|
153
|
+
}}
|
|
154
|
+
customstyles={{
|
|
155
|
+
textColor: "#3a3a3a",
|
|
156
|
+
accentColor: "#000000cc",
|
|
157
|
+
backgroundColor: "#ffffff",
|
|
158
|
+
btnPadding: "10px 16px",
|
|
159
|
+
btnRadius: "4px",
|
|
160
|
+
continerMaxWidth: "500px",
|
|
161
|
+
fontFamily: "'GT-America', sans-serif",
|
|
162
|
+
errorColor: "#ff485c",
|
|
163
|
+
inputBorderColor: "#0000003b",
|
|
164
|
+
inputBorderWidth: "1px",
|
|
165
|
+
inputRadius: "4px",
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
If you are using TypeScript, you can import the types for better type safety in your vite-env.d.ts or any declaration file:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
/// <reference types="vite/client" />
|
|
176
|
+
import { StrablCardFormProps } from "@strabl-engineering/strabl-pay/react";
|
|
177
|
+
|
|
178
|
+
declare module "react" {
|
|
179
|
+
namespace JSX {
|
|
180
|
+
interface IntrinsicElements {
|
|
181
|
+
StrablCardPaymentForm: StrablCardFormProps;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
### 2. Angular
|
|
189
|
+
|
|
190
|
+
In your `AppModule` (for NgModule-based apps) or in your `Component` (for Standalone apps), add the `CUSTOM_ELEMENTS_SCHEMA`.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
|
194
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
195
|
+
import { AppComponent } from './app.component';
|
|
196
|
+
import '@strabl-engineering/strabl-pay'; // Import the web component loader
|
|
197
|
+
|
|
198
|
+
@NgModule({
|
|
199
|
+
declarations: [AppComponent],
|
|
200
|
+
imports: [BrowserModule],
|
|
201
|
+
providers: [],
|
|
202
|
+
bootstrap: [AppComponent],
|
|
203
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA] // Allows using 'strabl-card-payment-form'
|
|
204
|
+
})
|
|
205
|
+
export class AppModule { }
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Step 2: Component Logic
|
|
209
|
+
Define your configuration and handlers in your TypeScript file.
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { Component } from '@angular/core';
|
|
213
|
+
|
|
214
|
+
@Component({
|
|
215
|
+
selector: 'app-checkout',
|
|
216
|
+
templateUrl: './checkout.component.html'
|
|
217
|
+
})
|
|
218
|
+
export class CheckoutComponent {
|
|
219
|
+
config = {
|
|
220
|
+
platformUuid: "YOUR_PLATFORM_UUID",
|
|
221
|
+
apiKey: "YOUR_PUBLIC_API_KEY",
|
|
222
|
+
amount: 100,
|
|
223
|
+
currencyCode: 'AED',
|
|
224
|
+
language: 'en',
|
|
225
|
+
paymentMethods: ["card", "applepay"],
|
|
226
|
+
fieldInputStyle: 'floating-label',
|
|
227
|
+
customer: { email: "", name: "" },
|
|
228
|
+
styles: {
|
|
229
|
+
textColor: "#3a3a3a",
|
|
230
|
+
accentColor: "#000000cc",
|
|
231
|
+
backgroundColor: "#ffffff",
|
|
232
|
+
btnPadding: "10px 16px",
|
|
233
|
+
btnRadius: "4px",
|
|
234
|
+
continerMaxWidth: "500px",
|
|
235
|
+
fontFamily: "'GT-America', sans-serif",
|
|
236
|
+
errorColor: "#ff485c",
|
|
237
|
+
inputBorderColor: "#0000003b",
|
|
238
|
+
inputBorderWidth: "1px",
|
|
239
|
+
inputRadius: "4px",
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
async handleSubmission() {
|
|
244
|
+
console.log("Submit Payment clicked");
|
|
245
|
+
return true; // Return true to proceed
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onSuccess(event: any) {
|
|
249
|
+
// Web components dispatch custom events, details are in event.detail
|
|
250
|
+
console.log("Payment successful!", event.detail);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
onFailed(event: any) {
|
|
254
|
+
console.log("Payment Failed!", event.detail);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
#### Step 3: Template Usage
|
|
261
|
+
Use property binding [] for inputs and event binding () for outputs. Note that Web Components often use standard kebab-case or the specific event names defined in the library.
|
|
262
|
+
|
|
263
|
+
```html
|
|
264
|
+
<strabl-card-payment-form
|
|
265
|
+
[platformUuid]="config.platformUuid"
|
|
266
|
+
[apiKey]="config.apiKey"
|
|
267
|
+
[amount]="config.amount"
|
|
268
|
+
[currencyCode]="config.currencyCode"
|
|
269
|
+
[language]="config.language"
|
|
270
|
+
[paymentMethods]="config.paymentMethods"
|
|
271
|
+
[fieldInputStyle]="config.fieldInputStyle"
|
|
272
|
+
[customer]="config.customer"
|
|
273
|
+
[customstyles]="config.styles"
|
|
274
|
+
(strablPaymentSuccess)="onSuccess($event)"
|
|
275
|
+
(strablPaymentFailed)="onFailed($event)">
|
|
276
|
+
</strabl-card-payment-form>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 3. Plain HTML / JavaScript
|
|
280
|
+
|
|
281
|
+
```html
|
|
282
|
+
<!DOCTYPE html>
|
|
283
|
+
<html lang="en">
|
|
284
|
+
<head>
|
|
285
|
+
<meta charset="UTF-8">
|
|
286
|
+
<title>Strabl Checkout</title>
|
|
287
|
+
<!-- Load the SDK -->
|
|
288
|
+
<script type="module" src="https://unpkg.com/@strabl-engineering/strabl-pay@latest/dist/index.js"></script>
|
|
289
|
+
</head>
|
|
290
|
+
<body>
|
|
291
|
+
|
|
292
|
+
<!-- Use the custom tag directly -->
|
|
293
|
+
<strabl-card-payment-form id="strabl-form"></strabl-card-payment-form>
|
|
294
|
+
|
|
295
|
+
<script type="module">
|
|
296
|
+
const form = document.getElementById('strabl-form');
|
|
297
|
+
|
|
298
|
+
// Set properties
|
|
299
|
+
form.platformUuid = "YOUR_PLATFORM_UUID";
|
|
300
|
+
form.apiKey = "YOUR_PUBLIC_API_KEY";
|
|
301
|
+
form.amount = 100;
|
|
302
|
+
form.currencyCode = "AED";
|
|
303
|
+
form.language = "en";
|
|
304
|
+
form.paymentMethods = ["card", "applepay"];
|
|
305
|
+
form.fieldInputStyle = "floating-label";
|
|
306
|
+
|
|
307
|
+
form.customstyles = {
|
|
308
|
+
textColor: "#3a3a3a",
|
|
309
|
+
accentColor: "#000000cc",
|
|
310
|
+
backgroundColor: "#ffffff",
|
|
311
|
+
btnPadding: "10px 16px",
|
|
312
|
+
btnRadius: "4px",
|
|
313
|
+
continerMaxWidth: "500px",
|
|
314
|
+
fontFamily: "'GT-America', sans-serif",
|
|
315
|
+
errorColor: "#ff485c",
|
|
316
|
+
inputBorderColor: "#0000003b",
|
|
317
|
+
inputBorderWidth: "1px",
|
|
318
|
+
inputRadius: "4px",
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// Listen for events
|
|
322
|
+
form.addEventListener('strablPaymentSuccess', (event) => {
|
|
323
|
+
console.log("Success! Order Code:", event.detail);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
form.addEventListener('strablPaymentFailed', (event) => {
|
|
327
|
+
console.error("Failed! Reason:", event.detail);
|
|
328
|
+
});
|
|
329
|
+
</script>
|
|
330
|
+
</body>
|
|
331
|
+
</html>
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
In order to submit the payment, publish a custom `strabl-submit-card-form` event from your JavaScript code. The SDK will listen for this event and trigger the payment process.
|
|
335
|
+
|
|
336
|
+
```js
|
|
337
|
+
window.dispatchEvent(new CustomEvent("strabl-submit-card-form"));
|
|
338
|
+
```
|
|
339
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { ThreeDsAuth } from "../lib/ThreeDsAuth";
|
|
3
|
+
export type PaymentMethod = "card" | "applepay";
|
|
4
|
+
export interface StrablCardFormProps {
|
|
5
|
+
paymentMethods?: PaymentMethod[];
|
|
6
|
+
fieldInputStyle?: "floating-label" | "outlined";
|
|
7
|
+
platformUuid: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
currencyCode: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
language: "en" | "ar";
|
|
12
|
+
customstyles?: {
|
|
13
|
+
textColor?: string;
|
|
14
|
+
errorColor?: string;
|
|
15
|
+
btnRadius?: string;
|
|
16
|
+
btnPadding?: string;
|
|
17
|
+
backgroundColor?: string;
|
|
18
|
+
accentColor?: string;
|
|
19
|
+
continerMaxWidth?: string;
|
|
20
|
+
inputRadius?: string;
|
|
21
|
+
inputBorderColor?: string;
|
|
22
|
+
inputBorderWidth?: string;
|
|
23
|
+
fontFamily?: string;
|
|
24
|
+
};
|
|
25
|
+
customer?: {
|
|
26
|
+
name?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
};
|
|
29
|
+
onPaymentSubmission?: () => Promise<boolean>;
|
|
30
|
+
onPaymentSuccess?: (orderShortCode: string) => void;
|
|
31
|
+
onPaymentFailed?: (failureReason: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare class StrablCardForm extends LitElement {
|
|
34
|
+
static styles: import("lit").CSSResult;
|
|
35
|
+
paymentMethods: Array<"card" | "applepay">;
|
|
36
|
+
platformUuid: string;
|
|
37
|
+
apiKey: string;
|
|
38
|
+
currencyCode: string;
|
|
39
|
+
amount: number;
|
|
40
|
+
language: "en" | "ar";
|
|
41
|
+
fieldInputStyle: "floating-label" | "outlined";
|
|
42
|
+
customstyles: any;
|
|
43
|
+
customer: any;
|
|
44
|
+
onPaymentSubmission?: () => Promise<boolean>;
|
|
45
|
+
onPaymentSuccess?: (orderShortCode: string) => void;
|
|
46
|
+
onPaymentFailed?: (failureReason: string) => void;
|
|
47
|
+
private cardNumber;
|
|
48
|
+
private cardHolderName;
|
|
49
|
+
private expiry;
|
|
50
|
+
private cvc;
|
|
51
|
+
private cardType;
|
|
52
|
+
private translations;
|
|
53
|
+
private isSubmitting;
|
|
54
|
+
private errors;
|
|
55
|
+
private errorMessage;
|
|
56
|
+
private _isReady;
|
|
57
|
+
private _resolveReady;
|
|
58
|
+
private httpClient?;
|
|
59
|
+
private paymentServiceClient?;
|
|
60
|
+
private applePayInstance;
|
|
61
|
+
private reportSdkUsageClient?;
|
|
62
|
+
threeDsAuth: ThreeDsAuth;
|
|
63
|
+
constructor();
|
|
64
|
+
connectedCallback(): void;
|
|
65
|
+
disconnectedCallback(): void;
|
|
66
|
+
private updateServices;
|
|
67
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
68
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
69
|
+
private get paymentService();
|
|
70
|
+
private updateCardType;
|
|
71
|
+
private handleExternalSubmit;
|
|
72
|
+
validateCardNumber(): boolean;
|
|
73
|
+
validateCardExpiry(): boolean;
|
|
74
|
+
validateCVC(): boolean;
|
|
75
|
+
validateCardHolderName(): boolean;
|
|
76
|
+
handleSubmit(e?: Event): Promise<void>;
|
|
77
|
+
private handleThreeDsAuthCompletion;
|
|
78
|
+
private removeUrlParam;
|
|
79
|
+
private checkForThreeDsAuthRedirect;
|
|
80
|
+
private notifySuccess;
|
|
81
|
+
private notifyFailure;
|
|
82
|
+
private isApplePaySupported;
|
|
83
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
84
|
+
}
|
|
85
|
+
declare global {
|
|
86
|
+
interface HTMLElementTagNameMap {
|
|
87
|
+
"strabl-card-form": StrablCardForm;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export declare class StrablInput extends LitElement {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
type: "cardNumber" | "name" | "expiry" | "cvv" | "missingCardNumber";
|
|
7
|
+
error?: string;
|
|
8
|
+
maxLength: number;
|
|
9
|
+
gaps: number[];
|
|
10
|
+
lengths: number[];
|
|
11
|
+
firstSixPresent: boolean;
|
|
12
|
+
firstSixDigits: string;
|
|
13
|
+
lastFourDigits: string;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
fieldInputStyle: "floating-label" | "outlined";
|
|
16
|
+
private isDeleting;
|
|
17
|
+
protected createRenderRoot(): this;
|
|
18
|
+
private handleKeyDown;
|
|
19
|
+
private handleInputChange;
|
|
20
|
+
private formatCardNumber;
|
|
21
|
+
private formatExpiryDate;
|
|
22
|
+
private handlePaste;
|
|
23
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface HTMLElementTagNameMap {
|
|
27
|
+
"strabl-input": StrablInput;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const BASE_API_URL: {
|
|
2
|
+
sandbox: string;
|
|
3
|
+
prod: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const GENERATE_CARD_TOKEN_API = "/v1/api/direct/tokenize";
|
|
6
|
+
export declare const INTENTION_TO_PAY_API = "/v1/api/direct/intent-to-pay";
|
|
7
|
+
export declare const CONFIRM_PAYMENT_API = "/v1/api/direct/pay";
|
|
8
|
+
export declare const CREATE_APPLE_PAY_SESSION_API = "/v1/api/direct/session";
|
|
9
|
+
export declare const REPORT_USAGE_API = "/v2/public/api/t";
|
|
10
|
+
export declare const PLATFORM_UUID_HEADER_KEY = "X-PLATFORM-KEY";
|
|
11
|
+
export declare const CARD_ENCRYPTION_KEY_SANDBOX = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvhwrT7LnpNhR8GRgnew5MTHVVvSrp4Ts12VV5Ahgj8y1B9i28e4HLKC/bzZxbsaZe+J7m3Wn4fUPs2zuN1SiYhI4nV+Vs+bfGtmnbkdlNYZCEAq7sMbxP1PeZsI/vROW4la7SJ49K/lOXKj5QTOjvkpu8CleHToYXO0VpAFlbRwkY5+rGa7YBnlyRnISNp+vxfHQjJk4C/PeThaOx4IFIf/HeooZw01h1demPNpxBzjvK5NSBN0ap8Aa0YfAoORdNj7DN3WePIPP+f9HUDlQzV0DlApipF8uGDo3H0TBkr5OPcVlDO5VKCmcJktAXqsAA18qRTDL0qOFI2Jq57JxfQIDAQAB\n-----END PUBLIC KEY-----";
|
|
12
|
+
export declare const CARD_ENCRYPTION_KEY_PROD = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk5GvG6PDVnTpboz2t/1SRR9fKWdccsQV1CNl5g0tW/SfbqvIAmgH2WK+e8Wj3JFMP3q6UbkB9hTrrbdnI1IlJ8kwMm1kvSlTbFQZr1NIFbIUm5Q6N6xVASEfFSRjNVa8fhhpcCz4SVKYLsXKC0HViF16oFmVoCl8m5XC2Wir7UpWHpWJRQ2Vho2u1Nl7Q8O1HZHfmfwEfz3c9+cuwVY4g7TPptDz5BXC8j5bPcc0MeRRplqGwpGXP/D+xr3ir8BXCV7U3IqdY2Ajqt/avXHC weWvRkEhPTIcPxgsvtGE29soWS4pw9pqpIMXoFVnxgpHVRVPyOsD2haPd8jTj9BR4QIDAQAB\n-----END PUBLIC KEY-----";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import gtAmericaRegularUrl from "./fonts/gtAmericaRegular.woff?inline";
|
|
2
|
+
import gtAmericaMediumUrl from "./fonts/GT-America-Medium.otf?inline";
|
|
3
|
+
import gtAmericaLightUrl from "./fonts/GT-America-Light.otf?inline";
|
|
4
|
+
import gtAmericaThinUrl from "./fonts/GT-America-Thin.otf?inline";
|
|
5
|
+
import gtAmericaBoldUrl from "./fonts/gtAmericaBold.woff?inline";
|
|
6
|
+
import gtAmericaBoldItalicUrl from "./fonts/gtAmericaBoldItalic.woff?inline";
|
|
7
|
+
export { gtAmericaRegularUrl, gtAmericaMediumUrl, gtAmericaBoldItalicUrl, gtAmericaBoldUrl, gtAmericaLightUrl, gtAmericaThinUrl, };
|
package/dist/fonts.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface FontConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Optional base URL where the gtAmerica font files are hosted.
|
|
4
|
+
* If provided, the @font-face rules will include `url(...)` sources
|
|
5
|
+
* resolving to `${baseUrl}/<file>`.
|
|
6
|
+
*/
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/**
|
|
9
|
+
* If true (default), also injects a Google Fonts <link> for Inter as
|
|
10
|
+
* a free fallback so the component renders with a proper humanist
|
|
11
|
+
* sans-serif when the gtAmerica family is not available.
|
|
12
|
+
*/
|
|
13
|
+
injectFallback?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function configureFonts(config: FontConfig): void;
|
|
16
|
+
export declare function injectGlobalFonts(): void;
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Language = "en" | "ar";
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const visaIcon: import("lit-html").TemplateResult<2>;
|
|
2
|
+
export declare const mastercardIcon: import("lit-html").TemplateResult<2>;
|
|
3
|
+
export declare const amexIcon: import("lit-html").TemplateResult<2>;
|
|
4
|
+
export declare const unionpayIcon: import("lit-html").TemplateResult<2>;
|
|
5
|
+
export declare const jcbIcon: import("lit-html").TemplateResult<2>;
|
|
6
|
+
export declare const discoverIcon: import("lit-html").TemplateResult<2>;
|
|
7
|
+
export declare const dinersIcon: import("lit-html").TemplateResult<2>;
|
|
8
|
+
export declare const genericCardIcon: import("lit-html").TemplateResult<2>;
|
|
9
|
+
export declare function cardIconFor(typeKey: string | undefined): import("lit-html").TemplateResult<2> | undefined;
|
|
10
|
+
export declare const applePayIcon: import("lit-html").TemplateResult<2>;
|
|
11
|
+
export declare const pciDssIcon: import("lit-html").TemplateResult<2>;
|
|
12
|
+
export declare const sslIcon: import("lit-html").TemplateResult<2>;
|
|
13
|
+
export declare const strablLogo: import("lit-html").TemplateResult<2>;
|
|
14
|
+
export declare const iconWrappers: {
|
|
15
|
+
html: (strings: TemplateStringsArray, ...values: unknown[]) => import("lit-html").TemplateResult<1>;
|
|
16
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StrablCardForm } from "./components/strabl-card-form.element";
|
|
2
|
+
import { StrablInput } from "./components/strabl-input.element";
|
|
3
|
+
export { StrablCardForm, StrablInput };
|
|
4
|
+
export { configureFonts, injectGlobalFonts } from "./fonts.js";
|
|
5
|
+
export { mountCardForm } from "./mount.js";
|
|
6
|
+
export type { MountOptions, MountedCardForm } from "./mount.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { S as a, a as o } from "./strabl-input.element-DeXtiSuj.js";
|
|
2
|
+
import { c as l, i as s } from "./strabl-input.element-DeXtiSuj.js";
|
|
3
|
+
function c(t) {
|
|
4
|
+
if (typeof document > "u")
|
|
5
|
+
throw new Error(
|
|
6
|
+
"mountCardForm can only be called in a browser environment"
|
|
7
|
+
);
|
|
8
|
+
customElements.get("strabl-card-form") || customElements.define("strabl-card-form", a);
|
|
9
|
+
const r = document.querySelector(t.selector);
|
|
10
|
+
if (!r)
|
|
11
|
+
throw new Error(
|
|
12
|
+
`mountCardForm: no element matched selector "${t.selector}"`
|
|
13
|
+
);
|
|
14
|
+
const n = document.createElement("strabl-card-form"), m = (e) => {
|
|
15
|
+
e.platformUuid !== void 0 && (n.platformUuid = e.platformUuid), e.apiKey !== void 0 && (n.apiKey = e.apiKey), e.currencyCode !== void 0 && (n.currencyCode = e.currencyCode), e.amount !== void 0 && (n.amount = e.amount), e.language !== void 0 && (n.language = e.language), e.paymentMethods !== void 0 && (n.paymentMethods = e.paymentMethods), e.customstyles !== void 0 && (n.customstyles = e.customstyles), e.customer !== void 0 && (n.customer = e.customer), e.onPaymentSubmission !== void 0 && (n.onPaymentSubmission = e.onPaymentSubmission), e.onPaymentSuccess !== void 0 && (n.onPaymentSuccess = e.onPaymentSuccess), e.onPaymentFailed !== void 0 && (n.onPaymentFailed = e.onPaymentFailed);
|
|
16
|
+
};
|
|
17
|
+
return m(t), t.replace ? r.replaceChildren(n) : r.appendChild(n), {
|
|
18
|
+
element: n,
|
|
19
|
+
update: (e) => m(e),
|
|
20
|
+
submit: () => {
|
|
21
|
+
window.dispatchEvent(new CustomEvent("strabl-submit-card-form"));
|
|
22
|
+
},
|
|
23
|
+
destroy: () => n.remove()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
typeof customElements < "u" && (customElements.get("strabl-card-form") || customElements.define("strabl-card-form", a), customElements.get("strabl-input") || customElements.define("strabl-input", o));
|
|
27
|
+
export {
|
|
28
|
+
a as StrablCardForm,
|
|
29
|
+
o as StrablInput,
|
|
30
|
+
l as configureFonts,
|
|
31
|
+
s as injectGlobalFonts,
|
|
32
|
+
c as mountCardForm
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./strabl-input.element-CbrtvlUF.cjs");function m(r){if(typeof document>"u")throw new Error("mountCardForm can only be called in a browser environment");customElements.get("strabl-card-form")||customElements.define("strabl-card-form",n.StrablCardForm);const o=document.querySelector(r.selector);if(!o)throw new Error(`mountCardForm: no element matched selector "${r.selector}"`);const t=document.createElement("strabl-card-form"),a=e=>{e.platformUuid!==void 0&&(t.platformUuid=e.platformUuid),e.apiKey!==void 0&&(t.apiKey=e.apiKey),e.currencyCode!==void 0&&(t.currencyCode=e.currencyCode),e.amount!==void 0&&(t.amount=e.amount),e.language!==void 0&&(t.language=e.language),e.paymentMethods!==void 0&&(t.paymentMethods=e.paymentMethods),e.customstyles!==void 0&&(t.customstyles=e.customstyles),e.customer!==void 0&&(t.customer=e.customer),e.onPaymentSubmission!==void 0&&(t.onPaymentSubmission=e.onPaymentSubmission),e.onPaymentSuccess!==void 0&&(t.onPaymentSuccess=e.onPaymentSuccess),e.onPaymentFailed!==void 0&&(t.onPaymentFailed=e.onPaymentFailed)};return a(r),r.replace?o.replaceChildren(t):o.appendChild(t),{element:t,update:e=>a(e),submit:()=>{window.dispatchEvent(new CustomEvent("strabl-submit-card-form"))},destroy:()=>t.remove()}}typeof customElements<"u"&&(customElements.get("strabl-card-form")||customElements.define("strabl-card-form",n.StrablCardForm),customElements.get("strabl-input")||customElements.define("strabl-input",n.StrablInput));Object.defineProperty(exports,"StrablCardForm",{enumerable:!0,get:()=>n.StrablCardForm});Object.defineProperty(exports,"StrablInput",{enumerable:!0,get:()=>n.StrablInput});exports.configureFonts=n.configureFonts;exports.injectGlobalFonts=n.injectGlobalFonts;exports.mountCardForm=m;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PaymentService } from "../network/PaymentService";
|
|
2
|
+
export declare class ApplePayIntegration {
|
|
3
|
+
private slotElement;
|
|
4
|
+
private paymentService?;
|
|
5
|
+
private amount;
|
|
6
|
+
private currency;
|
|
7
|
+
private onSuccess;
|
|
8
|
+
private onFailure;
|
|
9
|
+
private scriptUrl;
|
|
10
|
+
constructor(slotElement: HTMLElement, callbacks: {
|
|
11
|
+
onSuccess: (m: string) => void;
|
|
12
|
+
onFailure: (e: string) => void;
|
|
13
|
+
});
|
|
14
|
+
updateDetails(amount: number, currency: string, paymentService?: PaymentService): void;
|
|
15
|
+
init({ paymentServiceClient, amount, currency, }: {
|
|
16
|
+
paymentServiceClient?: PaymentService;
|
|
17
|
+
currency: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
private loadApplePayScript;
|
|
21
|
+
private renderButton;
|
|
22
|
+
private handlePaymentRequest;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface EncryptedData {
|
|
2
|
+
key: string;
|
|
3
|
+
iv: string;
|
|
4
|
+
payload: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const encryptDataUsingRSAJsEncrypt: (data: any, publicKeyPem: string) => Promise<string | false>;
|
|
7
|
+
export declare function encryptDataUsingAESHybridEncrypt(data: any, apiKey: string): Promise<EncryptedData>;
|
|
8
|
+
export declare function encryptDataWithHybridRSA(serverPublicPem: string, plaintext: Uint8Array): Promise<EncryptedData>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type CreditCardTypeCardBrandId = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "visa";
|
|
2
|
+
type CreditCardTypeCardBrandNiceType = "American Express" | "Diners Club" | "Discover" | "Elo" | "Hiper" | "Hipercard" | "JCB" | "Maestro" | "Mastercard" | "Mir" | "UnionPay" | "Visa";
|
|
3
|
+
type CreditCardTypeSecurityCodeLabel = "CVV" | "CVC" | "CID" | "CVN" | "CVE" | "CVP2";
|
|
4
|
+
export type CreditCardType = {
|
|
5
|
+
niceType: string;
|
|
6
|
+
type: string;
|
|
7
|
+
patterns: number[] | [number[]];
|
|
8
|
+
gaps: number[];
|
|
9
|
+
lengths: number[];
|
|
10
|
+
code: {
|
|
11
|
+
size: number;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
matchStrength?: number;
|
|
15
|
+
};
|
|
16
|
+
interface BuiltInCreditCardType extends CreditCardType {
|
|
17
|
+
niceType: CreditCardTypeCardBrandNiceType;
|
|
18
|
+
type: CreditCardTypeCardBrandId;
|
|
19
|
+
code: {
|
|
20
|
+
size: 3 | 4;
|
|
21
|
+
name: CreditCardTypeSecurityCodeLabel;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function creditCardType(cardNumber: string): Array<CreditCardType>;
|
|
25
|
+
export declare function getCardInfoByType(cardType: CreditCardTypeCardBrandId): BuiltInCreditCardType | null;
|
|
26
|
+
export {};
|