Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WirecardMobileServices/a79526e9052e9343ad55dfc44171b081 to your computer and use it in GitHub Desktop.
Save WirecardMobileServices/a79526e9052e9343ad55dfc44171b081 to your computer and use it in GitHub Desktop.
import com.jakewharton.rxrelay2.BehaviorRelay;
import com.jakewharton.rxrelay2.Relay;
import java.math.BigDecimal;
import de.wirecard.epos.model.sale.builder.ReferenceTerminalPreAuthorizationSupplementRequest;
import de.wirecard.epos.model.sale.builder.payment.CardTerminalPreAuthorizationSupplementPayment;
import de.wirecard.epos.model.with.With;
import de.wirecard.epos.model.with.WithBase;
import de.wirecard.epos.util.events.Event;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
WithBase withBase = With.base().scheduler(Schedulers.newThread());
Relay<Event> eventRelay = BehaviorRelay.create();
CardTerminalPreAuthorizationSupplementPayment cardTerminalPreAuthorizationSupplementPayment = new CardTerminalPreAuthorizationSupplementPayment(
// mandatory field
new BigDecimal("2"),
// mandatory field, must refer to the last (previous) completed Pre-Authorization transaction or Pre-Authorization Supplement transaction of related transaction chain
"originalTransactionId",
// mandatory field, must be filled by value of "authorizationCode" returned in the response of the last (previous) Pre-Authorization transaction or Pre-Authorization Supplement
// transaction of related transaction chain
"authorizationCode"
);
ReferenceTerminalPreAuthorizationSupplementRequest referenceTerminalPreAuthorizationSupplementRequest = new ReferenceTerminalPreAuthorizationSupplementRequest(
"originalSaleId", // mandatory field, must refer to the same Sale Purchase as transaction referenced by "originalTransactionId"
cardTerminalPreAuthorizationSupplementPayment, // mandatory field
"cashRegisterId",// optional
"note",// optional
"externalId"// optional
);
eposSDK.sales()
.operation()
.referencePurchase(referenceTerminalPreAuthorizationSupplementRequest)
//.referencePurchase(referenceTerminalPreAuthorizationSupplementRequest, withBase )// in case you want request to run on specific thread
.subscribeParallel(eventRelay)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(saleId -> {
// sale was performed successfully
// saleId String is returned, you can load whole sale object by calling epos.sales().getSale(String saleId)
}, throwable -> {
// handle error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment