@rkfl/transact-server 1.0.3 → 1.0.6
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/constants.d.ts +63 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/package.json +9 -1
package/dist/constants.d.ts
CHANGED
|
@@ -8,3 +8,66 @@ export type Environment = keyof typeof apiDomains;
|
|
|
8
8
|
export interface HttpError extends Error {
|
|
9
9
|
status: number;
|
|
10
10
|
}
|
|
11
|
+
export interface CartItem {
|
|
12
|
+
id: string | null;
|
|
13
|
+
price: number;
|
|
14
|
+
name: string;
|
|
15
|
+
quantity: number;
|
|
16
|
+
key?: number;
|
|
17
|
+
totalPrice?: number;
|
|
18
|
+
isSubscription?: boolean | null;
|
|
19
|
+
frequency?: "weekly" | "monthly" | "quarterly" | "half-yearly" | "yearly" | "" | null;
|
|
20
|
+
subscriptionPeriod?: string | null;
|
|
21
|
+
merchantSubscriptionId?: string | null;
|
|
22
|
+
autoRenewal?: boolean | null;
|
|
23
|
+
isSubscriptionRenewal?: boolean | null;
|
|
24
|
+
subscriptionId?: string | null;
|
|
25
|
+
refundable?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface CustomerInfo {
|
|
28
|
+
name: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
phone?: string;
|
|
31
|
+
address?: string;
|
|
32
|
+
allowLoginWithoutEmail?: boolean;
|
|
33
|
+
userIdentifier?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ShippingAddress {
|
|
36
|
+
firstname?: string;
|
|
37
|
+
lastname?: string;
|
|
38
|
+
phoneNo?: string;
|
|
39
|
+
address1: string;
|
|
40
|
+
address2?: string;
|
|
41
|
+
state: string;
|
|
42
|
+
city: string;
|
|
43
|
+
zipcode?: string;
|
|
44
|
+
country: string;
|
|
45
|
+
landmark?: string | null;
|
|
46
|
+
email?: string | null;
|
|
47
|
+
}
|
|
48
|
+
export interface CustomParameter {
|
|
49
|
+
returnMethod: any;
|
|
50
|
+
params: any;
|
|
51
|
+
}
|
|
52
|
+
export interface FeeConfiguration {
|
|
53
|
+
type: "FIAT" | "PERCENT";
|
|
54
|
+
value: number;
|
|
55
|
+
}
|
|
56
|
+
export interface SiteInfo {
|
|
57
|
+
siteUrl?: string | null;
|
|
58
|
+
siteName?: string | null;
|
|
59
|
+
siteLogo?: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface CartData {
|
|
62
|
+
merchant_id: string;
|
|
63
|
+
amount: string;
|
|
64
|
+
cart: CartItem[];
|
|
65
|
+
currency: string;
|
|
66
|
+
order?: string;
|
|
67
|
+
redirectUrl?: string;
|
|
68
|
+
customerInfo?: CustomerInfo;
|
|
69
|
+
shippingAddress?: ShippingAddress | null;
|
|
70
|
+
customParameter?: CustomParameter | null;
|
|
71
|
+
feeConfiguration?: FeeConfiguration | null;
|
|
72
|
+
siteInfo?: SiteInfo | null;
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Environment } from './constants';
|
|
1
|
+
import type { CartData, Environment } from './constants';
|
|
2
2
|
export declare class Rocketfuel {
|
|
3
3
|
#private;
|
|
4
4
|
constructor({ clientId, clientSecret, merchantId, environment, }: {
|
|
@@ -7,7 +7,8 @@ export declare class Rocketfuel {
|
|
|
7
7
|
merchantId: string;
|
|
8
8
|
environment: Environment;
|
|
9
9
|
});
|
|
10
|
-
createOrder(payload:
|
|
10
|
+
createOrder(payload: CartData): Promise<any>;
|
|
11
11
|
transactionLookup(txId: string, type?: 'ORDERID' | 'TXID'): Promise<any>;
|
|
12
|
+
verifyAgeVerification(auditId: string): Promise<any>;
|
|
12
13
|
verifyWebhookSignature(body: any): boolean;
|
|
13
14
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"crypto-js";import*as e from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class r{#t;#e;#s;#r;#n=null;#a=null;constructor({clientId:t,clientSecret:e,merchantId:r,environment:n}){this.#t=t,this.#e=e,this.#s=r,this.#r=s[n||"production"]}#
|
|
1
|
+
import t from"crypto-js";import*as e from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class r{#t;#e;#s;#r;#n=null;#a=null;constructor({clientId:t,clientSecret:e,merchantId:r,environment:n}){this.#t=t,this.#e=e,this.#s=r,this.#r=s[n||"production"]}#i(){const e=JSON.stringify({merchantId:this.#s,totop:""});return t.AES.encrypt(e,this.#e).toString()}#o(){const t={"Content-Type":"application/json"};return this.#n&&(t.Authorization=`Bearer ${this.#n}`),t}async#c(){const t={clientId:this.#t,encryptedPayload:this.#i()},e=await fetch(`${this.#r}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Auth failed: ${e.status}`);const s=await e.json(),r=s?.result;if(!r?.access)throw new Error("Token missing in response");this.#n=r.access,this.#a=r.refresh}async#h(t,e,s=!0){const r=await fetch(t,e);if(403===r.status&&s){console.warn(`Received 403, refreshing token and retrying: ${t}`),await this.#c();const s={...e,headers:this.#o()};return this.#h(t,s,!1)}if(!r.ok){const t=new Error(r.statusText);throw t.status=r.status,t}return r.json()}async createOrder(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(t)});return{uuid:e?.result?.uuid}}async transactionLookup(t,e="ORDERID"){this.#n||await this.#c();const s=await this.#h(`${this.#r}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:t,type:e})});return s?.result}async verifyAgeVerification(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/merchant/audit/${t}`,{method:"GET",headers:this.#o()});return e?.result}verifyWebhookSignature(t){try{const{data:{data:s},signature:r}=t,n=e.createVerify("RSA-SHA256");return n.update(s),n.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",r,"base64")}catch(t){return console.error("Signature verification failed:",t),!1}}}export{r as Rocketfuel};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@rkfl/transact-server",
|
|
3
3
|
"main": "./dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.6",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rollup -c",
|
|
8
8
|
"npm:login": "npm login",
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
16
24
|
"files": [
|
|
17
25
|
"dist"
|
|
18
26
|
],
|