You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let json =try? JSONSerialization.jsonObject(with: data) as? [String:Any],
153
+
let eventName = json["eventName"] as?String {
154
+
print("Payment event: \(eventName)")
155
+
handlePaymentEvent(eventName, data: json)
156
+
}
157
+
}
158
+
}
159
+
```
113
160
114
-
The app listens for these events via `WKScriptMessageHandler`:
161
+
## Payment Events
115
162
116
-
- See all events [here](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#post-message-events)
163
+
The payment flow sends various events like `onramp_api.load_success`, `onramp_api.commit_success`, `onramp_api.polling_success`, etc.
117
164
118
-
See `ViewController.swift` lines 357-410 for full implementation.
165
+
See the [full list of events](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#post-message-events) in the Coinbase documentation.
119
166
120
167
## Sandbox Testing
121
168
122
-
The demo uses sandbox mode by default. Transactions use test credentials and won't charge real money.
169
+
The demo uses sandbox mode (no real money):
170
+
-`partnerUserRef` must start with `"sandbox-"`
171
+
- Transactions auto-complete
123
172
124
173
## Troubleshooting
125
174
126
175
**"Internet connection appears to be offline"**
127
-
- Ensure iPhone and computer are on the same WiFi
176
+
- Ensure iPhone and Mac are on same WiFi
177
+
- Try ngrok instead of local IP
128
178
- Check firewall settings
129
-
- Use ngrok to bypass network issues
130
179
131
-
**Apple Pay not appearing**
132
-
- Must use physical iOS device (not simulator)
180
+
**Apple Pay sheet doesn't appear**
181
+
- Must use physical device (not simulator)
133
182
- Device must have Apple Pay configured
134
-
-App must be served over HTTPS (use ngrok for testing)
183
+
-Ensure message handler name is exactly `"cbOnramp"`
135
184
136
-
**Events not being received**
137
-
- Check message handler name is `"onramp"`
138
-
- Verify JavaScript bridge injection in `didFinish` navigation
139
-
- Enable Safari Web Inspector to debug
185
+
**No events received**
186
+
- Handler name must be exactly `"cbOnramp"` (case-sensitive)
187
+
- Check Safari Web Inspector for JavaScript errors
0 commit comments