|
|
|
@ -8,6 +8,7 @@ import au.com.royalpay.payment.manage.shopify.auth.domain.service.ShopifyRequest
|
|
|
|
|
import au.com.royalpay.payment.manage.shopify.support.ShopifyEndpoint;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.http.server.ServletServerHttpRequest;
|
|
|
|
@ -41,7 +42,10 @@ public class ShopifyAuthTemplateController {
|
|
|
|
|
@GetMapping("/auth")
|
|
|
|
|
@ShopifyEndpoint
|
|
|
|
|
public String shopifyStorePermission(@RequestParam(value = "shop", required = false) String shop,
|
|
|
|
|
@RequestParam("hmac") String hmac, HttpServletRequest request) {
|
|
|
|
|
@RequestParam(value = "hmac", required = false) String hmac, HttpServletRequest request) {
|
|
|
|
|
if (StringUtils.isAnyEmpty(shop, hmac)) {
|
|
|
|
|
throw new BadRequestException("Parameter shop&hmac are required");
|
|
|
|
|
}
|
|
|
|
|
if (!Pattern.matches("^[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.myshopify\\.com", shop)) {
|
|
|
|
|
throw new BadRequestException("Parameter shop is invalid.");
|
|
|
|
|
}
|
|
|
|
@ -67,12 +71,15 @@ public class ShopifyAuthTemplateController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/auth/back")
|
|
|
|
|
@ShopifyEndpoint
|
|
|
|
|
public String shopifyStoreAuthRedirect(@RequestParam("code") String code,
|
|
|
|
|
@RequestParam("hmac") String hmac,
|
|
|
|
|
@RequestParam("host") String host,
|
|
|
|
|
@RequestParam("state") String state,
|
|
|
|
|
@RequestParam("shop") String shop,
|
|
|
|
|
@RequestParam("timestamp") String timestamp) {
|
|
|
|
|
public String shopifyStoreAuthRedirect(@RequestParam(value = "code", required = false) String code,
|
|
|
|
|
@RequestParam(value = "hmac", required = false) String hmac,
|
|
|
|
|
@RequestParam(value = "host", required = false) String host,
|
|
|
|
|
@RequestParam(value = "state", required = false) String state,
|
|
|
|
|
@RequestParam(value = "shop", required = false) String shop,
|
|
|
|
|
@RequestParam(value = "timestamp", required = false) String timestamp) {
|
|
|
|
|
if (StringUtils.isAnyEmpty(shop, hmac, host, state, shop, timestamp)) {
|
|
|
|
|
throw new BadRequestException("Parameter shop,hmac,host,state,shop,timestamp are required");
|
|
|
|
|
}
|
|
|
|
|
if (!Pattern.matches("^[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.myshopify\\.com", shop)) {
|
|
|
|
|
throw new ShopifyRequestVerifyException("Parameter shop is invalid.");
|
|
|
|
|
}
|
|
|
|
@ -90,7 +97,7 @@ public class ShopifyAuthTemplateController {
|
|
|
|
|
.shop(shop)
|
|
|
|
|
.timestamp(timestamp)
|
|
|
|
|
.build();
|
|
|
|
|
if (!shopifyRequestValidator.valid(shopifyCommonParameter)) {
|
|
|
|
|
if (Boolean.FALSE.equals(shopifyRequestValidator.valid(shopifyCommonParameter))) {
|
|
|
|
|
throw new ShopifyRequestVerifyException("This request parameters is invalid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|