Skip to content

Commit

Permalink
#1180 & #1237 intergration with front end - create payment and order …
Browse files Browse the repository at this point in the history
…in paypal
  • Loading branch information
tuannguyenh1 committed Nov 8, 2024
1 parent a37f777 commit 316c0c2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.yas.order.viewmodel.checkout;

import com.yas.order.model.Checkout;
import com.yas.order.model.enumeration.CheckoutProgress;
import com.yas.order.model.enumeration.CheckoutState;
import com.yas.order.model.enumeration.PaymentMethod;
import java.math.BigDecimal;
import java.util.Set;
import lombok.Builder;
Expand All @@ -11,6 +14,11 @@ public record CheckoutVm(
String email,
String note,
String couponCode,
CheckoutState checkoutState,
CheckoutProgress progress,
PaymentMethod paymentMethodId,
String attributes,
String lastError,
BigDecimal totalAmount,
BigDecimal totalDiscountAmount,
Set<CheckoutItemVm> checkoutItemVms
Expand All @@ -22,6 +30,11 @@ public static CheckoutVm fromModel(Checkout checkout, Set<CheckoutItemVm> checko
.email(checkout.getEmail())
.note(checkout.getNote())
.couponCode(checkout.getCouponCode())
.checkoutState(checkout.getCheckoutState())
.progress(checkout.getProgress())
.paymentMethodId(checkout.getPaymentMethodId())
.attributes(checkout.getAttributes())
.lastError(checkout.getLastError())
.checkoutItemVms(checkoutItemVms)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.yas.order.OrderApplication;
import com.yas.order.model.enumeration.CheckoutProgress;
import com.yas.order.model.enumeration.CheckoutState;
import com.yas.order.model.enumeration.PaymentMethod;
import com.yas.order.service.CheckoutService;
import com.yas.order.viewmodel.checkout.CheckoutItemPostVm;
import com.yas.order.viewmodel.checkout.CheckoutItemVm;
Expand Down Expand Up @@ -201,6 +204,11 @@ private CheckoutVm getCheckoutVm() {
"[email protected]",
"Please deliver after 5 PM",
"DISCOUNT20",
CheckoutState.PAYMENT_PROCESSING,
CheckoutProgress.PROMOTION_CODE_APPLIED,
PaymentMethod.PAYPAL,
null,
null,
BigDecimal.valueOf(900),
BigDecimal.valueOf(9),
checkoutItemVms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public record PaymentVm(
PaymentMethod paymentMethod,
PaymentStatus paymentStatus,
String gatewayTransactionId,
String failureMessage
String failureMessage,
String paymentProviderCheckoutId
) {

public static PaymentVm fromModel(Payment payment) {
Expand All @@ -28,7 +29,8 @@ public static PaymentVm fromModel(Payment payment) {
payment.getPaymentMethod(),
payment.getPaymentStatus(),
payment.getGatewayTransactionId(),
payment.getFailureMessage()
payment.getFailureMessage(),
payment.getPaymentProviderCheckoutId()
);
}
}

0 comments on commit 316c0c2

Please sign in to comment.