public OrderItemWebObject apply(OrderItem orderItem) { return new OrderItemWebObject().withOrderItem(orderItem, order.getCurrency(), locale); } }).toList());
@POST @Path("{orderId}/payment") public Object internalPayment(@PathParam("orderId") UUID orderId, MultivaluedMap<String, String> data) { try { Order order = orderStore.get().findById(orderId); Map<PaymentData, Object> paymentData = Maps.newHashMap(); paymentData.put(BasePaymentData.CURRENCY, order.getCurrency()); paymentData.put(BasePaymentData.ORDER_ID, order.getId()); paymentData.put(BasePaymentData.CUSTOMER, order.getCustomer()); if (order.getBillingAddress() != null) { paymentData.put(BasePaymentData.BILLING_ADDRESS, order.getBillingAddress()); } paymentData.put(BasePaymentData.DELIVERY_ADDRESS, order.getDeliveryAddress()); paymentData.put(BasePaymentData.ORDER, order); if (data.containsKey("cardNumber")) { paymentData.put(CreditCardPaymentData.CARD_NUMBER, data.getFirst("cardNumber")); paymentData.put(CreditCardPaymentData.HOLDER_NAME, data.getFirst("holderName")); paymentData.put(CreditCardPaymentData.EXPIRATION_MONTH, data.getFirst("expiryMonth")); paymentData.put(CreditCardPaymentData.EXPIRATION_YEAR, data.getFirst("expiryYear")); paymentData.put(CreditCardPaymentData.VERIFICATION_CODE, data.getFirst("cvv")); } PaymentRequest paymentRequest = paymentProcessor.requestPayment(order, paymentData); CheckoutResponse response = new CheckoutResponse(order, paymentRequest); return generateCheckoutResponse(response); } catch (Exception e) { return renderError(e.getMessage()); } }
.toFormatter(); CurrencyUnit currencyUnit = CurrencyUnit.of(order.getCurrency()); String grandTotal = formatter.withLocale(locale) .print(Money.of(currencyUnit, order.getGrandTotal(), RoundingMode.HALF_EVEN));
.toFormatter(); CurrencyUnit currencyUnit = CurrencyUnit.of(order.getCurrency()); String grandTotal = formatter.withLocale(locale) .print(Money.of(currencyUnit, order.getGrandTotal(), RoundingMode.HALF_EVEN));
public OrderRepresentation(DateTimeZone tenantZone, Order order) { this.slug = order.getSlug(); if (order.getCreationDate() != null) { this.creationDate = new DateTime(order.getCreationDate().getTime(), tenantZone); } if (order.getUpdateDate() != null) { this.updateDate = new DateTime(order.getUpdateDate().getTime(), tenantZone); } this.currency = order.getCurrency(); this.numberOfItems = order.getNumberOfItems(); this.itemsTotal = order.getItemsTotal(); this.shipping = order.getShipping(); this.grandTotal = order.getGrandTotal(); this.status = order.getStatus(); this.additionalInformation = order.getAdditionalInformation(); this.data = order.getOrderData(); if (order.getBillingAddress() != null) { this.setBillingAddress(new AddressRepresentation(order.getBillingAddress())); } if (order.getDeliveryAddress() != null) { this.setDeliveryAddress(new AddressRepresentation(order.getDeliveryAddress())); } if (order.getCustomer() != null) { this.setCustomer(new CustomerRepresentation(order.getCustomer())); } }