
html
<div id="checkoutAlipayField"></div>javascript
import { Alipay } from '@paykka/card-checkout-ui'
const checkoutAlipay = paykkaCheckout.create(Alipay, {
onSubmit: formValidateError => {
console.log('Alipay payment submitted:', formValidateError)
},
onSuccess: data => {
console.log('Alipay payment successful:', data)
},
onError: error => {
console.log('Alipay payment failed:', error)
}
})
checkoutAlipay.mount('#checkoutAlipayField')- Desktop browser: after clicking the payment button, a QR code is displayed on the page. The customer scans it with the Alipay App to complete the payment.
- Mobile browser: after clicking the payment button, the customer is redirected to Alipay to complete the payment and then returns to the checkout page.
Passed when calling the create method to create Alipay.
| Name | Description | Type | Default |
|---|---|---|---|
| hidePaymentButton | Whether to hide the payment button. After hiding it, you can trigger payment manually through the component ref's payment() method. | boolean | false |
| onSubmit | Payment submission callback, triggered after clicking the payment button.
| (formValidateError?: Record<string, FormValidateError[]>) => void | boolean | Promise<void | boolean> | undefined |
| onSuccess | Callback after successful payment.
| (data: PaymentSuccessData) => void | undefined |
| onError | Callback after payment failure, can resubmit for payment.
| (error: PayKKaError) => void | undefined |
| onTimeout | Callback when payment times out, can resubmit for payment. | () => void | undefined |
| onExpired | Callback when the checkout counter has expired during payment, cannot pay again. | () => void | undefined |
Methods and properties exposed by Alipay, can be called by the Alipay instance created via the create method, e.g.: checkoutAlipay.ref.payment().
| Name | Description | Type |
|---|---|---|
| payment | Make a payment, enabled when the payment button is not visible. | () => void |
Below is an explanation of some data types:
Payment success information.
interface PaymentSuccessData {
/** URL that can be redirected to after successful payment */
returnUrl?: string
}