@mmpay/browser 1.3.0 → 1.3.1

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/README.md +22 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ Embed the following `<script>` tag into the `<head>` or before the closing `</bo
13
13
  **Implementation**
14
14
 
15
15
  ```html
16
- <script src="https://cdn.jsdelivr.net/npm/mmpay-browser-sdk@latest/dist/mmpay-sdk.js"></script>
16
+ <script src="https://cdn.jsdelivr.net/npm/@mmpay/browser@latest/dist/mmpay-sdk.js"></script>
17
17
  ```
18
18
 
19
19
  ---
@@ -62,7 +62,7 @@ Payment status is pushed over a WebSocket, so the success screen appears about a
62
62
 
63
63
  While the shopper has an order that is not paid, cancelled or expired, `showPaymentModal()` does not create another one. It shows the unfinished order again, also after a page reload or when called with a different `orderId`, and the `created` event carries the `orderId` of the order that is actually on screen. A new order is created once the previous one is finished or the shopper stops it.
64
64
 
65
- A manual test page is in `test/index.html` (run `npm run build` first). It has a built-in mock API, so it works without a server.
65
+ You can try this in the demo playground, see [Run the demo](#run-the-demo).
66
66
 
67
67
  If your site sends a Content-Security-Policy header, allow:
68
68
 
@@ -77,6 +77,26 @@ The modal renders inside a shadow root and no longer uses inline event handlers
77
77
 
78
78
  ---
79
79
 
80
+ ## Run the demo
81
+
82
+ The repo includes a playground at `test/index.html`. In it you can pick the theme, card style, button colour and language, see the matching code for HTML, React or Vue with a Copy button, and run a real payment test against the built SDK.
83
+
84
+ ```bash
85
+ npm install
86
+ npm run build # builds ./dist/mmpay-sdk.js, which the demo loads
87
+ npm run serve # serves the repo at http://localhost:5173
88
+ ```
89
+
90
+ Open **http://localhost:5173/test/**, then:
91
+
92
+ 1. **Real test:** enter your `pk_test_` publishable key under *Connection* and press **▶ Run test**. Sandbox keys work from `http://localhost`. Live `pk_live_` keys only work on an HTTPS origin in your whitelist, so use a test key here. The log shows each HTTP call and WebSocket message, so you can see the status arrive in real time.
93
+ 2. **No server:** tick *Mock API*. Requests stay in the page, and the *Paid / Failed / Expired / Cancelled* buttons set the order status.
94
+ 3. **Spam test (5×)** calls `showPaymentModal()` five times with new order IDs. Only one order should be created. **Reload** checks that an unfinished order reopens on its own.
95
+
96
+ After changing anything in `src/`, run `npm run build` again and reload the page. Open the demo through `npm run serve`, not by double-clicking the file: from `file://` the WebSocket is refused and the SDK falls back to polling.
97
+
98
+ ---
99
+
80
100
  ## 3: 🚀 Making Payments
81
101
 
82
102
  ##### Approach 1 [Browser Site Order Creation] `showPaymentModal()`
@@ -280,7 +300,6 @@ export class MMPayService {
280
300
  return;
281
301
  }
282
302
  this.mmpay = new MMPaySDK('pk_test_123', {
283
- baseUrl: 'https://xxx.myanmyanpay.com', // Sign up with us and ask our tea
284
303
  merchantName: 'Test Shop',
285
304
  design: {
286
305
  mode: 'light-translucent', // dark | dark-translucent | light | light-translucent
@@ -344,7 +363,6 @@ export const useMMPay = () => {
344
363
  }
345
364
 
346
365
  mmpayRef.current = new MMPaySDK('pk_test_123', {
347
- baseUrl: 'https://xxx.myanmyanpay.com',
348
366
  merchantName: 'Test Shop',
349
367
  design: {
350
368
  mode: 'dark-translucent', // dark | dark-translucent | light | light-translucent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmpay/browser",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "JavaScript SDK for integrating the MMQR Merchant and Redirect payment gateway",
5
5
  "keywords": [
6
6
  "MMQR"