Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jennylarsson94 committed Jun 12, 2023
1 parent b88ae63 commit e5df36d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The Trustly Android SDK provides an easy way to implement the Trustly Checkout i

## Integration
Integrate the Trustly Android SDK through Maven Central.
Add the following to your Project level `build.gradle` file
Add the following to your Project level `build.gradle` file:

```gradle
repositories {
...
Expand All @@ -15,6 +16,7 @@ repositories {
```

Add Trustly SDK as dependency in your Module level the `build.gradle` file like so

```gradle
dependencies {
...
Expand All @@ -25,6 +27,7 @@ dependencies {
```

You also need to add the `INTERNET` permission to your `AndroidManifest.xml`

```xml
<uses-permission android:name="android.permission.INTERNET"/>
```
Expand All @@ -41,6 +44,7 @@ Example usage:
```

Instantiate a TrustlyWebView by passing the CheckouURL as a parameter from the activity. Assign the TrustlyWebView to the WebView.

```java
WebView main = findViewById(R.id.webview);
TrustlyWebView trustlyView = new TrustlyWebView(this, trustlyCheckoutUrl);
Expand All @@ -49,19 +53,22 @@ main.addView(trustlyView);
### Receiving Checkout Events
If you want more control of your Checkout flow you can choose to provide custom handlers.

Provide `successHanlder`, `abortHanlder` and `errorHandler` lambdas.
Provide `successHandler`, `abortHandler` and `errorHandler` lambdas.
In case no custom functionality is provided, the webview will load the `SuccessURL` in case of a success event, or the `FailURL` in case of a error or an abort event.
Read more https://eu.developers.trustly.com/doc/docs/order-initiation
[Read more](https://eu.developers.trustly.com/doc/docs/order-initiation)


```java
trustlyView = new TrustlyWebView(this, trustlyCheckoutUrl);

trustlyView.successHandler = () -> {
// your custom implementation here.
};

trustlyView.errorHandler = () -> {
// your custom implementation here.
};

trustlyView.abortHandler = () -> {
// your custom implementation here.
};
Expand All @@ -70,11 +77,13 @@ Read more https://eu.developers.trustly.com/doc/docs/order-initiation

## Automatic re-directs back to your application
It can happen that during the order flow, the user needs to be redirected outside of your application, to a third party application or website (in external stand alone browser). This could be part of the authentication and authorisation process.
To enable automatic re-directs back to your native application, you can pass a [link](https://developer.android.com/training/app-links) as an attribute to the order initiation request. You can pass your link (web, app link or deep link) value by including it in the "URLScheme" attribute when making an API call to Trustly. [You can read more about it here.](https://developers.trustly.com/emea/docs/ios)
To enable automatic re-directs back to your native application, you can pass a [link](https://developer.android.com/training/app-links) as an attribute to the order initiation request. You can pass your link (web, app link or deep link) value by including it in the `ReturnToAppURL` attribute when making an API call to Trustly. [You can read more about it here.](https://eu.developers.trustly.com/doc/reference/android-sdk)

:warning: It's important that the Activity hosting the checkout doesn't reload when the intent is received. Otherwise the Trustly checkout session will be lost.
When defining you intent filters make sure to set `android:launchMode="singleTop"` parameter in your manifest file.

Below is an example intent filter setup in the manifest xml.

```
<activity
android:name=".YOUR_TRUSTLY_WEB_VIEW_ACTIVITY"
Expand Down

0 comments on commit e5df36d

Please sign in to comment.