Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create list of sale items
- List<SaleItem> items = new ArrayList<>(1);
- items.add(new SaleItem(SaleItemType.PURCHASE, "item 1", new BigDecimal("10"), null, new BigDecimal("1"), new BigDecimal("20"), new BigDecimal("10"), null, null, null));
- // you can put requested objects or use more convenient way via builder which can lead you through mandatory fields
- accept.sales()
- .pay(SaleBuilder.newBuilder() // builder will guide you what you have to put
- .setAmount(new BigDecimal("10")) // amount of whole sale, mandatory field
- .setCurrency(Currency.getInstance("EUR")) // currency of whole sale, mandatory field
- .unitPricesIncludeTax() // choose if tax is included or excluded, mandatory field but you can choose from 3methods, unitPricesIncludeTax(), unitPricesExcludeTax(), setUnitPricesIncludeTax(boolean unitPricesIncludeTax)
- .addAlipayPayment(new BigDecimal("10"), "scannedConsumerIdFromAlipayApplication")
- //or
- .addWechatPayment(new BigDecimal("10"), "scannedConsumerIdFromWechatApplication")
- .setSaleItems(items)
- .setCashierId("cashier id")
- // ...
- .build()
- )
- .subscribeParallel(eventRelay)
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(saleId -> {
- // sale was performed successfully
- // saleId String is returned, you can load whole sale object by calling accept.sales().getSale(String saleId)
- }, throwable -> {
- // handle error
- });
- eventRelay
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(event -> {
- if (event instanceof Event.Update) { // update events indicates change of progress
- String update = ((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);
- }
- });
Add Comment
Please, Sign In to add comment