paymob-widget-alpha 1.0.10 → 1.0.11

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 +10 -10
  2. package/main.js +5 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -46,10 +46,10 @@ new PaymobWidget({
46
46
  theme: 'primary',
47
47
  customerCanSelect: true, // Enable the customer to select a plan.
48
48
  onSubmit: (plan) => {
49
- // `onSubmit` is called only in selectable mode (`customerCanSelect: true`),
50
- // when the user selects an installment plan and clicks **Buy now** in the widget.
51
- // The callback receives a `plan` object (e.g. `id`, `tenure`, `amount`) so you can create an order / continue your checkout flow in your app.
52
- // plan = { id: 123, tenure: 12, amount: 250 }
49
+ // `onSubmit` is called when the user clicks **Buy now**.
50
+ // In selectable mode (`customerCanSelect: true`), `plan` will be provided after the user selects a plan.
51
+ // plan = { id: 123, tenure: 12, amount: 250 }
52
+ // In non-selectable mode (`customerCanSelect: false`), `onSubmit` is called with no payload.
53
53
  },
54
54
  });
55
55
  ```
@@ -67,7 +67,7 @@ The full list of properties is as follows:
67
67
  | currency | String | No | Currency code. Default: `"EGP"`. |
68
68
  | integrationId | Number | No | Paymob integration ID. If provided, it will be sent when fetching installment plans. |
69
69
  | customerCanSelect | Boolean | No | If `true`, the widget allows selecting a plan and will show **Buy now** actions. Default: `false`. |
70
- | onSubmit | Function | No | Selectable mode only (`customerCanSelect: true`). Called when the user selects a plan and clicks **Buy now**. Receives `{ id, tenure, amount }`. |
70
+ | onSubmit | Function | No | Called when the user clicks **Buy now**. In selectable mode (`customerCanSelect: true`), it receives `{ id, tenure, amount }`. In non-selectable mode (`customerCanSelect: false`), it is called with no payload. |
71
71
 
72
72
  ### `onSubmit` payload
73
73
 
@@ -112,14 +112,14 @@ The full list of properties is as follows:
112
112
  elementId: 'paymob-widget',
113
113
  amount: 1000,
114
114
  currency: 'EGP',
115
- integrationId: 123456, // optional
115
+ integrationId: 123, // optional
116
116
  theme: 'primary', // "primary" | "light" | "dark"
117
117
  customerCanSelect: true, // Enable the customer to select a plan.
118
118
  onSubmit: (plan) => {
119
- // `onSubmit` is called only in selectable mode (`customerCanSelect: true`),
120
- // when the user selects an installment plan and clicks **Buy now** in the widget.
121
- // The callback receives a `plan` object (e.g. `id`, `tenure`, `amount`) so you can create an order / continue your checkout flow in your app.
122
- // plan = { id: 123, tenure: 12, amount: 250 }
119
+ // `onSubmit` is called when the user clicks **Buy now**.
120
+ // In selectable mode (`customerCanSelect: true`), `plan` will be provided after the user selects a plan.
121
+ // plan = { id: 123, tenure: 12, amount: 250 }
122
+ // In non-selectable mode (`customerCanSelect: false`), `onSubmit` is called with no payload.
123
123
  },
124
124
  });
125
125
  };
package/main.js CHANGED
@@ -8137,15 +8137,14 @@ function Widget({
8137
8137
  setSubmitError('Please select a plan.');
8138
8138
  return;
8139
8139
  }
8140
- if (!selectedInstallment) {
8141
- setSubmitError(null);
8142
- setIsModalOpen(false);
8143
- return;
8144
- }
8145
8140
  setIsSubmitting(true);
8146
8141
  setSubmitError(null);
8147
8142
  try {
8148
- onSubmit(selectedInstallment);
8143
+ if (selectedInstallment) {
8144
+ onSubmit(selectedInstallment);
8145
+ } else {
8146
+ onSubmit();
8147
+ }
8149
8148
  } finally {
8150
8149
  setIsSubmitting(false);
8151
8150
  setIsModalOpen(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-widget-alpha",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "keywords": ["paymob","widget","paymob-widget"],
5
5
  "main": "./main.js",
6
6
  "license": "MIT",