Skip to content

Commit

Permalink
WLP-2785: updated README.md 3;
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-r-smartdata committed Dec 2, 2024
1 parent 62c5d3e commit 74abc5c
Showing 1 changed file with 59 additions and 61 deletions.
120 changes: 59 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,35 @@ There are several key points in creating the configuration object to consider:
```kotlin
val configs = WhitelabelPayConfigurations(
bundleId = BuildConfig.APPLICATION_ID,
merchantId = MERCHANR_ID,
merchantId = MERCHANT_ID,
notificationId = NOTIFICATION_ID,
environment = WhitelabelPayEnvironment.INTEGRATION,
showErrorLogs = true
)
```

- `MERCHANT_ID` is provided by PaymentTools;
- `MERCHANT_ID` use `rew` as merchant id;
- `NOTIFICATION_ID` represents a UUID value converted to a string and without dashes.

### 2. SDK State
The WhitelabelPay SDK offers a mechanism to check the status of the SDK instance within the
WhitelabelPay system:

```kotlin
val state = sdk.deviceState()
val state = sdk.deviceState()
```

or observe the state changes:

```kotlin
sdk.observeDeviceState()
.collect { state ->
when (state) {
State.INACTIVE -> { }
State.ONBOARDING -> { }
State.ACTIVE -> { }
}
sdk.observeDeviceState()
.collect { state ->
when (state) {
State.INACTIVE -> { }
State.ONBOARDING -> { }
State.ACTIVE -> { }
}
}
```

### 3. Tokens
Expand All @@ -126,11 +126,11 @@ or observe the state changes:
The enrolment token is used to register a card (once or multiple times) within the WhitelabelPay
system. The sdk provides a function to get the enrolment token:
```kotlin
try {
val enrolmentToken = sdk.getEnrolmentToken()
} catch (e: Exception) {
Timber.e("get onboarding token failed: ", e)
}
try {
val enrolmentToken = sdk.getEnrolmentToken()
} catch (e: Exception) {
Timber.e("get onboarding token failed: ", e)
}
```

The enrolment token:
Expand All @@ -144,19 +144,19 @@ In order to use the token with the OneScan format, the SDK offers an utility fun
the string representation of the token:

```kotlin
val tokenString = enrolmentToken.stringRepresentation()
val tokenString = enrolmentToken.stringRepresentation()
```

#### Payment token
The payment token is used to make payments within the WhitelabelPay system.
The sdk provides a function to get a payment token (if available):

```kotlin
try {
val paymentToken = sdk.getPaymentToken()
} catch (e: Exception) {
Timber.e("get payment token failed: ", e)
}
try {
val paymentToken = sdk.getPaymentToken()
} catch (e: Exception) {
Timber.e("get payment token failed: ", e)
}
```

A payment token(s):
Expand Down Expand Up @@ -188,13 +188,13 @@ The SDK offers an utility function to synchronize all SDK data available on devi
data and payment tokens):

```kotlin
viewModelScope.launch {
try {
val state = sdk.sync()
} catch (e: Exception) {
Timber.e("sync failed: ", e)
}
viewModelScope.launch {
try {
val state = sdk.sync()
} catch (e: Exception) {
Timber.e("sync failed: ", e)
}
}
```

### 5. Registered cards operations (payment means)
Expand All @@ -204,53 +204,53 @@ called **payment means** within WhitelabelPay.

#### - Retrieve payment means
```kotlin
try {
val paymentMeansList = sdk.getPaymentMeansList()
} catch (e: Exception) {
Timber.e("get payment means list failed: ", e)
}
try {
val paymentMeansList = sdk.getPaymentMeansList()
} catch (e: Exception) {
Timber.e("get payment means list failed: ", e)
}
```

#### - Deactivate an active payment mean
```kotlin
viewModelScope.launch {
try {
sdk.deactivatePaymentMeans(
paymentMeanId = paymentMean.Id,
onDeactivationSuccess = { }
)
} catch (e: Exception) {
Timber.e("deactivation of payment mean failed: ", e)
}
viewModelScope.launch {
try {
sdk.deactivatePaymentMeans(
paymentMeanId = paymentMean.Id,
onDeactivationSuccess = { }
)
} catch (e: Exception) {
Timber.e("deactivation of payment mean failed: ", e)
}
}
```

#### - Reactivate an inactive payment mean
```kotlin
viewModelScope.launch {
try {
sdk.reactivatePaymentMean(
paymentMeanId = paymentMean.Id,
onReactivationSuccess = { }
)
} catch (e: Exception) {
Timber.e("reactivation of payment mean failed: ", e)
}
viewModelScope.launch {
try {
sdk.reactivatePaymentMean(
paymentMeanId = paymentMean.Id,
onReactivationSuccess = { }
)
} catch (e: Exception) {
Timber.e("reactivation of payment mean failed: ", e)
}
}
```

#### - Delete a payment mean
```kotlin
viewModelScope.launch {
try {
sdk.deletePaymentMean(
paymentMeanId = paymentMean.Id,
onDeletionSuccess = { }
)
} catch (e: Exception) {
Timber.e("deleting payment mean failed: ", e)
}
viewModelScope.launch {
try {
sdk.deletePaymentMean(
paymentMeanId = paymentMean.Id,
onDeletionSuccess = { }
)
} catch (e: Exception) {
Timber.e("deleting payment mean failed: ", e)
}
}
```

### 6. Sign Off
Expand Down Expand Up @@ -314,5 +314,3 @@ the shared preferences file should not be backed up. Here's an example of such a
```

where `bundle-id` is the value specified at step: 1. Setup for `bundleId` parameter.

# Package paymenttoosl-sdk

0 comments on commit 74abc5c

Please sign in to comment.