Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| paymentUrl | String | Yes | Full cashier URL returned by the backend |
| success | Function | No | Callback with payment result |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
Success Callback
| Property | Type | Description |
|---|---|---|
| resultCode | String | Payment result code |
Result Codes
| Code | Meaning | Action |
|---|---|---|
9000 | Payment appears successful | Poll backend for confirmation |
8000 | Transaction in progress | Poll backend for final status |
6001 | User cancelled | Allow retry |
6002 | Network error | Retry or poll status |
6004 | Outcome uncertain — may have succeeded | Poll backend before retrying |
4000 | Payment failed | Check backend status |
Code Example
my.tradePay({
paymentUrl: paymentUrlFromBackend,
success: (res) => {
if (res.resultCode === '9000') {
// Show pending, poll backend for confirmation
this.pollPaymentStatus();
} else if (res.resultCode === '6001') {
my.showToast({ content: 'Payment cancelled' });
}
},
fail: (err) => {
console.error('Payment error:', err);
}
});
Never trust the JSAPI result as final. The
resultCode is indicative only. Always confirm payment status via backend webhook before updating business state.Related APIs
Payments in Mini Apps
Complete payment guide