simplepay-js-sdk 0.4.0 → 0.6.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 CHANGED
@@ -44,7 +44,7 @@ try {
44
44
  total: 1212,
45
45
  currency: 'HUF', // optional, HUF | EUR | USD, defaults to HUF
46
46
  customerEmail: 'rrd@webmania.cc',
47
- language: 'HU', // optional, defaults to HU
47
+ language: 'HU', // optional, AR | BG | CS | DE | EN | ES | FR | IT | HR | HU | PL | RO | RU | SK | TR | ZH, defaults to HU
48
48
  method: 'CARD', // optional, CARD | WIRE, defaults to CARD
49
49
  invoice: {
50
50
  name: 'Radharadhya Dasa',
@@ -82,7 +82,7 @@ const response = getPaymentResponse(r, s)
82
82
  - `transactionId`: the transaction id
83
83
  - `event`: the event type: `success` | `fail` | `timeout` | `cancel`
84
84
  - `merchantId`: the merchant id
85
- - `orderId`: the order id
85
+ - `orderRef`: the order id
86
86
 
87
87
  ### IPN Endpoint
88
88
 
package/dist/index.d.ts CHANGED
@@ -1,19 +1,65 @@
1
- import { PaymentData, SimplePayResponse, Currency } from './types';
2
- declare const generateSignature: (body: string, merchantKey: string) => string;
3
- declare const checkSignature: (responseText: string, signature: string, merchantKey: string) => boolean;
4
- declare const getSimplePayConfig: (currency: Currency) => {
5
- MERCHANT_KEY: string | undefined;
6
- MERCHANT_ID: string | undefined;
7
- API_URL: string;
8
- SDK_VERSION: string;
9
- };
10
- declare const startPayment: (paymentData: PaymentData) => Promise<SimplePayResponse>;
11
- declare const getCurrencyFromMerchantId: (merchantId: string) => "HUF" | "EUR" | "USD";
12
- declare const getPaymentResponse: (r: string, signature: string) => {
13
- responseCode: number;
14
- transactionId: string;
15
- event: "success" | "fail" | "timeout" | "cancel";
16
- merchantId: string;
17
- orderId: string;
18
- };
19
- export { startPayment, getPaymentResponse, getSimplePayConfig, generateSignature, checkSignature, getCurrencyFromMerchantId };
1
+ export declare const checkSignature: (responseText: string, signature: string, merchantKey: string) => boolean;
2
+
3
+ declare const CURRENCIES: readonly ["HUF", "EUR", "USD"];
4
+
5
+ declare type Currency = typeof CURRENCIES[number];
6
+
7
+ export declare const generateSignature: (body: string, merchantKey: string) => string;
8
+
9
+ export declare const getCurrencyFromMerchantId: (merchantId: string) => "HUF" | "EUR" | "USD";
10
+
11
+ export declare const getPaymentResponse: (r: string, signature: string) => {
12
+ responseCode: number;
13
+ transactionId: string;
14
+ event: "success" | "fail" | "timeout" | "cancel";
15
+ merchantId: string;
16
+ orderRef: string;
17
+ };
18
+
19
+ export declare const getSimplePayConfig: (currency: Currency) => {
20
+ MERCHANT_KEY: string | undefined;
21
+ MERCHANT_ID: string | undefined;
22
+ API_URL: string;
23
+ SDK_VERSION: string;
24
+ };
25
+
26
+ declare type Language = typeof LANGUAGES[number];
27
+
28
+ declare const LANGUAGES: readonly ["AR", "BG", "CS", "DE", "EN", "ES", "FR", "IT", "HR", "HU", "PL", "RO", "RU", "SK", "TR", "ZH"];
29
+
30
+ declare interface PaymentData {
31
+ orderRef: string;
32
+ total: number | string;
33
+ customerEmail: string;
34
+ currency?: Currency;
35
+ language?: Language;
36
+ method?: PaymentMethod;
37
+ invoice?: {
38
+ name: string;
39
+ country: string;
40
+ state: string;
41
+ city: string;
42
+ zip: string;
43
+ address: string;
44
+ address2?: string;
45
+ phone?: string;
46
+ };
47
+ }
48
+
49
+ declare type PaymentMethod = 'CARD' | 'WIRE';
50
+
51
+ declare interface SimplePayResponse {
52
+ salt: string;
53
+ merchant: string;
54
+ orderRef: string;
55
+ currency: Currency;
56
+ transactionId: string;
57
+ timeout: string;
58
+ total: string;
59
+ paymentUrl: string;
60
+ errorCodes?: string[];
61
+ }
62
+
63
+ export declare const startPayment: (paymentData: PaymentData) => Promise<SimplePayResponse>;
64
+
65
+ export { }
package/dist/index.js CHANGED
@@ -1,125 +1,88 @@
1
- import crypto from 'crypto';
2
- import { CURRENCIES } from './types';
3
- // Existing interfaces remain the same
4
- const simplepayLogger = (...args) => {
5
- if (process.env.SIMPLEPAY_LOGGER !== 'true') {
6
- return;
7
- }
8
- console.log(...args);
1
+ const P = {}, I = ["HUF", "EUR", "USD"], a = (...e) => {
2
+ process.env.SIMPLEPAY_LOGGER === "true" && console.log(...e);
3
+ }, R = (e, t) => {
4
+ const r = P.createHmac("sha384", t.trim());
5
+ return r.update(e, "utf8"), r.digest("base64");
6
+ }, _ = (e, t, r) => t === R(e, r), g = (e) => JSON.stringify(e).replace(/\//g, "\\/"), h = (e) => {
7
+ if (!I.includes(e))
8
+ throw new Error(`Unsupported currency: ${e}`);
9
+ const t = "https://secure.simplepay.hu/payment/v2", r = "https://sandbox.simplepay.hu/payment/v2/start", o = "SimplePayV2.1_Rrd_0.5.0", s = process.env[`SIMPLEPAY_MERCHANT_KEY_${e}`], c = process.env[`SIMPLEPAY_MERCHANT_ID_${e}`], n = process.env.SIMPLEPAY_PRODUCTION === "true" ? t : r;
10
+ return {
11
+ MERCHANT_KEY: s,
12
+ MERCHANT_ID: c,
13
+ API_URL: n,
14
+ SDK_VERSION: o
15
+ };
16
+ }, l = async (e) => {
17
+ const t = e.currency || "HUF", { MERCHANT_KEY: r, MERCHANT_ID: o, API_URL: s, SDK_VERSION: c } = h(t);
18
+ if (a({ MERCHANT_KEY: r, MERCHANT_ID: o, API_URL: s }), !r || !o)
19
+ throw new Error("Missing SimplePay configuration");
20
+ const n = {
21
+ salt: P.randomBytes(16).toString("hex"),
22
+ merchant: o,
23
+ orderRef: e.orderRef,
24
+ currency: t,
25
+ customerEmail: e.customerEmail,
26
+ language: e.language || "HU",
27
+ sdkVersion: c,
28
+ methods: [e.method || "CARD"],
29
+ total: String(e.total),
30
+ timeout: new Date(Date.now() + 30 * 60 * 1e3).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
31
+ url: process.env.SIMPLEPAY_REDIRECT_URL || "http://url.to.redirect",
32
+ invoice: e.invoice
33
+ }, p = g(n), u = R(p, r);
34
+ a({ bodyString: p, signature: u });
35
+ try {
36
+ const i = await fetch(s, {
37
+ method: "POST",
38
+ headers: {
39
+ "Content-Type": "application/json",
40
+ Signature: u
41
+ },
42
+ body: p
43
+ });
44
+ if (a({ response: i }), !i.ok)
45
+ throw new Error(`SimplePay API error: ${i.status}`);
46
+ const S = i.headers.get("Signature");
47
+ if (a({ responseSignature: S }), !S)
48
+ throw new Error("Missing response signature");
49
+ const d = await i.text(), E = JSON.parse(d);
50
+ if (a({ responseText: d, responseJSON: E }), E.errorCodes)
51
+ throw new Error(`SimplePay API error: ${E.errorCodes}`);
52
+ if (!_(d, S, r))
53
+ throw new Error("Invalid response signature");
54
+ return E;
55
+ } catch (i) {
56
+ throw i;
57
+ }
58
+ }, f = (e) => {
59
+ var r, o;
60
+ const t = (o = (r = Object.entries(process.env).find(
61
+ ([s, c]) => s.startsWith("SIMPLEPAY_MERCHANT_ID_") && c === e
62
+ )) == null ? void 0 : r[0]) == null ? void 0 : o.replace("SIMPLEPAY_MERCHANT_ID_", "");
63
+ if (!t)
64
+ throw new Error(`Merchant id not found in the environment: ${e}`);
65
+ return t;
66
+ }, m = (e, t) => {
67
+ t = decodeURIComponent(t), t = Buffer.from(t, "base64").toString("utf-8");
68
+ const r = Buffer.from(e, "base64").toString("utf-8"), o = JSON.parse(r), s = f(o.m), { MERCHANT_KEY: c } = h(s);
69
+ if (!_(r, t, c || ""))
70
+ throw a({ rDecoded: r, signature: t }), new Error("Invalid response signature");
71
+ const n = JSON.parse(r);
72
+ return {
73
+ responseCode: n.r,
74
+ transactionId: n.t,
75
+ event: n.e,
76
+ merchantId: n.m,
77
+ orderRef: n.o
78
+ };
9
79
  };
10
- const generateSignature = (body, merchantKey) => {
11
- const hmac = crypto.createHmac('sha384', merchantKey.trim());
12
- hmac.update(body, 'utf8');
13
- return hmac.digest('base64');
80
+ export {
81
+ _ as checkSignature,
82
+ R as generateSignature,
83
+ f as getCurrencyFromMerchantId,
84
+ m as getPaymentResponse,
85
+ h as getSimplePayConfig,
86
+ l as startPayment
14
87
  };
15
- const checkSignature = (responseText, signature, merchantKey) => signature === generateSignature(responseText, merchantKey);
16
- // escaping slashes for the request body to prevent strange SimplePay API errors (eg Missing Signature)
17
- const prepareRequestBody = (body) => JSON.stringify(body).replace(/\//g, '\\/');
18
- const getSimplePayConfig = (currency) => {
19
- if (!CURRENCIES.includes(currency)) {
20
- throw new Error(`Unsupported currency: ${currency}`);
21
- }
22
- const SIMPLEPAY_API_URL = 'https://secure.simplepay.hu/payment/v2';
23
- const SIMPLEPAY_SANDBOX_URL = 'https://sandbox.simplepay.hu/payment/v2/start';
24
- const SDK_VERSION = 'SimplePayV2.1_Rrd_0.4.0';
25
- const MERCHANT_KEY = process.env[`SIMPLEPAY_MERCHANT_KEY_${currency}`];
26
- const MERCHANT_ID = process.env[`SIMPLEPAY_MERCHANT_ID_${currency}`];
27
- const API_URL = process.env.SIMPLEPAY_PRODUCTION === 'true' ? SIMPLEPAY_API_URL : SIMPLEPAY_SANDBOX_URL;
28
- return {
29
- MERCHANT_KEY,
30
- MERCHANT_ID,
31
- API_URL,
32
- SDK_VERSION
33
- };
34
- };
35
- const startPayment = async (paymentData) => {
36
- const currency = paymentData.currency || 'HUF';
37
- const { MERCHANT_KEY, MERCHANT_ID, API_URL, SDK_VERSION } = getSimplePayConfig(currency);
38
- simplepayLogger({ MERCHANT_KEY, MERCHANT_ID, API_URL });
39
- if (!MERCHANT_KEY || !MERCHANT_ID) {
40
- throw new Error('Missing SimplePay configuration');
41
- }
42
- const requestBody = {
43
- salt: crypto.randomBytes(16).toString('hex'),
44
- merchant: MERCHANT_ID,
45
- orderRef: paymentData.orderRef,
46
- currency,
47
- customerEmail: paymentData.customerEmail,
48
- language: paymentData.language || 'HU',
49
- sdkVersion: SDK_VERSION,
50
- methods: [paymentData.method || 'CARD'],
51
- total: String(paymentData.total),
52
- timeout: new Date(Date.now() + 30 * 60 * 1000)
53
- .toISOString()
54
- .replace(/\.\d{3}Z$/, '+00:00'),
55
- url: process.env.SIMPLEPAY_REDIRECT_URL || 'http://url.to.redirect',
56
- invoice: paymentData.invoice,
57
- };
58
- const bodyString = prepareRequestBody(requestBody);
59
- const signature = generateSignature(bodyString, MERCHANT_KEY);
60
- simplepayLogger({ bodyString, signature });
61
- try {
62
- const response = await fetch(API_URL, {
63
- method: 'POST',
64
- headers: {
65
- 'Content-Type': 'application/json',
66
- 'Signature': signature,
67
- },
68
- body: bodyString,
69
- });
70
- simplepayLogger({ response });
71
- if (!response.ok) {
72
- throw new Error(`SimplePay API error: ${response.status}`);
73
- }
74
- const responseSignature = response.headers.get('Signature');
75
- simplepayLogger({ responseSignature });
76
- if (!responseSignature) {
77
- throw new Error('Missing response signature');
78
- }
79
- const responseText = await response.text();
80
- const responseJSON = JSON.parse(responseText);
81
- simplepayLogger({ responseText, responseJSON });
82
- if (responseJSON.errorCodes) {
83
- throw new Error(`SimplePay API error: ${responseJSON.errorCodes}`);
84
- }
85
- if (!checkSignature(responseText, responseSignature, MERCHANT_KEY)) {
86
- throw new Error('Invalid response signature');
87
- }
88
- return responseJSON;
89
- }
90
- catch (error) {
91
- console.error('SimplePay payment start error:', error);
92
- throw error;
93
- }
94
- };
95
- const getCurrencyFromMerchantId = (merchantId) => {
96
- const currency = Object.entries(process.env)
97
- .find(([key, value]) => key.startsWith('SIMPLEPAY_MERCHANT_ID_') && value === merchantId)?.[0]?.replace('SIMPLEPAY_MERCHANT_ID_', '');
98
- if (!currency) {
99
- throw new Error(`Merchant id not found in the environment: ${merchantId}`);
100
- }
101
- return currency;
102
- };
103
- const getPaymentResponse = (r, signature) => {
104
- signature = decodeURIComponent(signature);
105
- signature = Buffer.from(signature, 'base64').toString('utf-8');
106
- const rDecoded = Buffer.from(r, 'base64').toString('utf-8');
107
- const rDecodedJSON = JSON.parse(rDecoded);
108
- const currency = getCurrencyFromMerchantId(rDecodedJSON.m);
109
- const { MERCHANT_KEY } = getSimplePayConfig(currency);
110
- if (!checkSignature(rDecoded, signature, MERCHANT_KEY || '')) {
111
- simplepayLogger({ rDecoded, signature });
112
- throw new Error('Invalid response signature');
113
- }
114
- const responseJson = JSON.parse(rDecoded);
115
- const response = {
116
- responseCode: responseJson.r,
117
- transactionId: responseJson.t,
118
- event: responseJson.e,
119
- merchantId: responseJson.m,
120
- orderId: responseJson.o,
121
- };
122
- return response;
123
- };
124
- export { startPayment, getPaymentResponse, getSimplePayConfig, generateSignature, checkSignature, getCurrencyFromMerchantId };
125
- //# sourceMappingURL=index.js.map
88
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAmF,UAAU,EAAE,MAAM,SAAS,CAAA;AAErH,sCAAsC;AAEtC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAC1C,OAAM;IACV,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,WAAmB,EAAE,EAAE;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACzB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,YAAoB,EAAE,SAAiB,EAAE,WAAmB,EAAE,EAAE,CACpF,SAAS,KAAK,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;AAE9D,uGAAuG;AACvG,MAAM,kBAAkB,GAAG,CAAC,IAA0B,EAAE,EAAE,CACtD,IAAI,CAAC,SA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ACH,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EAC5B,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../__vite-browser-external","../src/types.ts","../src/index.ts"],"sourcesContent":["export default {}","type PaymentMethod = 'CARD' | 'WIRE'\n\nconst CURRENCIES = ['HUF', 'EUR', 'USD'] as const\ntype Currency = typeof CURRENCIES[number]\n\nconst LANGUAGES = [\n 'AR', // Arabic\n 'BG', // Bulgarian\n 'CS', // Czech\n 'DE', // German\n 'EN', // English\n 'ES', // Spanish\n 'FR', // French\n 'IT', // Italian\n 'HR', // Croatian\n 'HU', // Hungarian\n 'PL', // Polish\n 'RO', // Romanian\n 'RU', // Russian\n 'SK', // Slovak\n 'TR', // Turkish\n 'ZH', // Chinese\n] as const\ntype Language = typeof LANGUAGES[number]\n\ninterface PaymentData {\n orderRef: string\n total: number | string\n customerEmail: string\n currency?: Currency\n language?: Language\n method?: PaymentMethod\n invoice?: {\n name: string\n country: string\n state: string\n city: string\n zip: string\n address: string\n address2?: string\n phone?: string\n }\n}\n\ninterface SimplePayRequestBody extends Omit<PaymentData, 'total'> {\n total: string\n salt: string\n merchant: string\n sdkVersion: string\n methods: PaymentMethod[]\n timeout: string\n url: string\n}\n\ninterface SimplePayResponse {\n salt: string\n merchant: string\n orderRef: string\n currency: Currency\n transactionId: string\n timeout: string\n total: string\n paymentUrl: string\n errorCodes?: string[]\n}\n\ninterface SimplepayResult {\n r: number // response code\n t: string // transaction id\n e: 'success' | 'fail' | 'timeout' | 'cancel' // event\n m: string // merchant id\n o: string // order id\n}\n\nexport { PaymentData, SimplePayRequestBody, SimplePayResponse, SimplepayResult, CURRENCIES, Currency, PaymentMethod, LANGUAGES, Language }","import crypto from 'crypto'\nimport { PaymentData, SimplePayRequestBody, SimplePayResponse, SimplepayResult, Currency, CURRENCIES } from './types'\n\n// Existing interfaces remain the same\n\nconst simplepayLogger = (...args: any[]) => {\n if (process.env.SIMPLEPAY_LOGGER !== 'true') {\n return\n }\n console.log(...args)\n}\n\nconst generateSignature = (body: string, merchantKey: string) => {\n const hmac = crypto.createHmac('sha384', merchantKey.trim())\n hmac.update(body, 'utf8')\n return hmac.digest('base64')\n}\n\nconst checkSignature = (responseText: string, signature: string, merchantKey: string) =>\n signature === generateSignature(responseText, merchantKey)\n\n// escaping slashes for the request body to prevent strange SimplePay API errors (eg Missing Signature)\nconst prepareRequestBody = (body: SimplePayRequestBody) =>\n JSON.stringify(body).replace(/\\//g, '\\\\/')\n\n\nconst getSimplePayConfig = (currency: Currency) => {\n if (!CURRENCIES.includes(currency)) {\n throw new Error(`Unsupported currency: ${currency}`)\n }\n\n const SIMPLEPAY_API_URL = 'https://secure.simplepay.hu/payment/v2'\n const SIMPLEPAY_SANDBOX_URL = 'https://sandbox.simplepay.hu/payment/v2/start'\n const SDK_VERSION = 'SimplePayV2.1_Rrd_0.5.0'\n const MERCHANT_KEY = process.env[`SIMPLEPAY_MERCHANT_KEY_${currency}`]\n const MERCHANT_ID = process.env[`SIMPLEPAY_MERCHANT_ID_${currency}`]\n const API_URL = process.env.SIMPLEPAY_PRODUCTION === 'true' ? SIMPLEPAY_API_URL : SIMPLEPAY_SANDBOX_URL\n\n return {\n MERCHANT_KEY,\n MERCHANT_ID,\n API_URL,\n SDK_VERSION\n }\n}\n\nconst startPayment = async (paymentData: PaymentData) => {\n const currency = paymentData.currency || 'HUF'\n const { MERCHANT_KEY, MERCHANT_ID, API_URL, SDK_VERSION } = getSimplePayConfig(currency)\n simplepayLogger({ MERCHANT_KEY, MERCHANT_ID, API_URL })\n\n if (!MERCHANT_KEY || !MERCHANT_ID) {\n throw new Error('Missing SimplePay configuration')\n }\n\n const requestBody: SimplePayRequestBody = {\n salt: crypto.randomBytes(16).toString('hex'),\n merchant: MERCHANT_ID,\n orderRef: paymentData.orderRef,\n currency,\n customerEmail: paymentData.customerEmail,\n language: paymentData.language || 'HU',\n sdkVersion: SDK_VERSION,\n methods: [paymentData.method || 'CARD'],\n total: String(paymentData.total),\n timeout: new Date(Date.now() + 30 * 60 * 1000)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, '+00:00'),\n url: process.env.SIMPLEPAY_REDIRECT_URL || 'http://url.to.redirect',\n invoice: paymentData.invoice,\n }\n\n const bodyString = prepareRequestBody(requestBody)\n const signature = generateSignature(bodyString, MERCHANT_KEY)\n simplepayLogger({ bodyString, signature })\n\n try {\n const response = await fetch(API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Signature': signature,\n },\n body: bodyString,\n })\n\n simplepayLogger({ response })\n\n if (!response.ok) {\n throw new Error(`SimplePay API error: ${response.status}`)\n }\n\n const responseSignature = response.headers.get('Signature')\n simplepayLogger({ responseSignature })\n if (!responseSignature) {\n throw new Error('Missing response signature')\n }\n\n const responseText = await response.text()\n const responseJSON = JSON.parse(responseText) as SimplePayResponse\n simplepayLogger({ responseText, responseJSON })\n\n if (responseJSON.errorCodes) {\n throw new Error(`SimplePay API error: ${responseJSON.errorCodes}`)\n }\n\n if (!checkSignature(responseText, responseSignature, MERCHANT_KEY)) {\n throw new Error('Invalid response signature')\n }\n\n return responseJSON\n\n } catch (error) {\n throw error\n }\n}\n\nconst getCurrencyFromMerchantId = (merchantId: string) => {\n const currency = Object.entries(process.env)\n .find(([key, value]) =>\n key.startsWith('SIMPLEPAY_MERCHANT_ID_') && value === merchantId\n )?.[0]?.replace('SIMPLEPAY_MERCHANT_ID_', '') as Currency\n if (!currency) {\n throw new Error(`Merchant id not found in the environment: ${merchantId}`)\n }\n return currency\n}\n\nconst getPaymentResponse = (r: string, signature: string) => {\n signature = decodeURIComponent(signature)\n signature = Buffer.from(signature, 'base64').toString('utf-8')\n const rDecoded = Buffer.from(r, 'base64').toString('utf-8')\n const rDecodedJSON = JSON.parse(rDecoded)\n const currency = getCurrencyFromMerchantId(rDecodedJSON.m)\n const { MERCHANT_KEY } = getSimplePayConfig(currency as Currency)\n\n if (!checkSignature(rDecoded, signature, MERCHANT_KEY || '')) {\n simplepayLogger({ rDecoded, signature })\n throw new Error('Invalid response signature')\n }\n\n const responseJson: SimplepayResult = JSON.parse(rDecoded)\n const response = {\n responseCode: responseJson.r,\n transactionId: responseJson.t,\n event: responseJson.e,\n merchantId: responseJson.m,\n orderRef: responseJson.o,\n }\n\n return response\n}\n\nexport {\n startPayment,\n getPaymentResponse,\n getSimplePayConfig,\n generateSignature,\n checkSignature,\n getCurrencyFromMerchantId\n}"],"names":["crypto","CURRENCIES","simplepayLogger","args","generateSignature","body","merchantKey","hmac","checkSignature","responseText","signature","prepareRequestBody","getSimplePayConfig","currency","SIMPLEPAY_API_URL","SIMPLEPAY_SANDBOX_URL","SDK_VERSION","MERCHANT_KEY","MERCHANT_ID","API_URL","startPayment","paymentData","requestBody","bodyString","response","responseSignature","responseJSON","error","getCurrencyFromMerchantId","merchantId","_a","_b","key","value","getPaymentResponse","r","rDecoded","rDecodedJSON","responseJson"],"mappings":"AAAA,MAAeA,IAAA,CAAA,GCETC,IAAa,CAAC,OAAO,OAAO,KAAK,GCGjCC,IAAkB,IAAIC,MAAgB;AACpC,EAAA,QAAQ,IAAI,qBAAqB,UAG7B,QAAA,IAAI,GAAGA,CAAI;AACvB,GAEMC,IAAoB,CAACC,GAAcC,MAAwB;AAC7D,QAAMC,IAAOP,EAAO,WAAW,UAAUM,EAAY,MAAM;AACtD,SAAAC,EAAA,OAAOF,GAAM,MAAM,GACjBE,EAAK,OAAO,QAAQ;AAC/B,GAEMC,IAAiB,CAACC,GAAsBC,GAAmBJ,MAC7DI,MAAcN,EAAkBK,GAAcH,CAAW,GAGvDK,IAAqB,CAACN,MACxB,KAAK,UAAUA,CAAI,EAAE,QAAQ,OAAO,KAAK,GAGvCO,IAAqB,CAACC,MAAuB;AAC/C,MAAI,CAACZ,EAAW,SAASY,CAAQ;AAC7B,UAAM,IAAI,MAAM,yBAAyBA,CAAQ,EAAE;AAGvD,QAAMC,IAAoB,0CACpBC,IAAwB,iDACxBC,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,IAAe,KAAK,MAAMD,CAAQ,GAClCvB,IAAWe,EAA0BS,EAAa,CAAC,GACnD,EAAE,cAAApB,EAAA,IAAiBL,EAAmBC,CAAoB;AAEhE,MAAI,CAACL,EAAe4B,GAAU1B,GAAWO,KAAgB,EAAE;AACvC,UAAAf,EAAA,EAAE,UAAAkC,GAAU,WAAA1B,GAAW,GACjC,IAAI,MAAM,4BAA4B;AAG1C,QAAA4B,IAAgC,KAAK,MAAMF,CAAQ;AASlD,SARU;AAAA,IACb,cAAcE,EAAa;AAAA,IAC3B,eAAeA,EAAa;AAAA,IAC5B,OAAOA,EAAa;AAAA,IACpB,YAAYA,EAAa;AAAA,IACzB,UAAUA,EAAa;AAAA,EAC3B;AAGJ;"}
package/package.json CHANGED
@@ -1,25 +1,27 @@
1
1
  {
2
2
  "name": "simplepay-js-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "A Node.js utility for SimplePay payment integration",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/rrd108/simplepay-js-sdk"
8
8
  },
9
9
  "type": "module",
10
- "main": "dist/index.js",
10
+ "main": "./dist/index.js",
11
11
  "exports": {
12
- ".": "./dist/index.js",
13
- "./types": "./dist/types.js"
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
14
16
  },
15
- "types": "dist/index.d.ts",
17
+ "types": "./dist/index.d.ts",
16
18
  "files": [
17
19
  "dist",
18
20
  "src"
19
21
  ],
20
22
  "scripts": {
21
- "build": "tsc",
22
- "prepare": "npm run build",
23
+ "build": "vite build",
24
+ "types": "tsc --emitDeclarationOnly",
23
25
  "test": "vitest --run",
24
26
  "test:watch": "vitest",
25
27
  "release": "bash ./release.sh",
@@ -35,10 +37,12 @@
35
37
  "license": "MIT",
36
38
  "devDependencies": {
37
39
  "@types/node": "^22.0.0",
38
- "typescript": "^5.0.0",
40
+ "typescript": "^5.7.2",
41
+ "vite": "^6.0.3",
42
+ "vite-plugin-dts": "^4.3.0",
39
43
  "vitest": "^2.1.6"
40
44
  },
41
45
  "engines": {
42
- "node": ">=18.0.0"
46
+ "node": ">=20.0.0"
43
47
  }
44
48
  }
package/src/index.spec.ts CHANGED
@@ -5,8 +5,6 @@ import { Currency } from './types'
5
5
  const setEnv = () => {
6
6
  process.env.SIMPLEPAY_MERCHANT_ID_HUF = 'testId'
7
7
  process.env.SIMPLEPAY_MERCHANT_KEY_HUF = 'testKey'
8
- // process.env.SIMPLEPAY_MERCHANT_ID_EUR = 'P085402'
9
- // process.env.SIMPLEPAY_MERCHANT_KEY_EUR = '4?K4&!ZG3|v~6_)p0634'
10
8
  process.env.SIMPLEPAY_MERCHANT_ID_EUR = 'merchantEuroId'
11
9
  process.env.SIMPLEPAY_MERCHANT_KEY_EUR = 'secretEuroKey'
12
10
  }
@@ -125,7 +123,7 @@ describe('SimplePay SDK Tests', () => {
125
123
  transactionId: 504233881,
126
124
  event: 'SUCCESS',
127
125
  merchantId: 'merchantEuroId',
128
- orderId: 'c-1-eur'
126
+ orderRef: 'c-1-eur'
129
127
  })
130
128
  })
131
129
 
package/src/index.ts CHANGED
@@ -31,7 +31,7 @@ const getSimplePayConfig = (currency: Currency) => {
31
31
 
32
32
  const SIMPLEPAY_API_URL = 'https://secure.simplepay.hu/payment/v2'
33
33
  const SIMPLEPAY_SANDBOX_URL = 'https://sandbox.simplepay.hu/payment/v2/start'
34
- const SDK_VERSION = 'SimplePayV2.1_Rrd_0.4.0'
34
+ const SDK_VERSION = 'SimplePayV2.1_Rrd_0.6.0'
35
35
  const MERCHANT_KEY = process.env[`SIMPLEPAY_MERCHANT_KEY_${currency}`]
36
36
  const MERCHANT_ID = process.env[`SIMPLEPAY_MERCHANT_ID_${currency}`]
37
37
  const API_URL = process.env.SIMPLEPAY_PRODUCTION === 'true' ? SIMPLEPAY_API_URL : SIMPLEPAY_SANDBOX_URL
@@ -111,7 +111,6 @@ const startPayment = async (paymentData: PaymentData) => {
111
111
  return responseJSON
112
112
 
113
113
  } catch (error) {
114
- console.error('SimplePay payment start error:', error)
115
114
  throw error
116
115
  }
117
116
  }
@@ -146,7 +145,7 @@ const getPaymentResponse = (r: string, signature: string) => {
146
145
  transactionId: responseJson.t,
147
146
  event: responseJson.e,
148
147
  merchantId: responseJson.m,
149
- orderId: responseJson.o,
148
+ orderRef: responseJson.o,
150
149
  }
151
150
 
152
151
  return response
package/src/types.ts CHANGED
@@ -3,12 +3,32 @@ type PaymentMethod = 'CARD' | 'WIRE'
3
3
  const CURRENCIES = ['HUF', 'EUR', 'USD'] as const
4
4
  type Currency = typeof CURRENCIES[number]
5
5
 
6
+ const LANGUAGES = [
7
+ 'AR', // Arabic
8
+ 'BG', // Bulgarian
9
+ 'CS', // Czech
10
+ 'DE', // German
11
+ 'EN', // English
12
+ 'ES', // Spanish
13
+ 'FR', // French
14
+ 'IT', // Italian
15
+ 'HR', // Croatian
16
+ 'HU', // Hungarian
17
+ 'PL', // Polish
18
+ 'RO', // Romanian
19
+ 'RU', // Russian
20
+ 'SK', // Slovak
21
+ 'TR', // Turkish
22
+ 'ZH', // Chinese
23
+ ] as const
24
+ type Language = typeof LANGUAGES[number]
25
+
6
26
  interface PaymentData {
7
27
  orderRef: string
8
28
  total: number | string
9
29
  customerEmail: string
10
30
  currency?: Currency
11
- language?: string
31
+ language?: Language
12
32
  method?: PaymentMethod
13
33
  invoice?: {
14
34
  name: string
@@ -52,4 +72,4 @@ interface SimplepayResult {
52
72
  o: string // order id
53
73
  }
54
74
 
55
- export { PaymentData, SimplePayRequestBody, SimplePayResponse, SimplepayResult, CURRENCIES, Currency, PaymentMethod }
75
+ export { PaymentData, SimplePayRequestBody, SimplePayResponse, SimplepayResult, CURRENCIES, Currency, PaymentMethod, LANGUAGES, Language }
package/dist/types.d.ts DELETED
@@ -1,49 +0,0 @@
1
- type PaymentMethod = 'CARD' | 'WIRE';
2
- declare const CURRENCIES: readonly ["HUF", "EUR", "USD"];
3
- type Currency = typeof CURRENCIES[number];
4
- interface PaymentData {
5
- orderRef: string;
6
- total: number | string;
7
- customerEmail: string;
8
- currency?: Currency;
9
- language?: string;
10
- method?: PaymentMethod;
11
- invoice?: {
12
- name: string;
13
- country: string;
14
- state: string;
15
- city: string;
16
- zip: string;
17
- address: string;
18
- address2?: string;
19
- phone?: string;
20
- };
21
- }
22
- interface SimplePayRequestBody extends Omit<PaymentData, 'total'> {
23
- total: string;
24
- salt: string;
25
- merchant: string;
26
- sdkVersion: string;
27
- methods: PaymentMethod[];
28
- timeout: string;
29
- url: string;
30
- }
31
- interface SimplePayResponse {
32
- salt: string;
33
- merchant: string;
34
- orderRef: string;
35
- currency: Currency;
36
- transactionId: string;
37
- timeout: string;
38
- total: string;
39
- paymentUrl: string;
40
- errorCodes?: string[];
41
- }
42
- interface SimplepayResult {
43
- r: number;
44
- t: string;
45
- e: 'success' | 'fail' | 'timeout' | 'cancel';
46
- m: string;
47
- o: string;
48
- }
49
- export { PaymentData, SimplePayRequestBody, SimplePayResponse, SimplepayResult, CURRENCIES, Currency, PaymentMethod };
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- const CURRENCIES = ['HUF', 'EUR', 'USD'];
2
- export { CURRENCIES };
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;AAoDjD,OAAO,EAAyE,UAAU,EAA2B,CAAA"}