Authenticate a transaction
Last updated
Was this helpful?
Was this helpful?
public void mastercard_AuthenticateTransaction(@NonNull final String tokenID, @NonNull TransactionContext transactionContext, @NonNull MastercardTAFHelper masterCardTAFHelper, @NonNull FragmentActivity fragmentActivity) {
masterCardTAFHelper.authenticateTransaction(tokenID, transactionContext, new TransactionListener() {
@Override
public void onDeviceAuthentication(DeviceAuthentication deviceAuthentication) {
CharSequence title = "Title";
CharSequence subTitle = "Subtitle";
CharSequence description = "Description";
CharSequence negativeButtonText = "Negative Button";
deviceAuthentication.startAuthentication(fragmentActivity,
title,
subTitle,
description,
negativeButtonText);
}
@Override
public void onError(TMGClientException exception) {
// Check error
int errorCode = exception.getErrorCode();
String errorMessage = exception.getMessage();
}
@Override
public void onSuccess(String payload) {
// Decode the Mastercard Payload and verify the Transaction assertion
}
});
}let tokenID = ""
let transContext = MastercardTAFHelper.TransactionContext(merchantName: "ABC", amount: "100", currencyCode: "USD")
// 1. Start authenticate transaction
mastercardTAFHelper.authenticateTransaction(forTokenID: tokenID, context: transContext,
deviceAuthenticationHandler: { auth in
// 2. Start user authentication
let customMessage = "" // Pass in the custom message. e.g: "Authenticate with Face ID"
auth.startAuthentication(withMessage: customMessage)
},
completionHandler: { (mastercardPayload, error) in
// 3. Success in generating payload
if error == nil {
} else {
// Handle error
}
}
)