Add cancellation callback URL

This commit is contained in:
Grishka 2024-06-17 16:38:00 +03:00
parent bc6b3e1186
commit 1c6da783ad
3 changed files with 12 additions and 4 deletions

View File

@ -13,7 +13,7 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 33
versionCode 101
versionCode 102
versionName "2.5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -15,15 +15,15 @@ import org.joinmastodon.android.R;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.events.DismissDonationCampaignBannerEvent;
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
import org.joinmastodon.android.ui.sheets.DonationSuccessfulSheet;
import java.util.Objects;
import me.grishka.appkit.Nav;
public class DonationWebViewFragment extends WebViewFragment{
public static final String SUCCESS_URL="https://sponsor.joinmastodon.org/donation/success";
public static final String FAILURE_URL="https://sponsor.joinmastodon.org/donation/failure";
public static final String SUCCESS_URL="https://sponsor.joinmastodon.org/donate/success";
public static final String FAILURE_URL="https://sponsor.joinmastodon.org/donate/failure";
public static final String CANCEL_URL="https://sponsor.joinmastodon.org/donate/cancel";
@Override
public void onCreate(Bundle savedInstanceState){
@ -48,6 +48,9 @@ public class DonationWebViewFragment extends WebViewFragment{
}else if(url.equalsIgnoreCase(FAILURE_URL)){
onFailure();
return true;
}else if(url.equalsIgnoreCase(CANCEL_URL)){
onCancel();
return true;
}
return false;
}
@ -86,4 +89,8 @@ public class DonationWebViewFragment extends WebViewFragment{
getActivity().setResult(Activity.RESULT_OK, new Intent().putExtra("postText", getArguments().getString("successPostText")));
getActivity().finish();
}
private void onCancel(){
getActivity().finish();
}
}

View File

@ -244,6 +244,7 @@ public class DonationSheet extends BottomSheet{
case YEARLY -> "yearly";
})
.appendQueryParameter("success_callback_url", DonationWebViewFragment.SUCCESS_URL)
.appendQueryParameter("cancel_callback_url", DonationWebViewFragment.CANCEL_URL)
.appendQueryParameter("failure_callback_url", DonationWebViewFragment.FAILURE_URL);
Bundle args=new Bundle();
args.putString("url", builder.build().toString());