@phystack/checkout 4.4.29
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/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/services/checkout-client.service.d.ts +19 -0
- package/dist/services/checkout-client.service.js +42 -0
- package/dist/services/checkout-interface.service.d.ts +8 -0
- package/dist/services/checkout-interface.service.js +1 -0
- package/dist/types/data-residency.d.ts +9 -0
- package/dist/types/data-residency.js +10 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/payment.d.ts +64 -0
- package/dist/types/payment.js +11 -0
- package/dist/types/transaction.d.ts +61 -0
- package/dist/types/transaction.js +7 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CheckoutServiceInterface } from "./checkout-interface.service";
|
|
2
|
+
import { CreatePaymentPayload, CreateTransactionPayload, DataResidencyEnum, PaymentResponse, TransactionResponse } from "../types";
|
|
3
|
+
type CheckoutServiceConfig = {
|
|
4
|
+
dataResidency: DataResidencyEnum;
|
|
5
|
+
tenantId: string;
|
|
6
|
+
};
|
|
7
|
+
declare class CheckoutService implements CheckoutServiceInterface {
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly httpClient;
|
|
10
|
+
private readonly dataResidency;
|
|
11
|
+
private readonly tenantId;
|
|
12
|
+
constructor({ dataResidency, tenantId }: CheckoutServiceConfig);
|
|
13
|
+
private getBaseUrl;
|
|
14
|
+
getTransaction(transactionId: string): Promise<TransactionResponse>;
|
|
15
|
+
createTransaction(payload: CreateTransactionPayload): Promise<TransactionResponse>;
|
|
16
|
+
cancelTransaction(transactionId: string): Promise<TransactionResponse>;
|
|
17
|
+
createPayment(payload: CreatePaymentPayload): Promise<PaymentResponse>;
|
|
18
|
+
}
|
|
19
|
+
export default CheckoutService;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { DataResidencyEnum, } from "../types";
|
|
3
|
+
class CheckoutService {
|
|
4
|
+
constructor({ dataResidency, tenantId }) {
|
|
5
|
+
this.tenantId = tenantId;
|
|
6
|
+
this.dataResidency = dataResidency;
|
|
7
|
+
this.baseUrl = `${this.getBaseUrl(this.dataResidency)}/${this.tenantId}`;
|
|
8
|
+
this.httpClient = axios.create({ baseURL: this.baseUrl });
|
|
9
|
+
}
|
|
10
|
+
getBaseUrl(dataResidency) {
|
|
11
|
+
const baseUrlMap = {
|
|
12
|
+
[DataResidencyEnum.AU]: "https://api.omborigrid.com/regions/au/phycheckout/api/tenants",
|
|
13
|
+
[DataResidencyEnum.EU]: "https://api.omborigrid.com/regions/eu/phycheckout/api/tenants",
|
|
14
|
+
[DataResidencyEnum.IN]: "https://api.omborigrid.com/regions/in/phycheckout/api/tenants",
|
|
15
|
+
[DataResidencyEnum.UAE]: "https://api.omborigrid.com/regions/uae/phycheckout/api/tenants",
|
|
16
|
+
[DataResidencyEnum.US]: "https://api.omborigrid.com/regions/us/phycheckout/api/tenants",
|
|
17
|
+
[DataResidencyEnum.QA]: "https://api.omborigrid.com/regions/qa/phycheckout/api/tenants",
|
|
18
|
+
[DataResidencyEnum.DEV]: "https://api.griddeveloper.com/regions/dev/phycheckout/api/tenants",
|
|
19
|
+
};
|
|
20
|
+
const baseUrl = baseUrlMap[dataResidency];
|
|
21
|
+
if (!baseUrl) {
|
|
22
|
+
throw new Error(`Invalid data residency: ${dataResidency}`);
|
|
23
|
+
}
|
|
24
|
+
return baseUrl;
|
|
25
|
+
}
|
|
26
|
+
async getTransaction(transactionId) {
|
|
27
|
+
const { data } = await this.httpClient.get(`/transactions/${transactionId}`);
|
|
28
|
+
return data.data;
|
|
29
|
+
}
|
|
30
|
+
async createTransaction(payload) {
|
|
31
|
+
const { data } = await this.httpClient.post("/transactions", payload);
|
|
32
|
+
return data.data;
|
|
33
|
+
}
|
|
34
|
+
async cancelTransaction(transactionId) {
|
|
35
|
+
return await this.httpClient.delete(`/transactions/${transactionId}`);
|
|
36
|
+
}
|
|
37
|
+
async createPayment(payload) {
|
|
38
|
+
const { data } = await this.httpClient.post("/payments", payload);
|
|
39
|
+
return data.data;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default CheckoutService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CreatePaymentPayload, PaymentResponse } from "../types";
|
|
2
|
+
import { CreateTransactionPayload, TransactionResponse } from "../types/transaction";
|
|
3
|
+
export interface CheckoutServiceInterface {
|
|
4
|
+
getTransaction(transactionId: string): Promise<TransactionResponse>;
|
|
5
|
+
createTransaction(payload: CreateTransactionPayload): Promise<TransactionResponse>;
|
|
6
|
+
cancelTransaction(transactionId: string): Promise<TransactionResponse>;
|
|
7
|
+
createPayment(payload: CreatePaymentPayload): Promise<PaymentResponse>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var DataResidencyEnum;
|
|
2
|
+
(function (DataResidencyEnum) {
|
|
3
|
+
DataResidencyEnum["EU"] = "EU";
|
|
4
|
+
DataResidencyEnum["US"] = "US";
|
|
5
|
+
DataResidencyEnum["UAE"] = "UAE";
|
|
6
|
+
DataResidencyEnum["AU"] = "AU";
|
|
7
|
+
DataResidencyEnum["IN"] = "IN";
|
|
8
|
+
DataResidencyEnum["QA"] = "QA";
|
|
9
|
+
DataResidencyEnum["DEV"] = "DEV";
|
|
10
|
+
})(DataResidencyEnum || (DataResidencyEnum = {}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare enum PaymentMode {
|
|
2
|
+
Online = "online",
|
|
3
|
+
CardPresent = "cardPresent"
|
|
4
|
+
}
|
|
5
|
+
export declare enum PaymentType {
|
|
6
|
+
StripeOnlineCheckout = "stripeOnlineCheckout",
|
|
7
|
+
AdyenCloudCardTerminal = "adyenCloudCardTerminal",
|
|
8
|
+
Other = "other"
|
|
9
|
+
}
|
|
10
|
+
export interface TransactionOtherPayment {
|
|
11
|
+
type: PaymentType.Other;
|
|
12
|
+
data: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface StripeOnlineCheckoutPaymentData {
|
|
15
|
+
collectShippingAddress: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TransactionStripeOnlineCheckoutPayment {
|
|
18
|
+
type: PaymentType.StripeOnlineCheckout;
|
|
19
|
+
data: StripeOnlineCheckoutPaymentData;
|
|
20
|
+
}
|
|
21
|
+
export interface AdyenCardTerminalCloudPaymentData {
|
|
22
|
+
terminalId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TransactionAdyenCloudCardTerminalCheckoutPayment {
|
|
25
|
+
type: PaymentType.AdyenCloudCardTerminal;
|
|
26
|
+
data: AdyenCardTerminalCloudPaymentData;
|
|
27
|
+
}
|
|
28
|
+
export type TransactionPayment = TransactionOtherPayment | TransactionStripeOnlineCheckoutPayment;
|
|
29
|
+
export interface Customer {
|
|
30
|
+
email: string;
|
|
31
|
+
name: string;
|
|
32
|
+
phone: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AdyenCloudCardTerminalPaymentData {
|
|
35
|
+
terminalId: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CreatePaymentPayload {
|
|
38
|
+
paymentTypeId: string;
|
|
39
|
+
transactionId: string;
|
|
40
|
+
data?: AdyenCloudCardTerminalPaymentData | StripeOnlineCheckoutPaymentData;
|
|
41
|
+
}
|
|
42
|
+
export interface StripeOnlineCheckoutPaymentResponse {
|
|
43
|
+
type: PaymentType.StripeOnlineCheckout;
|
|
44
|
+
transactionId: string;
|
|
45
|
+
data: {
|
|
46
|
+
stripeId: string;
|
|
47
|
+
checkoutUrl: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface AdyenCloudCardTerminalCheckoutPaymentResponse {
|
|
51
|
+
type: PaymentType.AdyenCloudCardTerminal;
|
|
52
|
+
transactionId: string;
|
|
53
|
+
data: {
|
|
54
|
+
status: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type PaymentResponse = StripeOnlineCheckoutPaymentResponse | AdyenCloudCardTerminalCheckoutPaymentResponse;
|
|
58
|
+
export interface PaymentMethodSchemaConfig {
|
|
59
|
+
id: string;
|
|
60
|
+
title: string;
|
|
61
|
+
type: PaymentType;
|
|
62
|
+
mode: PaymentMode;
|
|
63
|
+
data: StripeOnlineCheckoutPaymentData | AdyenCardTerminalCloudPaymentData;
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var PaymentMode;
|
|
2
|
+
(function (PaymentMode) {
|
|
3
|
+
PaymentMode["Online"] = "online";
|
|
4
|
+
PaymentMode["CardPresent"] = "cardPresent";
|
|
5
|
+
})(PaymentMode || (PaymentMode = {}));
|
|
6
|
+
export var PaymentType;
|
|
7
|
+
(function (PaymentType) {
|
|
8
|
+
PaymentType["StripeOnlineCheckout"] = "stripeOnlineCheckout";
|
|
9
|
+
PaymentType["AdyenCloudCardTerminal"] = "adyenCloudCardTerminal";
|
|
10
|
+
PaymentType["Other"] = "other";
|
|
11
|
+
})(PaymentType || (PaymentType = {}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Customer, TransactionPayment } from "./payment";
|
|
2
|
+
export interface TransactionResponse {
|
|
3
|
+
id: string;
|
|
4
|
+
tenantId: string;
|
|
5
|
+
status: TransactionStatusEnum;
|
|
6
|
+
items: TransactionItem[];
|
|
7
|
+
totalAmount: number;
|
|
8
|
+
subtotalAmount: number;
|
|
9
|
+
totalTaxAmount: number;
|
|
10
|
+
totalDiscountAmount: number;
|
|
11
|
+
totalShippingAmount: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
metadata?: unknown;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
payment?: TransactionPayment;
|
|
17
|
+
customer?: Customer;
|
|
18
|
+
}
|
|
19
|
+
export declare enum TransactionStatusEnum {
|
|
20
|
+
Pending = "pending",
|
|
21
|
+
Success = "success",
|
|
22
|
+
Failed = "failed",
|
|
23
|
+
Cancelled = "cancelled"
|
|
24
|
+
}
|
|
25
|
+
export interface TransactionItem {
|
|
26
|
+
productId: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
unitAmount: number;
|
|
30
|
+
discountAmount: number;
|
|
31
|
+
subtotalAmount: number;
|
|
32
|
+
totalAmount: number;
|
|
33
|
+
quantity: number;
|
|
34
|
+
taxAmount?: number;
|
|
35
|
+
taxRate?: number;
|
|
36
|
+
metadata?: unknown;
|
|
37
|
+
alerts?: any[];
|
|
38
|
+
}
|
|
39
|
+
export interface CreateTransactionPayload {
|
|
40
|
+
spaceId: string;
|
|
41
|
+
currency: string;
|
|
42
|
+
items: {
|
|
43
|
+
quantity: number;
|
|
44
|
+
productId?: string;
|
|
45
|
+
productData: {
|
|
46
|
+
productId: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
unitAmount: number;
|
|
50
|
+
taxRate?: number;
|
|
51
|
+
customProperties?: {
|
|
52
|
+
key: string;
|
|
53
|
+
value: string;
|
|
54
|
+
productId?: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}[];
|
|
58
|
+
metadata?: unknown;
|
|
59
|
+
payment?: string;
|
|
60
|
+
salesEmployeeId?: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var TransactionStatusEnum;
|
|
2
|
+
(function (TransactionStatusEnum) {
|
|
3
|
+
TransactionStatusEnum["Pending"] = "pending";
|
|
4
|
+
TransactionStatusEnum["Success"] = "success";
|
|
5
|
+
TransactionStatusEnum["Failed"] = "failed";
|
|
6
|
+
TransactionStatusEnum["Cancelled"] = "cancelled";
|
|
7
|
+
})(TransactionStatusEnum || (TransactionStatusEnum = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@phystack/checkout",
|
|
3
|
+
"version": "4.4.29",
|
|
4
|
+
"author": "https://build.phygrid.com/",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ombori checkout",
|
|
7
|
+
"PhyGrid checkout sdk",
|
|
8
|
+
"ombori self checkout",
|
|
9
|
+
"stripe online checkout",
|
|
10
|
+
"adyen card payment",
|
|
11
|
+
"payment",
|
|
12
|
+
"checkout",
|
|
13
|
+
"retail",
|
|
14
|
+
"iot"
|
|
15
|
+
],
|
|
16
|
+
"description": "",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rimraf dist && tsc",
|
|
23
|
+
"format": "prettier --write \"src/**/*.{ts,js,json,md}\"",
|
|
24
|
+
"format:check": "prettier --check \"src/**/*.{ts,js,json,md}\"",
|
|
25
|
+
"typecheck": "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"axios": "^1.7.9"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"prettier": "^3.4.2",
|
|
33
|
+
"rimraf": "^6.0.1",
|
|
34
|
+
"typescript": "^5.7.3"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"gitHead": "7dba834ca1f446f669992ff14352862d2fbcfe22"
|
|
44
|
+
}
|