-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…in paypal
- Loading branch information
tuannguyenh1
committed
Nov 11, 2024
1 parent
a37f777
commit cc8e102
Showing
25 changed files
with
337 additions
and
36 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 | ||
|
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
22 changes: 22 additions & 0 deletions
22
payment/src/main/java/com/yas/payment/config/JsonConfig.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.yas.payment.config; | ||
|
||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.gson.Gson; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
public class JsonConfig { | ||
|
||
@Bean | ||
public ObjectMapper objectMapper() { | ||
return new ObjectMapper(); | ||
} | ||
|
||
@Bean | ||
public Gson gson() { | ||
return new Gson(); | ||
} | ||
} |
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
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
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
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
33 changes: 33 additions & 0 deletions
33
payment/src/main/java/com/yas/payment/utils/JsonUtils.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.yas.payment.utils; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.yas.commonlibrary.exception.BadRequestException; | ||
|
||
public class JsonUtils { | ||
|
||
private JsonUtils() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public static String convertObjectToString(ObjectMapper objectMapper, Object value) { | ||
try { | ||
return objectMapper.writeValueAsString(value); | ||
} catch (JsonProcessingException e) { | ||
throw new BadRequestException(Constants.ErrorCode.CANNOT_CONVERT_TO_STRING, value); | ||
} | ||
} | ||
|
||
public static ObjectNode getAttributesNode(ObjectMapper objectMapper, String attributes) { | ||
try { | ||
if (attributes == null || attributes.isBlank()) { | ||
return objectMapper.createObjectNode(); | ||
} else { | ||
return (ObjectNode) objectMapper.readTree(attributes); | ||
} | ||
} catch (JsonProcessingException e) { | ||
throw new BadRequestException("Invalid Json: {}", attributes); | ||
} | ||
} | ||
} |
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
2 changes: 2 additions & 0 deletions
2
payment/src/main/resources/db/changelog/ddl/changelog-0005.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE IF EXISTS "payment" | ||
ADD COLUMN attributes JSONB; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum EPaymentMethod { | ||
COD = 'COD', | ||
BANKING = 'BANKING', | ||
PAYPAL = 'PAYPAL', | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { EPaymentMethod } from '@/modules/common/models/EPaymentMethod'; | ||
import { CheckoutItem } from './CheckoutItem'; | ||
import { ECheckoutState } from './ECheckoutState'; | ||
import { ECheckoutProgress } from './ECheckoutProgress'; | ||
|
||
export type Checkout = { | ||
id?: string; | ||
email: string; | ||
note?: string; | ||
couponCode?: string; | ||
checkoutState?: ECheckoutState; | ||
progress?: ECheckoutProgress; | ||
paymentMethodId?: EPaymentMethod; | ||
attributes?: string; | ||
lastError?: string; | ||
totalAmount: number; | ||
totalDiscountAmount: number; | ||
checkoutItemPostVms: CheckoutItem[]; | ||
checkoutItemVms: CheckoutItem[]; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export enum ECheckoutProgress { | ||
INIT = 'INIT', | ||
PROMOTION_CODE_APPLIED = 'PROMOTION_CODE_APPLIED', | ||
PROMOTION_CODE_APPLIED_FAILED = 'PROMOTION_CODE_APPLIED_FAILED', | ||
STOCK_LOCKED = 'STOCK_LOCKED', | ||
STOCK_LOCKED_FAILED = 'STOCK_LOCKED_FAILED', | ||
PAYMENT_CREATED = 'PAYMENT_CREATED', | ||
PAYMENT_CREATED_FAILED = 'PAYMENT_CREATED_FAILED', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum ECheckoutState { | ||
COMPLETED = 'COMPLETED', | ||
PENDING = 'PENDING', | ||
LOCK = 'LOCK', | ||
CHECKED_OUT = 'CHECKED_OUT', | ||
PAYMENT_PROCESSING = 'PAYMENT_PROCESSING', | ||
PAYMENT_FAILED = 'PAYMENT_FAILED', | ||
PAYMENT_CONFIRMED = 'PAYMENT_CONFIRMED', | ||
FULFILLED = 'FULFILLED', | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum EPaymentStatus { | ||
NEW = 'NEW', | ||
PROCESSING = 'PROCESSING', | ||
PENDING = 'PENDING', | ||
COMPLETED = 'COMPLETED', | ||
CANCELLED = 'CANCELLED', | ||
} |
Oops, something went wrong.