@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.
@@ -0,0 +1,50 @@
1
+ export declare const getTranslatedText: (lang: string) => {
2
+ choosePaymentMethodText: string;
3
+ enterCardDetailsText: string;
4
+ submitButtonText: string;
5
+ labels: {
6
+ cardNumber: string;
7
+ cardHolderName: string;
8
+ expiry: string;
9
+ cvc: string;
10
+ };
11
+ or: string;
12
+ invalid_card_number: string;
13
+ invalid_expiry: string;
14
+ expiry_cannot_be_in_the_past: string;
15
+ invalid_length: string;
16
+ failed_to_encrypt_card_data: string;
17
+ validating_card: string;
18
+ please_dont_close_or_refresh: string;
19
+ stay_safe_dont_share: string;
20
+ strab_and_its_team_will_never_ask_for_your_otp: string;
21
+ united_against_fraud: string;
22
+ required_field: string;
23
+ payment_error: string;
24
+ something_went_wrong_while_loading_the_payment_form: string;
25
+ } | {
26
+ choosePaymentMethodText: string;
27
+ enterCardDetailsText: string;
28
+ invalid_card_number: string;
29
+ invalid_expiry: string;
30
+ expiry_cannot_be_in_the_past: string;
31
+ invalid_length: string;
32
+ failed_to_encrypt_card_data: string;
33
+ required_field: string;
34
+ payment_error: string;
35
+ something_went_wrong_while_loading_the_payment_form: string;
36
+ submitButtonText: string;
37
+ labels: {
38
+ cardNumber: string;
39
+ cardHolderName: string;
40
+ expiry: string;
41
+ cvc: string;
42
+ };
43
+ or: string;
44
+ validating_card: string;
45
+ please_dont_close_or_refresh: string;
46
+ stay_safe_dont_share: string;
47
+ strab_and_its_team_will_never_ask_for_your_otp: string;
48
+ united_against_fraud: string;
49
+ };
50
+ export declare const isRTL: (lang: string) => lang is "ar";
@@ -0,0 +1,9 @@
1
+ export declare class ThreeDsAuth {
2
+ handleMessage: (event: MessageEvent) => Promise<void>;
3
+ performMpgsThreeDsAuth({ orderShortCode, token, threeDsUrl, threeDsToken, }: {
4
+ orderShortCode: string;
5
+ token: string;
6
+ threeDsUrl?: string;
7
+ threeDsToken?: string;
8
+ }): Promise<void>;
9
+ }
@@ -0,0 +1,19 @@
1
+ export declare class UserMetaData {
2
+ private static readonly STORAGE_KEY;
3
+ static fetchAndStoreMetaData(): Promise<void>;
4
+ static getBrowserType(): "Opera" | "Microsoft Edge" | "Google Chrome" | "Mozilla Firefox" | "Apple Safari" | "Microsoft Internet Explorer" | "UC Browser" | "Samsung Browser" | "Unknown browser";
5
+ static getOsName(): "Windows" | "MacOS" | "Android" | "iOS" | "Linux" | "Unknown OS";
6
+ static getMetaData(): {
7
+ referrer: string;
8
+ ipAddress: any;
9
+ lat: any;
10
+ lng: any;
11
+ countryName: any;
12
+ cityName: any;
13
+ regionName: any;
14
+ asnOrganization: any;
15
+ isProxy: any;
16
+ browser: string;
17
+ platform: string;
18
+ };
19
+ }
@@ -0,0 +1 @@
1
+ export declare const isValidUrl: (str: string) => boolean;
@@ -0,0 +1,15 @@
1
+ import { StrablCardForm, type StrablCardFormProps } from "./components/strabl-card-form.element.js";
2
+ export interface MountOptions extends Partial<StrablCardFormProps> {
3
+ selector: string;
4
+ onPaymentSubmission?: () => Promise<boolean>;
5
+ onPaymentSuccess?: (orderShortCode: string) => void;
6
+ onPaymentFailed?: (failureReason: string) => void;
7
+ replace?: boolean;
8
+ }
9
+ export interface MountedCardForm {
10
+ element: StrablCardForm;
11
+ update: (options: Partial<Omit<MountOptions, "selector" | "replace">>) => void;
12
+ submit: () => void;
13
+ destroy: () => void;
14
+ }
15
+ export declare function mountCardForm(options: MountOptions): MountedCardForm;
@@ -0,0 +1,19 @@
1
+ type RequestOptions = {
2
+ headers?: Record<string, string>;
3
+ queryParams?: Record<string, string | number | boolean>;
4
+ body?: any;
5
+ timeout?: number;
6
+ };
7
+ export declare class HttpClient {
8
+ private baseUrl;
9
+ private defaultHeaders;
10
+ constructor(apiKey: string, defaultHeaders?: Record<string, string>);
11
+ private buildUrl;
12
+ private request;
13
+ get<T>(url: string, options?: RequestOptions): Promise<T>;
14
+ post<T>(url: string, body?: any, options?: RequestOptions): Promise<T>;
15
+ put<T>(url: string, body?: any, options?: RequestOptions): Promise<T>;
16
+ patch<T>(url: string, body?: any, options?: RequestOptions): Promise<T>;
17
+ delete<T>(url: string, options?: RequestOptions): Promise<T>;
18
+ }
19
+ export {};
@@ -0,0 +1,75 @@
1
+ import { HttpClient } from "./HttpClient";
2
+ type GenerateCardTokenResponse = {
3
+ success: boolean;
4
+ message?: string;
5
+ data: {
6
+ token: string;
7
+ };
8
+ };
9
+ type CreatePaymentIntentResponse = {
10
+ code: string;
11
+ message: string;
12
+ data: {
13
+ status: "CAPTURED" | "CAPTURE_FAILED" | "AUTHORIZED";
14
+ amount: number;
15
+ capturedAmount: number;
16
+ currency: string;
17
+ cardLastFour: string;
18
+ cardFirstSix: string;
19
+ customerName: string;
20
+ orderShortCode: string;
21
+ redirectUrl: string;
22
+ cardToken: string;
23
+ paymentGateway: string;
24
+ paymentReference: string;
25
+ failureReason?: string;
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ additionalRedirectParams?: {
29
+ "3dsToken"?: string;
30
+ "3dsUrl"?: string;
31
+ };
32
+ };
33
+ };
34
+ type ConfirmPaymentResponse = {
35
+ code: string;
36
+ message: string;
37
+ data: {
38
+ transactionId: string;
39
+ status: "CAPTURED" | "CAPTURE_FAILED" | "AUTHORIZED";
40
+ orderShortCode: string;
41
+ failureReason: string;
42
+ };
43
+ };
44
+ export declare class PaymentService {
45
+ private api;
46
+ constructor(api: HttpClient);
47
+ generateCardToken({ key, iv, payload, }: {
48
+ key: string;
49
+ iv: string;
50
+ payload: string;
51
+ }): Promise<GenerateCardTokenResponse>;
52
+ createPaymentIntent({ amount, currency, customerEmail, customerName, cvv, ipAddress, redirectUrl, cardToken, isApplePay, tokenData, metadata, }: {
53
+ cardToken?: string;
54
+ customerName?: string;
55
+ amount: number;
56
+ currency: string;
57
+ customerEmail?: string;
58
+ redirectUrl: string;
59
+ cvv?: string;
60
+ ipAddress?: string;
61
+ isApplePay?: boolean;
62
+ tokenData?: any;
63
+ metadata?: {
64
+ [key: string]: string;
65
+ };
66
+ }): Promise<CreatePaymentIntentResponse>;
67
+ confirmPayment({ transactionId, }: {
68
+ transactionId: string;
69
+ }): Promise<ConfirmPaymentResponse>;
70
+ createApplePaySession({ validationUrl, }: {
71
+ validationUrl: string;
72
+ }): Promise<any>;
73
+ reportSdkUage(): Promise<void>;
74
+ }
75
+ export {};
@@ -0,0 +1,8 @@
1
+ import { HttpClient } from "./HttpClient";
2
+ export declare class ReportSdkUsage {
3
+ private api;
4
+ private REPORT_KEY;
5
+ private THROTTLE_MINUTES;
6
+ constructor(api: HttpClient);
7
+ reportSdkUsage(): Promise<void>;
8
+ }
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ import { StrablCardForm } from "./components/strabl-card-form.element.js";
3
+ import "./components/strabl-input.element.js";
4
+ export interface StrablCardFormProps {
5
+ platformUuid: string;
6
+ apiKey: string;
7
+ currencyCode: string;
8
+ amount: number;
9
+ language?: "en" | "ar";
10
+ fieldInputStyle?: "floating-label" | "outlined";
11
+ paymentMethods?: ("card" | "applepay")[];
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
+ className?: string;
30
+ style?: React.CSSProperties;
31
+ onPaymentSubmission?: () => Promise<boolean>;
32
+ onPaymentSuccess?: (orderShortCode: string) => void;
33
+ onPaymentFailed?: (failureReason: string) => void;
34
+ }
35
+ export declare const StrablCardPaymentForm: React.ForwardRefExoticComponent<StrablCardFormProps & React.RefAttributes<StrablCardForm>>;
package/dist/react.js ADDED
@@ -0,0 +1,26 @@
1
+ import * as s from "react";
2
+ import { S as u, a as c } from "./strabl-input.element-DeXtiSuj.js";
3
+ typeof customElements < "u" && !customElements.get("strabl-card-form") && customElements.define("strabl-card-form", u);
4
+ typeof customElements < "u" && !customElements.get("strabl-input") && customElements.define("strabl-input", c);
5
+ const f = s.forwardRef(function(m, n) {
6
+ const { className: a, style: r, ...t } = m, o = s.useRef(null);
7
+ return s.useLayoutEffect(() => {
8
+ const e = o.current;
9
+ e && (e.paymentMethods = t.paymentMethods ?? ["card"], e.customstyles = t.customstyles ?? {}, e.customer = t.customer ?? {}, e.onPaymentSubmission = t.onPaymentSubmission, e.onPaymentSuccess = t.onPaymentSuccess, e.onPaymentFailed = t.onPaymentFailed);
10
+ }, [t]), s.createElement("strabl-card-form", {
11
+ ref: (e) => {
12
+ o.current = e, typeof n == "function" ? n(e) : n && (n.current = e);
13
+ },
14
+ class: a,
15
+ style: r,
16
+ platformUuid: t.platformUuid,
17
+ apiKey: t.apiKey,
18
+ currencyCode: t.currencyCode,
19
+ amount: t.amount,
20
+ language: t.language || "en",
21
+ fieldInputStyle: t.fieldInputStyle || "outlined"
22
+ });
23
+ });
24
+ export {
25
+ f as StrablCardPaymentForm
26
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),c=require("./strabl-input.element-CbrtvlUF.cjs");function i(o){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>o[n]})}}return r.default=o,Object.freeze(r)}const a=i(m);typeof customElements<"u"&&!customElements.get("strabl-card-form")&&customElements.define("strabl-card-form",c.StrablCardForm);typeof customElements<"u"&&!customElements.get("strabl-input")&&customElements.define("strabl-input",c.StrablInput);const f=a.forwardRef(function(r,n){const{className:s,style:l,...e}=r,u=a.useRef(null);return a.useLayoutEffect(()=>{const t=u.current;t&&(t.paymentMethods=e.paymentMethods??["card"],t.customstyles=e.customstyles??{},t.customer=e.customer??{},t.onPaymentSubmission=e.onPaymentSubmission,t.onPaymentSuccess=e.onPaymentSuccess,t.onPaymentFailed=e.onPaymentFailed)},[e]),a.createElement("strabl-card-form",{ref:t=>{u.current=t,typeof n=="function"?n(t):n&&(n.current=t)},class:s,style:l,platformUuid:e.platformUuid,apiKey:e.apiKey,currencyCode:e.currencyCode,amount:e.amount,language:e.language||"en",fieldInputStyle:e.fieldInputStyle||"outlined"})});exports.StrablCardPaymentForm=f;