2. Implement contactless payment callbacks
Overview
SDK integration
Implement ContactlessPaymentServiceListener
ContactlessPaymentServiceListener// Instantiate a listener for the HCE service.
PaymentServiceListener myPaymentListener = new ContactlessPaymentServiceListener() {
@Override
public void onTransactionStarted() {
/*
* Triggered when the first APDU is exchanged with the POS terminal.
*/
}
@Override
public void onAuthenticationRequired(
PaymentService activatedPaymentService,
CHVerificationMethod chVerificationMethod,
long cvmResetTimeout) {
/*
* Triggered when the end user must authenticate (CDCVM).
*
* Use chVerificationMethod to determine the required method.
* cvmResetTimeout applies only to some methods (for example, wallet PIN).
* Use it to tell the end user how long the verification stays valid.
*/
}
@Override
public void onReadyToTap(PaymentService paymentService) {
/*
* Triggered after successful authentication.
* Prompt the end user to tap again before cvmResetTimeout expires.
*/
}
@Override
public void onTransactionCompleted(TransactionContext transactionContext) {
/*
* Triggered when the transaction completes successfully.
* Use TransactionContext to display details (amount, date, and more).
*/
}
@Override
public void onTransactionInterrupted() {
/*
* Triggered when the NFC link to the POS terminal is interrupted.
* Prompt the end user to tap again.
* Optional callback
*/
}
@Override
public void onError(
TransactionContext transactionContext,
PaymentServiceErrorCode paymentServiceErrorCode,
String message) {
/*
* Triggered when the transaction cannot complete successfully.
*/
}
@Override
public void onFirstTapCompleted() {
/*
* Indicates the first-tap APDU processing completed.
* Supported only for PFP-based transactions.
*/
}
@Override
public void onNextTransactionReady(
DeactivationStatus deactivationStatus,
DigitalizedCardStatus digitalizedCardStatus,
DigitalizedCard digitalizedCard) {
/*
* Triggered after a transaction completes.
* Use it to verify the card state and prepare for the next payment.
*/
}
};Return the listener from your HCE service
Callback flow (typical)
Handle POS terminal disconnects (optional)
Last updated
Was this helpful?