Skip to content

Commit ea27497

Browse files
authored
Using Mkcert for local wallets testing in demo app (#525)
1 parent ed6d29f commit ea27497

4 files changed

Lines changed: 176 additions & 5 deletions

File tree

examples/webbilling-demo/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ With a UI
4747
```bash
4848
npm run test:e2e-ui
4949
```
50+
51+
### Testing Apple Pay and Google Pay with local certs
52+
53+
To test Apple Pay and Google Pay we have to fake an https setup for the Apple Pay/Google Pay authorized domains locally.
54+
The following instructions allow you to do it just using this repo but require you to play with your `/etc/hosts` and won't work on windows.
55+
56+
> [!WARNING]
57+
> This setup will install local certificates for somedomain.com in your machine using the vite-plugin-mkcert, therefore, you need to run this
58+
> command as superuser. Make sure to pick a domain (or add one) that you don't want to mess up on your machine or you'll
59+
> have to fix your certificates manually.
60+
61+
Check the enabled domains in the Stripe config for the Apple Pay/Google Pay Payment method.
62+
Say the domain `somedomain.com` exists in that list.
63+
64+
Add this line to your `/etc/hosts` file.
65+
66+
```
67+
127.0.0.1 somedomain.com
68+
```
69+
70+
This will resolve `somedomain.com` to localhost.
71+
72+
Now you can run the webserver forcing the usage of that domain and the 443 port (for full https support).
73+
74+
```
75+
sudo npm run dev-fake-https -- --host somedomain.com --port 443
76+
```
77+
78+
Now you should be able to run safari with Apple Pay just by visiting `somedomain.com`.

examples/webbilling-demo/package-lock.json

Lines changed: 130 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/webbilling-demo/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8+
"dev-fake-https": "vite ",
89
"build": "tsc && vite build",
910
"lint": "eslint \"**/*.{ts,tsx}\" --report-unused-disable-directives --max-warnings 0",
1011
"preview": "vite preview",
@@ -42,14 +43,15 @@
4243
"eslint-plugin-n": "^17.15.0",
4344
"eslint-plugin-prettier": "^5.2.1",
4445
"eslint-plugin-promise": "^7.2.1",
45-
"eslint-plugin-storybook": "^0.11.1",
46-
"eslint-plugin-svelte": "^2.46.1",
4746
"eslint-plugin-react-hooks": "^5.1.0",
4847
"eslint-plugin-react-refresh": "^0.4.16",
48+
"eslint-plugin-storybook": "^0.11.1",
49+
"eslint-plugin-svelte": "^2.46.1",
50+
"globals": "^15.13.0",
4951
"prettier": "^3.4.2",
5052
"typescript": "^5.7.2",
51-
"vite": "^6.0.3",
5253
"typescript-eslint": "^8.18.0",
53-
"globals": "^15.13.0"
54+
"vite": "^6.0.3",
55+
"vite-plugin-mkcert": "^1.17.8"
5456
}
5557
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
3+
import mkcert from "vite-plugin-mkcert";
4+
5+
// https://vitejs.dev/config/
6+
export default defineConfig({
7+
plugins: [react(), mkcert()],
8+
server: {
9+
port: 443,
10+
},
11+
});

0 commit comments

Comments
 (0)