set cookie for paypal problem

This commit is contained in:
2020-06-07 21:44:51 +03:00
parent aa508b9364
commit 76b3bc8cda
9 changed files with 66 additions and 5 deletions

Binary file not shown.

View File

@@ -22,8 +22,8 @@ android {
applicationId "ch.pizzacucina.android"
minSdkVersion 16
targetSdkVersion 28
versionCode 7 // play store'daki version --> canlı: 0 - dahili test: 17
versionName "1.07" // play store'daki version --> canlı: 0.00 - dahili test: 1.17
versionCode 8 // play store'daki version --> canlı: 0 - dahili test: 17
versionName "1.08" // play store'daki version --> canlı: 0.00 - dahili test: 1.17
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
manifestPlaceholders = [

View File

@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":7,"versionName":"1.07","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"1.08","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

View File

@@ -68,7 +68,7 @@ public class SplashActivity extends BaseActivity {
//DisplayHelper.changeStatusColor();
if(NetworkHelper.isNetworkAvailable()){
registerNotificationTag();
getStoreList();
getSessionId();
}
else{
DialogHelper.showNoNetworkDialog();
@@ -108,8 +108,33 @@ public class SplashActivity extends BaseActivity {
}
}
private void getStoreList(){
private void getSessionId(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<String>> call = ApiService.apiInterface.getSessionId();
call.enqueue(new Callback<ResponseObject<String>>() {
@Override
public void onResponse(Call<ResponseObject<String>> call, Response<ResponseObject<String>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess() && !response.body().getData().isEmpty()){
SessionHelper.saveSessionId(response.body().getData());
getStoreList();
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<String>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getStoreList(){
Call<ResponseArray<StoreModel>> call = ApiService.apiInterface.getStoreList();
call.enqueue(new Callback<ResponseArray<StoreModel>>() {
@Override

View File

@@ -7,6 +7,7 @@ public class ApiEndPoints {
public static final String API_GET_STORE_LIST = "pizza/servicemagazabelirle.php";
public static final String API_GET_CAMPAIGN_BANNERS = "pizzacucina" + PREFIX + "getCampaignBanners" + SUFFIX;
public static final String API_GET_SESSION_ID = "pizzacucina" + PREFIX + "getSessionId" + SUFFIX;
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
public static final String API_GET_IGNORED_CATEGORY_IDS= PREFIX + "getIgnoredCategory" + SUFFIX;

View File

@@ -228,6 +228,9 @@ public interface ApiInterface {
@GET(ApiEndPoints.API_GET_STORE_LIST)
Call<ResponseArray<StoreModel>> getStoreList();
@GET(ApiEndPoints.API_GET_SESSION_ID)
Call<ResponseObject<String>> getSessionId();
@GET("{storeName}" + ApiEndPoints.API_GET_DELIVERY_TIME_OF_STORE)
Call<ResponseObject<StoreShiftModel>> getDeliveryTimeOfStore(@Path("storeName") String storeName,
@Query("shipping_method_code") String shippingMethodCode);

View File

@@ -7,6 +7,7 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit;
import ch.pizzacucina.android.BuildConfig;
import ch.pizzacucina.android.helper.SessionHelper;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@@ -44,6 +45,14 @@ public class ApiService {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("Content-Type", "application/json");
String url = chain.request().url().toString();
if(!url.contains("getSessionId") && !SessionHelper.getSessionId().isEmpty()){
builder.addHeader("session_id", SessionHelper.getSessionId());
//String cookie = "language=de-DE; currency=CHF; PHPSESSID=" + SessionHelper.getSessionId() + ";";
String cookie = "PHPSESSID=" + SessionHelper.getSessionId() + ";";
builder.addHeader("Cookie", cookie);
}
Request request = builder.build();
return chain.proceed(request);
}

View File

@@ -78,6 +78,14 @@ public class SessionHelper {
SharedPrefsHelper.saveSelectedCoupon(couponModel);
}
public static String getSessionId(){
return SharedPrefsHelper.getSessionId();
}
public static void saveSessionId(String sessionId){
SharedPrefsHelper.saveSessionId(sessionId);
}
public static CheckCouponModel getSelectedCoupon(){
return SharedPrefsHelper.getSelectedCoupon();
}

View File

@@ -37,6 +37,7 @@ public class SharedPrefsHelper {
private static final String PREF_KEY_USER_SELECTED_STORE = SHARED_PREFS_NAME + "selectedStore";
private static final String PREF_KEY_IS_FIRST_TIME = SHARED_PREFS_NAME + "isFirstTime";
private static final String PREF_KEY_SELECTED_COUPON = SHARED_PREFS_NAME + "selectedCoupon";
private static final String PREF_KEY_SESSION_ID = SHARED_PREFS_NAME + "sessionId";
private static SharedPreferences sharedPreferences =
BaseActivity.currentActivity
@@ -93,6 +94,7 @@ public class SharedPrefsHelper {
editor.remove(PREF_KEY_CART_ITEM_COUNT);
editor.remove(PREF_KEY_CART_TOTAL_PRICE);
editor.remove(PREF_KEY_SELECTED_COUPON);
editor.remove(PREF_KEY_SESSION_ID);
editor.apply();
}
@@ -186,6 +188,19 @@ public class SharedPrefsHelper {
editor.apply();
}
public static void saveSessionId(String sessionId){
editor.putString(PREF_KEY_SESSION_ID, sessionId);
editor.apply();
}
public static String getSessionId(){
return sharedPreferences.getString(PREF_KEY_SESSION_ID, "");
}
public static void clearSessionId(){
editor.remove(PREF_KEY_SESSION_ID);
editor.apply();
}
/*