paymob-widget-alpha 1.0.2 → 1.0.3

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 (3) hide show
  1. package/README.md +1 -7
  2. package/main.js +27 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -118,14 +118,8 @@ The full list of properties is as follows:
118
118
 
119
119
  ## Notes
120
120
 
121
- - **Rendering**: The widget renders a React app into your `elementId` container.
121
+ - **Rendering**: The widget renders a Installment Widget into your `elementId` container.
122
122
  - **Isolation**: UI is rendered inside a Shadow DOM wrapper to reduce CSS conflicts with the host page.
123
- - **API base URL**: Base URL is resolved from the key prefix (e.g. `egy_`, `are_`, `sau_`, `pak_`, `omn_`) using `publicKey` (and `clientSecret` as a fallback).
124
- - **Installment plans endpoint**: The widget fetches plans using:
125
- - `POST /api/ecommerce/installment-plans/product` with `{ public_key, amount_cents, currency, integration_id? }`
126
123
 
127
- ## Troubleshooting
128
124
 
129
- - **Container not found**: Ensure an element exists with the same id passed in `elementId`.
130
- - **No plans available**: Verify `publicKey`, `currency`, `amount`, and that installment plans exist for the given product/amount.
131
125
 
package/main.js CHANGED
@@ -7846,13 +7846,19 @@ function normalizeBanksWithPlans(installmentPlansProductPayload) {
7846
7846
  var _bankItem$installment, _axios$defaults$baseU, _bankItem$bank_logo;
7847
7847
  const bankInstallmentPlans = (_bankItem$installment = bankItem.installment_plans) != null ? _bankItem$installment : [];
7848
7848
  const installmentOptions = bankInstallmentPlans.map(planFromProduct => {
7849
+ var _planFromProduct$purc, _planFromProduct$conv;
7849
7850
  const interestRate = Number(planFromProduct.interest_rate);
7850
- const badge = interestRate === 0 ? '0% Interest' : `${interestRate}% Interest`;
7851
+ const purchaseFees = Number((_planFromProduct$purc = planFromProduct.purchase_fees) != null ? _planFromProduct$purc : 0);
7852
+ const convenienceFees = Number((_planFromProduct$conv = planFromProduct.convenience_fees) != null ? _planFromProduct$conv : 0);
7853
+ const fees = purchaseFees + convenienceFees;
7854
+ const noFees = !(planFromProduct.purchase_fees || planFromProduct.convenience_fees);
7851
7855
  return {
7852
7856
  id: planFromProduct.id,
7853
7857
  months: Number(planFromProduct.tenure),
7854
7858
  monthlyAmount: Number(planFromProduct.installment_amount),
7855
- badge
7859
+ interestRate,
7860
+ fees,
7861
+ noFees
7856
7862
  };
7857
7863
  });
7858
7864
  const minimumMonthlyFromProduct = Number(bankItem.minimum_plan_amount);
@@ -8170,17 +8176,31 @@ function Widget({
8170
8176
  children: [installmentOption.months, " Months"]
8171
8177
  })]
8172
8178
  }),
8173
- hintText: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
8179
+ hintText: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
8174
8180
  style: {
8175
8181
  display: 'flex',
8176
8182
  alignItems: 'center',
8177
- gap: '10px'
8183
+ gap: '8px',
8184
+ flexWrap: 'wrap'
8178
8185
  },
8179
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Badge, {
8180
- text: installmentOption.badge,
8186
+ children: [installmentOption.noFees && /*#__PURE__*/(0,jsx_runtime.jsx)(Badge, {
8187
+ text: "No fees",
8181
8188
  color: "green",
8182
8189
  size: "sm"
8183
- })
8190
+ }), installmentOption.fees > 0 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
8191
+ style: {
8192
+ color: '#475467',
8193
+ fontSize: '14px',
8194
+ fontWeight: 400,
8195
+ lineHeight: '18px',
8196
+ letterSpacing: '0.16px'
8197
+ },
8198
+ children: ["Including ", currency, " ", installmentOption.fees, " fees"]
8199
+ }), installmentOption.interestRate === 0 && /*#__PURE__*/(0,jsx_runtime.jsx)(Badge, {
8200
+ text: "0% Interest",
8201
+ color: "green",
8202
+ size: "sm"
8203
+ })]
8184
8204
  })
8185
8205
  }, installmentOption.id))
8186
8206
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-widget-alpha",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "keywords": ["paymob","widget","paymob-widget"],
5
5
  "main": "./main.js",
6
6
  "license": "MIT",