Skip to content

Commit

Permalink
build: optimize code, fix final bugs, and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngntu10 committed Nov 14, 2024
1 parent 302c6f9 commit 0782d65
Show file tree
Hide file tree
Showing 3 changed files with 6,134 additions and 6 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
DB_PASSWORD: nguyentu1005
REDIS_HOST: redis-optimart
REDIS_PORT: 6379
TZ: Asia/Ho_Chi_Minh
depends_on:
- db
- redis
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/com/Optimart/configuration/VNPAY/VNPAYConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.springframework.context.annotation.Configuration;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -41,13 +45,21 @@ public Map<String, String> getVNPayConfig() {
vnpParamsMap.put("vnp_OrderType", this.orderType);
vnpParamsMap.put("vnp_Locale", "vn");
vnpParamsMap.put("vnp_ReturnUrl", this.vnp_ReturnUrl);
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Etc/GMT+7"));
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String vnpCreateDate = formatter.format(calendar.getTime());
// Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Etc/GMT+7"));
// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
// String vnpCreateDate = formatter.format(calendar.getTime());
// vnpParamsMap.put("vnp_CreateDate", vnpCreateDate);
// calendar.add(Calendar.MINUTE, 15);
// String vnp_ExpireDate = formatter.format(calendar.getTime());
// vnpParamsMap.put("vnp_ExpireDate", vnp_ExpireDate);
// ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Etc/GMT+7"));
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String vnpCreateDate = now.format(formatter);
vnpParamsMap.put("vnp_CreateDate", vnpCreateDate);
calendar.add(Calendar.MINUTE, 15);
String vnp_ExpireDate = formatter.format(calendar.getTime());
vnpParamsMap.put("vnp_ExpireDate", vnp_ExpireDate);
LocalDateTime expireDateTime = now.plusMinutes(15);
String vnpExpireDate = expireDateTime.format(formatter);
vnpParamsMap.put("vnp_ExpireDate", vnpExpireDate);
return vnpParamsMap;
}
}
Loading

0 comments on commit 0782d65

Please sign in to comment.