@fire-spark/payments-placetopay-checkout 0.23.0 → 0.25.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -10
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PaymentError, createPaymentError, definePaymentErrors, toPaymentError } from "@fire-spark/payments";
1
+ import { PaymentError, createPaymentError, definePaymentErrors, paymentResultAmount, toPaymentError } from "@fire-spark/payments";
2
2
  //#region src/constants.ts
3
3
  const PLACETOPAY_PROVIDER = "place_to_pay";
4
4
  /** Query param the API adds to `returnUrl` / `cancelUrl`: our attempt. */
@@ -109,7 +109,7 @@ const failedResult = (ctx, error, metadata) => {
109
109
  };
110
110
  return {
111
111
  status: "FAILED",
112
- amount: ctx.amount.value,
112
+ ...paymentResultAmount(ctx.amount.value),
113
113
  metadata: m,
114
114
  error
115
115
  };
@@ -118,15 +118,19 @@ const failedResult = (ctx, error, metadata) => {
118
118
  const placetopayResultOf = (ctx, outcome) => {
119
119
  const metadata = placetopayMetadataOf(ctx, outcome);
120
120
  const amount = ctx.amount.value;
121
- if (outcome.status === "PAID") return {
122
- status: "PAID",
123
- amount,
124
- metadata,
125
- details: cardDetailsOf(outcome)
126
- };
121
+ const exact = paymentResultAmount(amount);
122
+ if (outcome.status === "PAID") {
123
+ const details = cardDetailsOf(outcome);
124
+ return {
125
+ status: "PAID",
126
+ ...exact,
127
+ metadata,
128
+ details
129
+ };
130
+ }
127
131
  if (outcome.status === "PENDING") return {
128
132
  status: "PENDING",
129
- amount,
133
+ ...exact,
130
134
  metadata
131
135
  };
132
136
  const error = toPaymentError(placetopayErrors, {
@@ -197,7 +201,7 @@ const placetopayCheckoutPayments = (options) => {
197
201
  };
198
202
  return {
199
203
  status: "PENDING",
200
- amount: ctx.amount.value,
204
+ ...paymentResultAmount(ctx.amount.value),
201
205
  metadata
202
206
  };
203
207
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fire-spark/payments-placetopay-checkout",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Fire Spark PlacetoPay adapter (Ecuador): card payments through the WebCheckout redirect on the web, verified and reversed by the Fire Spark API",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -17,8 +17,8 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "@fire-spark/payments": "^0.23.0",
21
- "@fire-spark/types": "^0.23.0"
20
+ "@fire-spark/payments": "^0.25.0",
21
+ "@fire-spark/types": "^0.25.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "tsdown": "^0.22.14",