Skip to content

Commit

Permalink
feat(merchant-sdk): Refactored merchant-sdk project to have `mercha…
Browse files Browse the repository at this point in the history
…nt` instead of `health` and `gms` instead of `ghs` in the naming of files and variables.

EC-62
  • Loading branch information
danicretu committed Jun 6, 2024
1 parent a195b72 commit 5ec10e4
Show file tree
Hide file tree
Showing 143 changed files with 1,710 additions and 1,732 deletions.
2 changes: 1 addition & 1 deletion RELEASE-ORDER.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Release order for :health-sdk:sdk 4.1.0:

Release order for :merchant-sdk:sdk 4.0.0:
1. :core-api-library:library 2.1.4
2. :health-api-library:library 4.0.0
2. :health-api-library:library 4.1.0
3. :merchant-sdk:sdk 4.0.0

Release order for :capture-sdk:default-network 3.10.3:
Expand Down
2 changes: 1 addition & 1 deletion merchant-sdk/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Moved to https://developer.gini.net/gini-mobile-android/health-sdk/sdk/html/license.html
Moved to https://developer.gini.net/gini-mobile-android/merchant-sdk/sdk/html/license.html
18 changes: 9 additions & 9 deletions merchant-sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
![Gini Health SDK for Android](./logo.png)
![Gini Merchant SDK for Android](./logo.png)

Gini Health SDK for Android
Gini Merchant SDK for Android
===========================

The Gini Health SDK for Android provides all the UI and functionality needed to use the Gini Health API in your app to
The Gini Merchant SDK for Android provides all the UI and functionality needed to use the Gini Merchant API in your app to
extract payment and health information from invoices. The payment information can be reviewed and then the invoice can
be paid using any available payment provider app (e.g., banking app).

The Gini Health API provides an information extraction service for analyzing health invoices. Specifically, it extracts
The Gini Merchant API provides an information extraction service for analyzing health invoices. Specifically, it extracts
information such as the document sender or the payment relevant information (amount to pay, IBAN, etc.). In addition it
also provides a secure channel for sharing payment related information between clients.

Documentation
-------------

* [Integration Guide](https://developer.gini.net/gini-mobile-android/health-sdk/sdk)
* [Integration Guide](https://developer.gini.net/gini-mobile-android/merchant-sdk/sdk)

Example Apps
------------

### Health Example App
### Merchant Example App

You can see a sample usage of the Gini Health SDK in the `:health-sdk:example-app` module.
You can see a sample usage of the Gini Merchant SDK in the `:merchant-sdk:example-app` module.

It requires Gini Health API credentials which are injected automatically if you create this file `health-sdk/example-app/local.properties` with the following properties:
It requires Gini Merchant API credentials which are injected automatically if you create this file `merchant-sdk/example-app/local.properties` with the following properties:
```
clientId=*******
clientSecret=*******
Expand All @@ -37,5 +37,5 @@ An example bank app is available in the [Gini Bank SDK](https://github.com/gini/
License
-------

The Gini Health SDK for Android is available under a commercial license.
The Gini Merchant SDK for Android is available under a commercial license.
See the LICENSE file for more info.
10 changes: 5 additions & 5 deletions merchant-sdk/example-app/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Gini Health SDK Example App
Gini Merchant SDK Example App
=========================

This example app provides you with a sample usage of the Gini Health SDK.
This example app provides you with a sample usage of the Gini Merchant SDK.

The Gini Health API Library is used for analyzing documents and creating payment requests.

Before using the Gini Health SDK example app, you need to set your Gini Health API client id and secret by creating a
Before using the Gini Merchant SDK example app, you need to set your Gini Health API client id and secret by creating a
`local.properties` file in this folder containing a `clientId` and a `clientSecret` property.

ProGuard
Expand All @@ -17,7 +17,7 @@ The release build is configured to run ProGuard. You need a keystore with a key
the `gradle.properties` or as arguments for the build command:

```
$ ./gradlew health-sdk:example-app:assembleRelease \
$ ./gradlew merchant-sdk:example-app:assembleRelease \
-PreleaseKeystoreFile=<path to keystore> \
-PreleaseKeystorePassword=<keystore password> \
-PreleaseKeyAlias=<key alias> \
Expand All @@ -34,7 +34,7 @@ is used for creating release builds which can be shared with clients while the `
for QA purposes. The difference between `prod` and `qa` is that `qa` allows using custom SSL root certificates for
SSL proxies (e.g. Charles Proxy).

Payment Providers for testing the Health SDK
Payment Providers for testing the Merchant SDK
============================================

Payment Providers for testing are provided by the Gini Bank SDK's example app. Run `bundle exec fastlane install_test_payment_provider_apps` in the repository root to install test payment provider apps
Expand Down
4 changes: 2 additions & 2 deletions merchant-sdk/example-app/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version=1.0.0
versionCode=1

# Signing
releaseKeystoreFile=health_sdk_example.jks
releaseKeystoreFile=merchant_sdk_example.jks
releaseKeystorePassword=***
releaseKeyAlias=health_sdk_example
releaseKeyAlias=merchant_sdk_example
releaseKeyPassword=***
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.exampleapp.pager.PagerAdapter
import java.io.File

class MainViewModel(
private val giniHealth: GiniHealth,
private val giniMerchant: GiniMerchant,
) : ViewModel() {
private val _pages: MutableStateFlow<List<PagerAdapter.Page>> = MutableStateFlow(emptyList())
val pages: StateFlow<List<PagerAdapter.Page>> = _pages
Expand All @@ -40,7 +40,7 @@ class MainViewModel(

fun setDocumentForReview(documentId: String) {
viewModelScope.launch {
giniHealth.setDocumentForReview(documentId)
giniMerchant.setDocumentForReview(documentId)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.gini.android.merchant.sdk.exampleapp.di

import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.util.getGiniApi
import org.koin.dsl.module

val giniModule = module {
single { getGiniApi(get(), getProperty("clientId"), getProperty("clientSecret"), "example.com") }
single { GiniHealth(get()) }
single { GiniMerchant(get()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import net.gini.android.core.api.Resource
import net.gini.android.core.api.models.Document
import net.gini.android.core.api.models.ExtractionsContainer
import net.gini.android.health.api.GiniHealthAPI
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.exampleapp.invoices.data.model.DocumentWithExtractions
import java.util.Date

class InvoicesRepository(
private val giniHealthAPI: GiniHealthAPI,
val giniHealth: GiniHealth,
val giniMerchant: GiniMerchant,
private val hardcodedInvoicesLocalDataSource: HardcodedInvoicesLocalDataSource,
private val invoicesLocalDataSource: InvoicesLocalDataSource
) {
Expand Down Expand Up @@ -76,7 +76,7 @@ class InvoicesRepository(
invoicesFlow.value.forEach { document ->
val emptyDocument = createEmptyDocument(document.documentId)
giniHealthAPI.documentManager.getAllExtractions(createEmptyDocument(documentId = document.documentId)).mapSuccess {
val isPayable = giniHealth.checkIfDocumentIsPayable(emptyDocument.id)
val isPayable = giniMerchant.checkIfDocumentIsPayable(emptyDocument.id)
val documentWithExtractions = DocumentWithExtractions.fromDocumentAndExtractions(
emptyDocument,
it.data,
Expand Down Expand Up @@ -104,7 +104,7 @@ class InvoicesRepository(
private suspend fun getDocumentWithExtraction(document: Document): Pair<DocumentWithExtractions?, Resource<ExtractionsContainer>> {
return when (val extractionsResource = giniHealthAPI.documentManager.getAllExtractionsWithPolling(document)) {
is Resource.Success -> {
val isPayable = giniHealth.checkIfDocumentIsPayable(document.id)
val isPayable = giniMerchant.checkIfDocumentIsPayable(document.id)
val documentWithExtractions = DocumentWithExtractions.fromDocumentAndExtractions(
document,
extractionsResource.data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.bankselection.BankSelectionBottomSheet
import net.gini.android.merchant.sdk.exampleapp.R
import net.gini.android.merchant.sdk.exampleapp.databinding.ActivityInvoicesBinding
import net.gini.android.merchant.sdk.exampleapp.invoices.data.UploadHardcodedInvoicesState
import net.gini.android.merchant.sdk.exampleapp.invoices.ui.model.InvoiceItem
import net.gini.android.merchant.sdk.integratedFlow.ContainerFragment
import net.gini.android.merchant.sdk.moreinformation.MoreInformationFragment
import net.gini.android.merchant.sdk.paymentcomponent.PaymentComponent
import net.gini.android.merchant.sdk.paymentcomponent.PaymentComponentView
Expand Down Expand Up @@ -132,7 +131,7 @@ class InvoicesActivity : AppCompatActivity() {
launch {
viewModel.openBankState.collect { paymentState ->
when (paymentState) {
is GiniHealth.PaymentState.Success -> {
is GiniMerchant.PaymentState.Success -> {
viewModel.updateDocument()
}
else -> {}
Expand Down Expand Up @@ -172,15 +171,6 @@ class InvoicesActivity : AppCompatActivity() {

viewModel.getPaymentReviewFragment(documentId)
}

override fun onStartIntegratedFlow() {
ContainerFragment.newInstance(paymentComponent = viewModel.paymentComponent).apply {
supportFragmentManager.beginTransaction()
.add(R.id.fragment_container,this, this::class.java.simpleName)
.addToBackStack(this::class.java.simpleName)
.commit()
}
}
}

// Reattach the listener to the ReviewFragment if it is being shown (in case of configuration changes)
Expand All @@ -199,7 +189,7 @@ class InvoicesActivity : AppCompatActivity() {
title = getString(R.string.title_activity_invoices)
} else if (supportFragmentManager.fragments.last() is MoreInformationFragment) {
title =
getString(net.gini.android.merchant.sdk.R.string.ghs_more_information_fragment_title)
getString(net.gini.android.merchant.sdk.R.string.gms_more_information_fragment_title)
} else if (supportFragmentManager.fragments.last() is ReviewFragment) {
title = getString(R.string.title_payment_review)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class InvoicesViewModel(
val _paymentReviewFragmentFlow = MutableStateFlow<PaymentReviewFragmentState>(PaymentReviewFragmentState.Idle)
val paymentReviewFragmentStateFlow = _paymentReviewFragmentFlow.asStateFlow()

val openBankState = invoicesRepository.giniHealth.openBankState
val openBankState = invoicesRepository.giniMerchant.openBankState

fun updateDocument() {
viewModelScope.launch {
with(invoicesRepository) {
requestDocumentExtractionAndSaveToLocal((giniHealth.documentFlow.value as ResultWrapper.Success).value)
requestDocumentExtractionAndSaveToLocal((giniMerchant.documentFlow.value as ResultWrapper.Success).value)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import dev.chrisbanes.insetter.applyInsetter
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import net.gini.android.core.api.models.Document
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.bankselection.BankSelectionBottomSheet
import net.gini.android.merchant.sdk.exampleapp.R
import net.gini.android.merchant.sdk.exampleapp.databinding.ActivityReviewBinding
Expand All @@ -45,23 +45,23 @@ class ReviewActivity : AppCompatActivity() {
override fun onToTheBankButtonClicked(paymentProviderName: String) {
LOG.debug("to the bank button clicked with payment provider: {}", paymentProviderName)
lifecycleScope.launch {
viewModel.giniHealth.openBankState.collect { paymentState ->
viewModel.giniMerchant.openBankState.collect { paymentState ->
when (paymentState) {
GiniHealth.PaymentState.Loading -> {
GiniMerchant.PaymentState.Loading -> {
LOG.debug("opening bank app")
}

is GiniHealth.PaymentState.Success -> {
is GiniMerchant.PaymentState.Success -> {
LOG.debug("launching bank app: {}", paymentState.paymentRequest.bankApp.name)
cancel()
}

is GiniHealth.PaymentState.Error -> {
is GiniMerchant.PaymentState.Error -> {
LOG.error( "failed to open bank app:", paymentState.throwable)
cancel()
}

GiniHealth.PaymentState.NoAction -> {}
GiniMerchant.PaymentState.NoAction -> {}
}
}
}
Expand All @@ -77,7 +77,7 @@ class ReviewActivity : AppCompatActivity() {
private val showCloseButton = true

override fun onCreate(savedInstanceState: Bundle?) {
viewModel.giniHealth.setSavedStateRegistryOwner(this, viewModel.viewModelScope)
viewModel.giniMerchant.setSavedStateRegistryOwner(this, viewModel.viewModelScope)

WindowCompat.setDecorFitsSystemWindows(window, false)

Expand All @@ -104,9 +104,6 @@ class ReviewActivity : AppCompatActivity() {

// Set a listener on the PaymentComponent to receive events from the PaymentComponentView
viewModel.paymentComponent.listener = object : PaymentComponent.Listener {
override fun onStartIntegratedFlow() {

}
override fun onMoreInformationClicked() {}

override fun onBankPickerClicked() {
Expand Down Expand Up @@ -149,9 +146,9 @@ class ReviewActivity : AppCompatActivity() {
binding.paymentComponentView.paymentComponent = viewModel.paymentComponent

lifecycleScope.launch {
val documentId = (viewModel.giniHealth.documentFlow.value as ResultWrapper.Success<Document>).value.id
val documentId = (viewModel.giniMerchant.documentFlow.value as ResultWrapper.Success<Document>).value.id

val isDocumentPayable = viewModel.giniHealth.checkIfDocumentIsPayable(documentId)
val isDocumentPayable = viewModel.giniMerchant.checkIfDocumentIsPayable(documentId)

if (!isDocumentPayable) {
AlertDialog.Builder(this@ReviewActivity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.gini.android.merchant.sdk.exampleapp.review

import androidx.lifecycle.ViewModel
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.paymentcomponent.PaymentComponent

class ReviewViewModel(val giniHealth: GiniHealth, val paymentComponent: PaymentComponent) : ViewModel()
class ReviewViewModel(val giniMerchant: GiniMerchant, val paymentComponent: PaymentComponent) : ViewModel()
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import kotlinx.coroutines.launch
import net.gini.android.core.api.MediaTypes
import net.gini.android.core.api.Resource
import net.gini.android.health.api.GiniHealthAPI
import net.gini.android.merchant.sdk.GiniHealth
import net.gini.android.merchant.sdk.GiniMerchant
import net.gini.android.merchant.sdk.exampleapp.invoices.data.InvoicesLocalDataSource
import net.gini.android.merchant.sdk.exampleapp.invoices.data.model.DocumentWithExtractions
import net.gini.android.merchant.sdk.exampleapp.util.getBytes

class UploadViewModel(
private val giniHealthAPI: GiniHealthAPI,
val giniHealth: GiniHealth,
val giniMerchant: GiniMerchant,
private val invoicesLocalDataSource: InvoicesLocalDataSource
) : ViewModel() {
private val _uploadState: MutableStateFlow<UploadState> = MutableStateFlow(UploadState.Loading)
Expand Down Expand Up @@ -55,7 +55,7 @@ class UploadViewModel(

giniHealthAPI.documentManager.getAllExtractions(polledDocumentResource.data)
.mapSuccess { extractionsResource ->
val isPayable = giniHealth.checkIfDocumentIsPayable(polledDocumentResource.data.id)
val isPayable = giniMerchant.checkIfDocumentIsPayable(polledDocumentResource.data.id)
invoicesLocalDataSource.appendInvoiceWithExtractions(
DocumentWithExtractions.fromDocumentAndExtractions(
polledDocumentResource.data,
Expand All @@ -75,7 +75,7 @@ class UploadViewModel(

private fun setDocumentForReview(documentId: String) {
viewModelScope.launch {
giniHealth.setDocumentForReview(documentId)
giniMerchant.setDocumentForReview(documentId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:shape="ring"
android:thickness="@dimen/indicator_size"
android:useLevel="false">
<solid android:color="@color/ghs_color_contrast_03"/>
<solid android:color="@color/gms_color_contrast_03"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:shape="ring"
android:thickness="@dimen/indicator_size"
android:useLevel="false">
<solid android:color="@color/ghs_color_03"/>
<solid android:color="@color/gms_color_03"/>
</shape>
</item>
</layer-list>
Loading

0 comments on commit 5ec10e4

Please sign in to comment.