Safepay logo
Docs
Safepay logo
Launch Safepay

Java SDK

Learn how to integrate Safepay Checkout into your Java Android App


A set of components allowing easy integration of Safepay Button and Safepay Checkout into your website, powered by zoid

1. Add WebView to your layout XML file

Open the XML layout file (activity_main.xml or any other layout file) and add a WebView element.

2. Load URL in WebView

In your Java code, you can load a URL into the WebView by finding the WebView instance and calling the loadUrl method.

3. Create a WebViewClient

If you want to detect changes in the URL history of a WebView, you can use the doUpdateVisitedHistory method in combination with the WebHistoryItem class. Create a WebViewClient and override the doUpdateVisitedHistory method

4. Use the WebHistoryItem

Use the WebHistoryItem class to access the URL history items.

5. Check URL in case of success on Safepay Hosted Checkout

Check if the URL contains `/external/mobile`. If it does, parse the `action` query parameter in `currentUrl`. If the value of `action` is 'complete', you can safely close the Safepay Checkout.

6. Check URL in case of an error on Safepay Hosted Checkout

Check if the url contains /external/error. If yes, you can safely close Safepay Checkout.

7. Check URL in case of cancellation on Safepay Hosted Checkout

Check if the URL contains `/external/mobile`. If it does, parse the `action` query parameter in `currentUrl`. If the value of `action` is 'cancelled', you can safely close the Safepay Checkout.

8. Check URL in case of success on Safepay Embedded Checkout

Check if the url contains /external/complete. If yes, you can safely close Safepay Checkout.

9. Check URL in case of an error on Safepay Embedded Checkout

Check if the url contains /external/error If yes, you can safely close Safepay Checkout.

Feedback

What do you think of our integration document? Let us know here support@getsafepay.com

Preview
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Previous
Node JS SDK
Next
IOS SDK