paymob-pixel-alpha 1.1.6 → 1.1.8

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 (4) hide show
  1. package/README.md +204 -30
  2. package/main.js +630 -320
  3. package/package.json +1 -1
  4. package/styles.css +4 -0
package/README.md CHANGED
@@ -8,13 +8,13 @@ Paymob Web SDK, help our merchant to have the native payment experience.
8
8
  Using npm:
9
9
 
10
10
  ```bash
11
- $ npm install paymob-pixel --save
11
+ $ npm install paymob-pixel-alpha --save
12
12
  ```
13
13
 
14
14
  Once the package is installed, you can import the library using `import`:
15
15
 
16
16
  ```js
17
- import { Pixel } from 'paymob-pixel';
17
+ import { Pixel } from 'paymob-pixel-alpha';
18
18
  ``` -->
19
19
 
20
20
  ### CDN
@@ -30,9 +30,9 @@ Using jsDelivr:
30
30
  <!-- Using unpkg:
31
31
 
32
32
  ```html
33
- <link rel="stylesheet" href="https://unpkg.com/paymob-pixel-alpha/styles.css">
34
- <link rel="stylesheet" href="https://unpkg.com/paymob-pixel-alpha/main.css">
35
- <script src="https://unpkg.com/paymob-pixel-alpha/main.js" type="module"></script>
33
+ <link rel="stylesheet" href="https://unpkg.com/paymob-pixel/styles.css">
34
+ <link rel="stylesheet" href="https://unpkg.com/paymob-pixel/main.css">
35
+ <script src="https://unpkg.com/paymob-pixel/main.js" type="module"></script>
36
36
  ``` -->
37
37
 
38
38
  ## Usage
@@ -81,7 +81,7 @@ The full list of events is as follows:
81
81
  The full list of functions is as follows:
82
82
  | Function | Props | Definition |
83
83
  | --------------------- | -------------- | -------------- |
84
- | updateIntentionData | - | Update intention data inside the SDK, in case any updates happend on the intention.
84
+ | updateIntentionData | elementId | Update intention data inside the SDK, in case any updates happend on the intention.
85
85
 
86
86
 
87
87
  ## Custom Pay Button Example
@@ -108,6 +108,12 @@ The full list of functions is as follows:
108
108
  > const response = await Pixel.updateIntentionData();
109
109
  > ```
110
110
  > **updateIntentionData** will return the response of the latest retrieve intention request.
111
+ >
112
+ >> **Note**: In case you have multiple instance of Pixel within the same page, you have to pass the **elementId** to **updateIntentionData**
113
+ >> ```js
114
+ >> const response = await Pixel.updateIntentionData("example");
115
+ >> ```
116
+ >
111
117
 
112
118
  ## Full Example
113
119
 
@@ -160,34 +166,202 @@ The full list of functions is as follows:
160
166
  console.log("====> onPaymentCancel")
161
167
  },
162
168
  customStyle: {
163
- Font_Family: 'monospace',
164
- Font_Size_Label: '18',
165
- Font_Size_Input_Fields: '18',
166
- Font_Size_Payment_Button: '28',
167
- Font_Weight_Label: 400,
168
- Font_Weight_Input_Fields: 400,
169
- Font_Weight_Payment_Button: 900,
170
- Color_Container: '#b7ffe4',
171
- Color_Border_Input_Fields: '#f00',
172
- Color_Border_Payment_Button: '#f00',
173
- Radius_Border: '50',
174
- Color_Disabled: '#c153bf',
175
- Color_Error: '#4a6',
176
- Color_Primary: '#c153bf',
177
- Color_Input_Fields: 'yellow',
178
- Text_Color_For_Label: '#f00',
179
- Text_Color_For_Payment_Button: '#f00',
180
- Text_Color_For_Input_Fields: '#f00',
181
- Color_For_Text_Placeholder: '#c153bf',
182
- Width_of_Container: '100%',
183
- Vertical_Padding: '50',
184
- Vertical_Spacing_between_components: '8',
185
- Container_Padding: '50'
186
- },
169
+ HideCardIcons: true,
170
+ Direction: 'rtl',
171
+ Label_Text: {
172
+ cardLabel: "بيانات البطاقة"
173
+ },
174
+ Placeholder_Text: {
175
+ holderName: 'الاسم علي البطاقة',
176
+ cardNumber:'رقم البطاقة',
177
+ expiryDate:'سنة / شهر',
178
+ securityCode:'(CVV) الرمز الامني'
179
+ },
180
+ Error_Text: {
181
+ holderName: 'مطلوب اسم حامل البطاقة',
182
+ cardNumber: 'مطلوب رقم البطاقة',
183
+ expiryDate: 'مطلوب تاريخ انتهاء الصلاحية',
184
+ securityCode: 'مطلوب رمز CVV مكون من 3 أرقام'
185
+ },
186
+ Font_Family: 'monospace',
187
+ Font_Size_Label: '18',
188
+ Font_Size_Input_Fields: '18',
189
+ Font_Size_Payment_Button: '28',
190
+ Font_Weight_Label: 400,
191
+ Font_Weight_Input_Fields: 400,
192
+ Font_Weight_Payment_Button: 900,
193
+ Color_Container: '#b7ffe4',
194
+ Color_Border_Input_Fields: '#f00',
195
+ Color_Border_Payment_Button: '#f00',
196
+ Radius_Border: '50',
197
+ Color_Disabled: '#c153bf',
198
+ Color_Error: '#4a6',
199
+ Color_Primary: '#c153bf',
200
+ Color_Input_Fields: 'yellow',
201
+ Text_Color_For_Label: '#f00',
202
+ Text_Color_For_Payment_Button: '#f00',
203
+ Text_Color_For_Input_Fields: '#f00',
204
+ Color_For_Text_Placeholder: '#c153bf',
205
+ Width_of_Container: '100%',
206
+ Vertical_Padding: '50',
207
+ Vertical_Spacing_between_components: '8',
208
+ Container_Padding: '50'
209
+ }
187
210
  });
188
211
  };
189
212
  </script>
190
213
  <script src="https://pay.google.com/gp/p/js/pay.js"></script>
191
214
  </body>
215
+ </html>
216
+ ```
217
+
218
+ &nbsp;
219
+
220
+ ---
221
+
222
+ &nbsp;
223
+
224
+ # `Pixel Tokenization`
225
+ Use Pixel SDK for only card tokenization.
226
+
227
+ ## Installing
228
+
229
+ ### CDN
230
+
231
+ Using jsDelivr:
232
+
233
+ ```html
234
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/styles.css">
235
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/main.css">
236
+ <script src="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/main.js" type="module"></script>
237
+ ```
238
+
239
+ ## Usage
240
+
241
+ ```js
242
+ new Pixel({
243
+ publicKey: 'are_pk_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
244
+ elementId: 'example',
245
+ supportedNetworks: ['visa', 'mada']
246
+ });
247
+ ```
248
+ ## Properties
249
+
250
+ The full list of properties is as follows:
251
+ | Property | Type | Definition |
252
+ | --------------------- | -------------- | -------------- |
253
+ | publicKey | String | It can be accessed from Merchant’s Dashboard → Settings → Account Info. |
254
+ | elementId | String | ID of the HTML element where the checkout pixel will be embedded. |
255
+ | supportedNetworks | Array | List of Supported networks. |
256
+ | hideCardHolderName | Boolean | If this option is set to false, will hide the card holder name input. |
257
+ | cardValidationChanged | Function | This Functionality will be processed whenever card validation status changed.|
258
+ | customStyle | Object | You can pass custom styles, for more details check the full example below.
259
+
260
+ ## Functions
261
+ The full list of functions is as follows:
262
+ | Function | Props | Definition |
263
+ | --------------------- | -------------- | -------------- |
264
+ | submit | elementId | Submit the card data and return the tokenized card.
265
+
266
+ ## Submit Example
267
+ > Use to fire the tokenization request and get the tokenized card data.
268
+ > ```js
269
+ > const response = await Pixel.submit();
270
+ > ```
271
+ > **submit** will return the response of the tokenization request .
272
+ >
273
+ >> **Note**: In case you have multiple instance of Pixel within the same page, you have to pass the **elementId** to **submit**
274
+ >> ```js
275
+ >> const response = await Pixel.submit("example");
276
+ >> ```
277
+ >
278
+
279
+ ## Full Example
280
+
281
+ ```html
282
+ <!DOCTYPE html>
283
+ <html lang="en">
284
+
285
+ <head>
286
+ <meta charset="utf-8" />
287
+ <title>Pixel Tokenization</title>
288
+ <base href="/">
289
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
290
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/styles.css">
291
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/main.css">
292
+ </head>
293
+
294
+ <body>
295
+ <div id="example"></div>
296
+ <button id="btn-submit">Submit</button>
297
+ <script src="https://cdn.jsdelivr.net/npm/paymob-pixel-alpha@latest/main.js" type="module"></script>
298
+ <script>
299
+ onload = (event) => {
300
+ new Pixel({
301
+ publicKey: 'are_pk_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
302
+ elementId: 'example',
303
+ supportedNetworks: ['visa', 'mada'],
304
+ cardValidationChanged: (isValid) => {
305
+ console.log("Is valid ? ", isValid)
306
+ },
307
+ customStyle: {
308
+ HideCardIcons: true,
309
+ Direction: 'rtl',
310
+ Label_Text: {
311
+ cardLabel: "بيانات البطاقة"
312
+ },
313
+ Placeholder_Text: {
314
+ holderName: 'الاسم علي البطاقة',
315
+ cardNumber:'رقم البطاقة',
316
+ expiryDate:'سنة / شهر',
317
+ securityCode:'(CVV) الرمز الامني'
318
+ },
319
+ Error_Text: {
320
+ holderName: 'مطلوب اسم حامل البطاقة',
321
+ cardNumber: 'مطلوب رقم البطاقة',
322
+ expiryDate: 'مطلوب تاريخ انتهاء الصلاحية',
323
+ securityCode: 'مطلوب رمز CVV مكون من 3 أرقام'
324
+ },
325
+ Font_Family: 'monospace',
326
+ Font_Size_Label: '18',
327
+ Font_Size_Input_Fields: '18',
328
+ Font_Size_Payment_Button: '28',
329
+ Font_Weight_Label: 400,
330
+ Font_Weight_Input_Fields: 400,
331
+ Font_Weight_Payment_Button: 900,
332
+ Color_Container: '#b7ffe4',
333
+ Color_Border_Input_Fields: '#f00',
334
+ Color_Border_Payment_Button: '#f00',
335
+ Radius_Border: '50',
336
+ Color_Disabled: '#c153bf',
337
+ Color_Error: '#4a6',
338
+ Color_Primary: '#c153bf',
339
+ Color_Input_Fields: 'yellow',
340
+ Text_Color_For_Label: '#f00',
341
+ Text_Color_For_Payment_Button: '#f00',
342
+ Text_Color_For_Input_Fields: '#f00',
343
+ Color_For_Text_Placeholder: '#c153bf',
344
+ Width_of_Container: '100%',
345
+ Vertical_Padding: '50',
346
+ Vertical_Spacing_between_components: '8',
347
+ Container_Padding: '50'
348
+ }
349
+ })
350
+ // Submit Call
351
+ const submitBtn = document.getElementById('btn-submit');
352
+ submitBtn.addEventListener('click', async () => {
353
+ try {
354
+ const response = await Pixel.submit();
355
+ console.log("Response:", response.data)
356
+
357
+ } catch (error) {
358
+ console.log("Error:", error)
359
+
360
+ }
361
+ })
362
+ };
363
+ </script>
364
+ </body>
365
+
192
366
  </html>
193
367
  ```