Last active
February 5, 2019 12:23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.jakewharton.rxrelay2.BehaviorRelay; | |
import com.jakewharton.rxrelay2.Relay; | |
import de.wirecard.epos.util.events.Event; | |
import de.wirecard.epos.util.events.TerminalEvent; | |
import de.wirecard.epos.util.events.acceptance.AppSignatureConfirmationEvent; | |
import io.reactivex.android.schedulers.AndroidSchedulers; | |
Relay<Event> eventRelay = BehaviorRelay.create(); | |
eventRelay | |
.observeOn(AndroidSchedulers.mainThread()) | |
// Updates during the payment flow | |
.subscribe(event -> { | |
if (event instanceof TerminalEvent.SignatureRequest) { | |
// In the case when the Cardholder Signature is required by the Payment flow | |
// Your task is to respond to it by collecting the signature image from the customer and | |
// posting it back in the signatureEntered method | |
String img = "signature image in Base64 format"; | |
((TerminalEvent.SignatureRequest) event).signatureEntered(img.getBytes()); // image in base 64 | |
((TerminalEvent.SignatureRequest) event).signatureCanceled(); // sale canceled, because signature was not collected | |
} | |
else if (event instanceof TerminalEvent.SignatureConfirmation) { | |
// In the case when the Cardholder Signature was collected then the merchant is required to confirm its validity | |
// A. If the terminal has buttons that are used for Approving/Rejecting then this is either never called from Payment flow | |
// or its AppSignatureConfirmationEvent comes null | |
// B. If the terminal does not have buttons then the Application must present a user interface to Approve/Reject the Cardholder Signature | |
((TerminalEvent.SignatureConfirmation) event).getEnteredSignature(); // signature confirmation can be performed in terminal or in app | |
if (event instanceof AppSignatureConfirmationEvent) { // this event indicates it has to be confirmed in app side | |
((AppSignatureConfirmationEvent) event).signatureConfirmed(); // signature confirmed in app | |
((AppSignatureConfirmationEvent) event).signatureCanceled(); // signature confirmation canceled in app | |
} | |
} | |
else if (event instanceof TerminalEvent.PaymentInfo) { | |
// provided some information during payment which can be shown to user | |
((TerminalEvent.PaymentInfo) event).getAppLabel(); | |
((TerminalEvent.PaymentInfo) event).getApplicationId(); | |
((TerminalEvent.PaymentInfo) event).getCardholderName(); | |
((TerminalEvent.PaymentInfo) event).getPanTag(); | |
} | |
else if (event instanceof Event.Update) { | |
// update events indicates change of progress | |
((Event.Update) event).getMessage(context); | |
} | |
else if (event instanceof Event.PasswordConfirmation) { | |
//wechat payment method can ask for confirmation, that customer entered pin | |
onPasswordConfirmation((Event.PasswordConfirmation) event); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment