Skip to content

Commit

Permalink
Resolved KSA order issues
Browse files Browse the repository at this point in the history
  • Loading branch information
harshalrandhe committed Feb 14, 2024
1 parent 1977087 commit 87f4eab
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected void onCreate(Bundle savedInstanceState) {
productDetails.setVendorMobile("1122334455");
productDetails.setProductName(productBean.getName());
productDetails.setProductPrice(productBean.getPrice());
// productDetails.setCurrency("SAR");
productDetails.setCurrency("AED");
productDetails.setImage(productBean.getImg());
paymentData.setProductDetails(productDetails);
Expand Down Expand Up @@ -131,21 +132,23 @@ protected void onCreate(Bundle savedInstanceState) {
orderDetails.setAmount(paymentData.getProductDetails().getProductPrice());
orderDetails.setCurrency(paymentData.getProductDetails().getCurrency());
orderDetails.setDescription("Mobile Payment");
orderDetails.setReturn_url("https://ulis.live:8081/status");
orderDetails.setReturn_url("https://ulis.live:8082/status");
paymentData.setOrder_details(orderDetails);

MerchantUrls merchantUrls = new MerchantUrls();
merchantUrls.setSuccess("https://ulis.live:8081/status");
merchantUrls.setCancel("https://ulis.live:8081/status");
merchantUrls.setFailure("https://ulis.live:8081/status");
merchantUrls.setSuccess("https://ulis.live:8082/status");
merchantUrls.setCancel("https://ulis.live:8082/status");
merchantUrls.setFailure("https://ulis.live:8082/status");
paymentData.setMerchant_urls(merchantUrls);

// paymentData.setMerchantKey(BuildConfig.MERCHANT_KEY);
// paymentData.setMerchantSecret(BuildConfig.MERCHANT_PASSWORD);
paymentData.setMerchantKey("live-SH10ZQM18IQ");
paymentData.setMerchantSecret("sec-IW101K818CW");
// paymentData.setMerchantKey("test-ZR1OGP6NR");
// paymentData.setMerchantSecret("sec-3P1LHI6GR");
// paymentData.setMerchantKey("live-SH10ZQM18IQ");
// paymentData.setMerchantSecret("sec-IW101K818CW");
paymentData.setMerchantKey("test-ZR1OGP6NR");
paymentData.setMerchantSecret("sec-3P1LHI6GR");
// paymentData.setMerchantKey("live-4B1QTZ138S");
// paymentData.setMerchantSecret("sec-HV18UG13PD");

Gson gson = new Gson();
paymentData.setProductBean(gson.fromJson(gson.toJson(productBean),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ulisfintech.telrpay.helper;



import android.os.Parcel;
import android.os.Parcelable;

Expand All @@ -23,6 +22,7 @@ public class OrderResponse extends BaseResponse implements Parcelable {
private String returnUrl;

private String env;
private String region;

public OrderResponse() {

Expand All @@ -36,6 +36,7 @@ protected OrderResponse(Parcel in) {
merchantUrls = in.readParcelable(MerchantUrls.class.getClassLoader());
returnUrl = in.readString();
env = in.readString();
region = in.readString();
}

@Override
Expand All @@ -47,6 +48,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(merchantUrls, flags);
dest.writeString(returnUrl);
dest.writeString(env);
dest.writeString(region);
}

@Override
Expand Down Expand Up @@ -121,4 +123,12 @@ public String getEnv() {
public void setEnv(String env) {
this.env = env;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,34 @@

class GatewayRequestBuilder {

private final String BASE_ORDER_URL = "https://ulis.live:4014/api/v1/orders/";
private final String BASE_ORDER_URL_UAE = "https://ulis.live:4014/api/v1/orders/";
private final String BASE_ORDER_URL_KSA = "https://ulis.live:4016/api/v1/orders/";
private final String BASE_REGION_URL = "https://ulis.live:4010/api/v1/merchant_key_secret/find/region";
static final String KSA = "KSA";
static final String UAE = "UAE";

public GatewayRequestBuilder() {
}

private String getBaseUrl(String region){
if (region.equalsIgnoreCase(UAE)) {
return BASE_ORDER_URL_UAE;
}else {
return BASE_ORDER_URL_KSA;
}
}

/**
* Check Order Status
*
* @param orderId order id
* @param endPoint order status api url
* @param endPoint order status api url
* @param headerBean API headers
* @return API request
*/
GatewayRequest buildOrderStatusRequest(String orderId, String endPoint, HeaderBean headerBean) {
GatewayRequest request = new GatewayRequest();
request.URL = BASE_ORDER_URL + endPoint;
request.URL = getBaseUrl(headerBean.getRegion()) + endPoint;
request.method = GatewayRequest.POST;
request.payload = new OrderIdBean(orderId);
request.extraHeaders = getHeaders(headerBean);
Expand All @@ -37,7 +49,7 @@ GatewayRequest buildOrderStatusRequest(String orderId, String endPoint, HeaderBe
*/
GatewayRequest buildOrderDetailsRequest(String orderId, String token, HeaderBean headerBean) {
GatewayRequest request = new GatewayRequest();
request.URL = BASE_ORDER_URL + "details";
request.URL = getBaseUrl(headerBean.getRegion()) + "details";
request.method = GatewayRequest.POST;
request.payload = new OrderIdBean(orderId, token);
request.extraHeaders = getHeaders(headerBean);
Expand All @@ -53,14 +65,27 @@ GatewayRequest buildOrderDetailsRequest(String orderId, String token, HeaderBean
*/
GatewayRequest buildCreateOrderRequest(OrderBean orderBean) {
GatewayRequest request = new GatewayRequest();
request.URL = BASE_ORDER_URL + "create";
request.URL = getBaseUrl(orderBean.getHeaders().getRegion()) + "create";
request.method = GatewayRequest.POST;
request.payload = new OrderPayload(orderBean);
// request.payload = new OrderPayload(jsonObject);
request.extraHeaders = getHeaders(orderBean.getHeaders());
return request;
}

/**
* @param headerBean
* @return check merchant region ( UAE OR KSA)
*/
GatewayRequest buildCheckRegionRequest(HeaderBean headerBean) {
GatewayRequest request = new GatewayRequest();
request.URL = BASE_REGION_URL;
request.method = GatewayRequest.POST;
request.payload = new OrderPayload();
request.extraHeaders = getHeaders(headerBean);
return request;
}

/**
* API Headers
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class HeaderBean {
private String merchant_key;
private String merchant_secret;
private String ip;
private String region;

public String getXusername() {
return xusername;
Expand Down Expand Up @@ -47,4 +48,12 @@ public String getIp() {
public void setIp(String ip) {
this.ip = ip;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private GatewayMap executeGatewayRequest(GatewayRequest request) throws Exceptio
}

// otherwise, create a gateway exception and throw it
String message = (String) response.get("error.explanation");
String message = (String) response.get("message");
if (message == null) {
message = "An error occurred";
}
Expand Down
Loading

0 comments on commit 87f4eab

Please sign in to comment.