@unchainedshop/plugins 4.8.13 → 4.8.14
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.
|
@@ -58,19 +58,31 @@ const PaypalCheckout = {
|
|
|
58
58
|
throw new Error('You have to provide orderID in paymentContext');
|
|
59
59
|
}
|
|
60
60
|
try {
|
|
61
|
-
const request = new checkoutNodeJssdk.orders.OrdersGetRequest(orderID);
|
|
62
61
|
const client = new checkoutNodeJssdk.core.PayPalHttpClient(environment());
|
|
63
|
-
const
|
|
62
|
+
const getRequest = new checkoutNodeJssdk.orders.OrdersGetRequest(orderID);
|
|
63
|
+
let paypalResult = (await client.execute(getRequest)).result;
|
|
64
|
+
if (paypalResult.status === 'APPROVED') {
|
|
65
|
+
const captureRequest = new checkoutNodeJssdk.orders.OrdersCaptureRequest(orderID);
|
|
66
|
+
captureRequest.requestBody({});
|
|
67
|
+
paypalResult = (await client.execute(captureRequest)).result;
|
|
68
|
+
}
|
|
69
|
+
if (paypalResult.status !== 'COMPLETED') {
|
|
70
|
+
throw new Error(`PayPal order not completed (status: ${paypalResult.status})`);
|
|
71
|
+
}
|
|
72
|
+
const capture = paypalResult.purchase_units?.[0]?.payments?.captures?.find((c) => c.status === 'COMPLETED');
|
|
73
|
+
if (!capture) {
|
|
74
|
+
throw new Error('PayPal order has no completed capture');
|
|
75
|
+
}
|
|
64
76
|
const pricing = OrderPricingSheet({
|
|
65
77
|
calculation: order.calculation,
|
|
66
78
|
currencyCode: order.currencyCode,
|
|
67
79
|
});
|
|
68
80
|
const ourTotal = roundToDecimals(pricing.total({ useNetPrice: false }).amount / 100, 2);
|
|
69
|
-
const
|
|
70
|
-
if (ourTotal ===
|
|
81
|
+
const paidTotal = roundToDecimals(capture.amount.value, 2);
|
|
82
|
+
if (ourTotal === paidTotal && capture.amount.currency_code === order.currencyCode) {
|
|
71
83
|
return order;
|
|
72
84
|
}
|
|
73
|
-
logger.warn('Missmatch PAYPAL ORDER', JSON.stringify(
|
|
85
|
+
logger.warn('Missmatch PAYPAL ORDER', JSON.stringify(paypalResult, null, 2));
|
|
74
86
|
logger.debug('OUR ORDER', order);
|
|
75
87
|
logger.debug('OUR PRICE', pricing);
|
|
76
88
|
throw new Error(`Payment mismatch`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
3
|
"description": "Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.14",
|
|
5
5
|
"main": "lib/plugins-index.js",
|
|
6
6
|
"types": "lib/plugins-index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@aws-sdk/client-eventbridge": ">= 3.714 < 4",
|
|
55
55
|
"@paypal/checkout-server-sdk": "1.x",
|
|
56
|
-
"@redis/client": ">= 1 <
|
|
56
|
+
"@redis/client": ">= 1 < 7",
|
|
57
57
|
"@scure/bip32": ">= 2",
|
|
58
58
|
"@scure/btc-signer": ">= 2",
|
|
59
59
|
"mime": ">= 4 < 5",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"express": ">= 5 < 6",
|
|
62
62
|
"fastify": ">= 5.2 < 6",
|
|
63
63
|
"minio": "8.x",
|
|
64
|
-
"nodemailer": ">= 6.9 <
|
|
64
|
+
"nodemailer": ">= 6.9 < 10",
|
|
65
65
|
"p-memoize": "8.x",
|
|
66
66
|
"stripe": ">= 19 < 23",
|
|
67
67
|
"web-push": ">= 3.6 <4",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@paypal/checkout-server-sdk": "^1.0.3",
|
|
116
|
-
"@redis/client": "^
|
|
116
|
+
"@redis/client": "^6.0.0",
|
|
117
117
|
"@scure/bip32": "^2.0.0",
|
|
118
118
|
"@scure/btc-signer": "^2.0.0",
|
|
119
119
|
"@types/express": "^5.0.3",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"express": "^5.1.0",
|
|
123
123
|
"fastify": "^5.4.0",
|
|
124
124
|
"minio": "^8.0.5",
|
|
125
|
-
"nodemailer": "^
|
|
125
|
+
"nodemailer": "^9.0.0",
|
|
126
126
|
"p-memoize": "^8.0.0",
|
|
127
127
|
"stripe": "^22.0.2",
|
|
128
128
|
"typescript": "^5.8.3",
|