@cloudcommerce/app-custom-payment 2.9.0 → 2.10.1
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/lib/custom-payment-create-transaction.js.map +1 -1
- package/lib/custom-payment-list-payments.js.map +1 -1
- package/package.json +9 -3
- package/.turbo/turbo-build.log +0 -5
- package/CHANGELOG.md +0 -1
- package/src/custom-payment-create-transaction.ts +0 -67
- package/src/custom-payment-list-payments.ts +0 -96
- package/src/custom-payment.ts +0 -11
- package/src/index.ts +0 -1
- package/tsconfig.json +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-payment-create-transaction.js","sourceRoot":"","sources":["../src/custom-payment-create-transaction.ts"],"names":[],"mappings":"AAMA,eAAe,KAAK,EAAE,OAAsB,EAAE,EAAE;IAC9C,4BAA4B;IAC5B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAiC,CAAC;IACzD,yBAAyB;IACzB,MAAM,SAAS,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAEtE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEjC,IAAI,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC;IACnD,IAAI,iBAAiB,EAAE;
|
|
1
|
+
{"version":3,"file":"custom-payment-create-transaction.js","sourceRoot":"","sources":["../src/custom-payment-create-transaction.ts"],"names":[],"mappings":"AAMA,eAAe,KAAK,EAAE,OAAsB,EAAE,EAAE;IAC9C,4BAA4B;IAC5B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAiC,CAAC;IACzD,yBAAyB;IACzB,MAAM,SAAS,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,WAA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O,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;iBAC/D,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAA6C;QAC5D,YAAY,EAAE,WAAW;QACzB,aAAa,EAAE;YACb,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC;QACD,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,MAAM,EAAE,MAAM,CAAC,KAAK;QACpB,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;QACD,KAAK,EAAE;YACL,qBAAqB;SACtB;QACD,KAAK;KACN,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,GAAG;QACX,mBAAmB,EAAE,OAAO,CAAC,WAAW,CAAC;QACzC,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-payment-list-payments.js","sourceRoot":"","sources":["../src/custom-payment-list-payments.ts"],"names":[],"mappings":"AAQA,eAAe,CAAC,IAAmB,EAAE,EAAE;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAA4B,CAAC;IACjD,4EAA4E;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC1E,2CAA2C;IAE3C,MAAM,MAAM,GAAG;QACb,GAAG,WAAW,CAAC,IAAI;QACnB,GAAG,WAAW,CAAC,WAAW;KAC3B,CAAC;IAEF,+BAA+B;IAC/B,qFAAqF;IACrF,MAAM,QAAQ,GAAyB;QACrC,gBAAgB,EAAE,EAAE;KACrB,CAAC;IAEF,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE;
|
|
1
|
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AQ,IAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;wBACnC,2BAA2B;wBAC3B,IACE,QAAQ,CAAC,QAAQ,KAAK,SAAS;+BAC5B,CAAC,CAAC,QAAQ,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK;mCAC3D,QAAQ,CAAC,eAAe,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;4BAC1D,0BAA0B;4BAC1B,QAAQ,CAAC,eAAe,GAAG;gCACzB,KAAK;gCACL,GAAG,QAAQ;6BACZ,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACjD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-custom-payment",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce app for simple custom payment methods",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"/lib",
|
|
9
|
+
"/lib-mjs",
|
|
10
|
+
"/types",
|
|
11
|
+
"/*.{js,mjs,ts}"
|
|
12
|
+
],
|
|
7
13
|
"repository": {
|
|
8
14
|
"type": "git",
|
|
9
15
|
"url": "git+https://github.com/ecomplus/cloud-commerce.git",
|
|
@@ -16,10 +22,10 @@
|
|
|
16
22
|
},
|
|
17
23
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/apps/custom-payment#readme",
|
|
18
24
|
"dependencies": {
|
|
19
|
-
"@cloudcommerce/api": "2.
|
|
25
|
+
"@cloudcommerce/api": "2.10.1"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
|
-
"@cloudcommerce/types": "2.
|
|
28
|
+
"@cloudcommerce/types": "2.10.1"
|
|
23
29
|
},
|
|
24
30
|
"scripts": {
|
|
25
31
|
"build": "bash ../../../scripts/build-lib.sh"
|
package/.turbo/turbo-build.log
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Please refer to GitHub [repository releases](https://github.com/ecomplus/cloud-commerce/releases) or monorepo unified [CHANGELOG.md](https://github.com/ecomplus/cloud-commerce/blob/main/CHANGELOG.md).
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AppModuleBody,
|
|
3
|
-
CreateTransactionParams,
|
|
4
|
-
CreateTransactionResponse,
|
|
5
|
-
} from '@cloudcommerce/types';
|
|
6
|
-
|
|
7
|
-
export default async (appData: AppModuleBody) => {
|
|
8
|
-
// treat module request body
|
|
9
|
-
const { application } = appData;
|
|
10
|
-
const params = appData.params as CreateTransactionParams;
|
|
11
|
-
// app configured options
|
|
12
|
-
const configApp = { ...application.data, ...application.hidden_data };
|
|
13
|
-
|
|
14
|
-
const { amount, buyer } = params;
|
|
15
|
-
|
|
16
|
-
let paymentMethodName = params.payment_method.name;
|
|
17
|
-
if (paymentMethodName) {
|
|
18
|
-
[paymentMethodName] = paymentMethodName.split(' ::');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let notes: string | undefined;
|
|
22
|
-
let paymentLink: string | undefined;
|
|
23
|
-
|
|
24
|
-
if (Array.isArray(configApp.payment_options) && configApp.payment_options.length) {
|
|
25
|
-
let paymentOption = configApp.payment_options.find((paymentOptionFound) => {
|
|
26
|
-
const paymentMethod = paymentOptionFound.payment_method;
|
|
27
|
-
return paymentMethod
|
|
28
|
-
&& paymentMethod.code === params.payment_method.code
|
|
29
|
-
&& (!paymentMethod.name || paymentMethod.name === paymentMethodName);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (!paymentOption) {
|
|
33
|
-
[paymentOption] = configApp.payment_options;
|
|
34
|
-
}
|
|
35
|
-
if (typeof paymentOption.text === 'string') {
|
|
36
|
-
notes = paymentOption.text.substring(0, 255);
|
|
37
|
-
}
|
|
38
|
-
if (typeof paymentOption.payment_link === 'string' && paymentOption.payment_link) {
|
|
39
|
-
paymentLink = paymentOption.payment_link
|
|
40
|
-
.replace(/{amount}/g, amount.total.toFixed(2).replace('.', ','))
|
|
41
|
-
.replace(/{email}/g, buyer.email);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const transaction: CreateTransactionResponse['transaction'] = {
|
|
46
|
-
payment_link: paymentLink,
|
|
47
|
-
intermediator: {
|
|
48
|
-
payment_method: params.payment_method,
|
|
49
|
-
},
|
|
50
|
-
currency_id: params.currency_id,
|
|
51
|
-
currency_symbol: params.currency_symbol,
|
|
52
|
-
amount: amount.total,
|
|
53
|
-
status: {
|
|
54
|
-
current: 'pending',
|
|
55
|
-
},
|
|
56
|
-
flags: [
|
|
57
|
-
'app-custom-payments',
|
|
58
|
-
],
|
|
59
|
-
notes,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
status: 200,
|
|
64
|
-
redirect_to_payment: Boolean(paymentLink),
|
|
65
|
-
transaction,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AppModuleBody,
|
|
3
|
-
ListPaymentsParams,
|
|
4
|
-
ListPaymentsResponse,
|
|
5
|
-
} from '@cloudcommerce/types';
|
|
6
|
-
|
|
7
|
-
type Gateway = ListPaymentsResponse['payment_gateways'][number]
|
|
8
|
-
|
|
9
|
-
export default (data: AppModuleBody) => {
|
|
10
|
-
const { application } = data;
|
|
11
|
-
const params = data.params as ListPaymentsParams;
|
|
12
|
-
// https://apx-mods.e-com.plus/api/v1/list_payments/schema.json?store_id=100
|
|
13
|
-
const amount = params.amount || { total: undefined, discount: undefined };
|
|
14
|
-
// const initialTotalAmount = amount.total;
|
|
15
|
-
|
|
16
|
-
const config = {
|
|
17
|
-
...application.data,
|
|
18
|
-
...application.hidden_data,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// start mounting response body
|
|
22
|
-
// https://apx-mods.e-com.plus/api/v1/list_payments/response_schema.json?store_id=100
|
|
23
|
-
const response: ListPaymentsResponse = {
|
|
24
|
-
payment_gateways: [],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
if (config.payment_options && config.payment_options.length) {
|
|
28
|
-
config.payment_options.forEach((paymentOption) => {
|
|
29
|
-
if (paymentOption.zip_range) {
|
|
30
|
-
// payment option for specific addresses only
|
|
31
|
-
const { customer } = params;
|
|
32
|
-
if (customer && customer.addresses) {
|
|
33
|
-
const address = customer.addresses.find((addr) => addr.default) || customer.addresses[0];
|
|
34
|
-
const zip = address && address.zip;
|
|
35
|
-
if (zip && (paymentOption.zip_range.min > zip || paymentOption.zip_range.max < zip)) {
|
|
36
|
-
// zip code condition not satisfied
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
label, icon, text, discount, enabled,
|
|
44
|
-
} = paymentOption;
|
|
45
|
-
if (enabled !== false) {
|
|
46
|
-
const paymentMethod = paymentOption.payment_method;
|
|
47
|
-
if (!paymentMethod || !paymentMethod.code) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (paymentOption.min_amount
|
|
51
|
-
&& (amount.total && amount.total < paymentOption.min_amount)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let paymentMethodName = paymentMethod.name || paymentMethod.code;
|
|
56
|
-
if (response.payment_gateways.find((gateway) => {
|
|
57
|
-
return gateway.payment_method && gateway.payment_method.name === paymentMethodName;
|
|
58
|
-
})) {
|
|
59
|
-
paymentMethodName += ` ::${Math.floor(Math.random() * 1000)}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const paymentGateway: Gateway = {
|
|
63
|
-
label,
|
|
64
|
-
icon,
|
|
65
|
-
text,
|
|
66
|
-
payment_method: {
|
|
67
|
-
code: paymentMethod.code,
|
|
68
|
-
name: paymentMethodName,
|
|
69
|
-
},
|
|
70
|
-
type: 'payment',
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (!amount.discount || paymentOption.cumulative_discount !== false) {
|
|
74
|
-
paymentGateway.discount = discount;
|
|
75
|
-
if (discount && discount.value > 0) {
|
|
76
|
-
// calculate discount value
|
|
77
|
-
if (
|
|
78
|
-
discount.apply_at !== 'freight'
|
|
79
|
-
&& (!response.discount_option || (response.discount_option.value
|
|
80
|
-
&& response.discount_option.value <= discount.value))) {
|
|
81
|
-
// default discount option
|
|
82
|
-
response.discount_option = {
|
|
83
|
-
label,
|
|
84
|
-
...discount,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
response.payment_gateways.push(paymentGateway);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return response;
|
|
96
|
-
};
|
package/src/custom-payment.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
2
|
-
import handleListPayments from './custom-payment-list-payments';
|
|
3
|
-
import handleCreateTransaction from './custom-payment-create-transaction';
|
|
4
|
-
|
|
5
|
-
export const listPayments = async (modBody: AppModuleBody) => {
|
|
6
|
-
return handleListPayments(modBody);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const createTransaction = async (modBody: AppModuleBody) => {
|
|
10
|
-
return handleCreateTransaction(modBody);
|
|
11
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './custom-payment';
|