Skip to content

Commit

Permalink
1.3.94
Browse files Browse the repository at this point in the history
  • Loading branch information
plpt88 committed Apr 16, 2024
1 parent 95634ad commit ede1cc4
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 86 deletions.
6 changes: 3 additions & 3 deletions GenesisAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'kotlin-kapt'

ext {
PUBLISH_GROUP_ID = 'com.emerchantpay.gateway'
PUBLISH_VERSION = '1.3.93'
PUBLISH_VERSION = '1.3.94'
PUBLISH_ARTIFACT_ID = 'genesis-android'
PUBLISH_DESCRIPTION = 'Genesis Android SDK'
PUBLISH_URL = 'https://github.com/GenesisGateway/android_sdk'
Expand All @@ -24,10 +24,10 @@ apply from: "${rootProject.projectDir}/scripts/maven-push.gradle"
android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.3.93"
versionName PUBLISH_VERSION
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.emerchantpay.gateway.genesisandroid.api.constants

import java.io.Serializable
enum class Endpoints(val endpointName: String) {
// Domain for E-ComProcessing's Genesis instance
ECOMPROCESSING("e-comprocessing.net"),

class Endpoints(val endpointName: String) : Serializable {
// Domain for Emerchantpay's Genesis instance
EMERCHANTPAY("emerchantpay.net"),

override fun toString(): String {
return endpointName
}

companion object {
// Domains for Consumer API
RETRIEVE_CONSUMER_EMERCHANTPAY("emerchantpay.net/v1/retrieve_consumer"),
RETRIEVE_CONSUMER_ECOMPROCESSING("e-comprocessing.net/v1/retrieve_consumer");

// Domain for E-ComProcessing's Genesis instance
val ECOMPROCESSING = Endpoints("e-comprocessing.net")

// Domain for Emerchantpay's Genesis instance
val EMERCHANTPAY = Endpoints("emerchantpay.net")

// Domains for Consumer API
val RETRIEVE_CONSUMER_EMERCHANTPAY = Endpoints("emerchantpay.net/v1/retrieve_consumer")
val RETRIEVE_CONSUMER_ECOMPROCESSING = Endpoints("e-comprocessing.net/v1/retrieve_consumer")
override fun toString(): String {
return endpointName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package com.emerchantpay.gateway.genesisandroid.api.internal
import android.content.Context
import com.emerchantpay.gateway.genesisandroid.api.constants.Endpoints
import com.emerchantpay.gateway.genesisandroid.api.constants.ErrorCodes
import com.emerchantpay.gateway.genesisandroid.api.constants.SharedPrefConstants
import com.emerchantpay.gateway.genesisandroid.api.internal.request.PaymentRequest
import com.emerchantpay.gateway.genesisandroid.api.internal.request.ReconcileRequest
import com.emerchantpay.gateway.genesisandroid.api.internal.request.RetrieveConsumerRequest
import com.emerchantpay.gateway.genesisandroid.api.internal.response.Response
import com.emerchantpay.gateway.genesisandroid.api.models.GenesisError
import com.emerchantpay.gateway.genesisandroid.api.network.HttpAsyncTask
import com.emerchantpay.gateway.genesisandroid.api.util.*
import com.emerchantpay.gateway.genesisandroid.api.util.Configuration
import com.emerchantpay.gateway.genesisandroid.api.util.NodeWrapper
import com.emerchantpay.gateway.genesisandroid.api.util.Request

open class GenesisClient : Request {

Expand Down Expand Up @@ -118,25 +119,23 @@ open class GenesisClient : Request {
http = HttpAsyncTask(configuration)

try {
var paymentRequest: PaymentRequest? = null
var paymentRequest: PaymentRequest?

response = when (genesisRequest) {
is ReconcileRequest -> http?.execute(configuration?.baseUrl, genesisRequest as? ReconcileRequest)?.get()
else -> {
paymentRequest = genesisRequest as? PaymentRequest

if (paymentRequest?.consumerId.isNullOrBlank()) {
val consumerId = retrieveConsumerIdFromGenesisGateway(paymentRequest?.getCustomerEmail())

consumerId?.let { paymentRequest = paymentRequest?.setConsumerId(it) }
}

http?.execute(configuration?.baseUrl, paymentRequest)?.get()
}
}

// Retrieve and store consumer id
val result = this.transaction?.request
var consumerId = result?.transaction?.consumerId
when {
Response(this).isSuccess!!
&& consumerId.isNullOrEmpty()
&& !paymentRequest?.getCustomerEmail().isNullOrEmpty() -> {
consumerId = retrieveConsumerIdFromGenesisGateway(paymentRequest?.getCustomerEmail())
}
}
} catch (e: Exception) {
GenesisError(ErrorCodes.SYSTEM_ERROR.code, e.message?: ErrorCodes.getErrorDescription(ErrorCodes.SYSTEM_ERROR.code?: 1))
}
Expand All @@ -145,22 +144,37 @@ open class GenesisClient : Request {
}

private fun retrieveConsumerIdFromGenesisGateway(email: String?): String? {
http = HttpAsyncTask(configuration)
val httpClient = HttpAsyncTask(configuration)

val retrieveConsumerRequest = RetrieveConsumerRequest(context, email)

val endpoint = configuration?.endpoint
val isWpfEnabled = configuration?.wpfEnabled
val isTokenEnabled = configuration?.tokenEnabled
val action = configuration?.action

configuration?.wpfEnabled = false
configuration?.tokenEnabled = false
configuration?.action = ""

when (configuration?.endpoint) {
Endpoints.EMERCHANTPAY -> {
configuration?.endpoint = Endpoints.RETRIEVE_CONSUMER_EMERCHANTPAY
}
Endpoints.ECOMPROCESSING -> {
configuration?.endpoint = Endpoints.RETRIEVE_CONSUMER_ECOMPROCESSING
}
else -> {}
}
configuration?.wpfEnabled = false
configuration?.tokenEnabled = false
configuration?.action = ""
response = http!!.execute(configuration?.baseUrl, retrieveConsumerRequest).get()

response = httpClient.execute(configuration?.baseUrl, retrieveConsumerRequest).get()
val result = this.transaction?.request

configuration?.endpoint = endpoint!!
configuration?.wpfEnabled = isWpfEnabled
configuration?.tokenEnabled = isTokenEnabled
configuration?.action = action

return result?.transaction?.consumerId
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.emerchantpay.gateway.genesisandroid.api.ui

import android.app.Activity
import android.content.Intent
import android.os.Message
import android.view.View
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.widget.ProgressBar
import com.emerchantpay.gateway.genesisandroid.api.constants.IntentExtras

import com.emerchantpay.gateway.genesisandroid.api.constants.URLConstants
import com.emerchantpay.gateway.genesisandroid.api.util.WebViewUtil

open class GenesisWebChromeClient(// WebView Activity
private val webViewActivity: GenesisWebViewActivity, // Progress Bar
Expand All @@ -27,23 +25,8 @@ open class GenesisWebChromeClient(// WebView Activity

val url = view.url

val returnIntent = Intent()
var resultCode: Int? = null

when {
url?.contains(URLConstants.FAILURE_ENDPOINT) == true -> {
returnIntent.putExtra(IntentExtras.EXTRA_RESULT, "failure")
resultCode = Activity.RESULT_OK
}
url?.contains(URLConstants.CANCEL_ENDPOINT) == true -> {
returnIntent.putExtra("cancel", "cancel")
resultCode = Activity.RESULT_CANCELED
}
url?.contains(URLConstants.SUCCESS_ENDPOINT) == true -> {
returnIntent.putExtra("success", "success")
resultCode = Activity.RESULT_OK
}
}
val result = url?.let { WebViewUtil.getResultIntent(it) }
val resultCode = result?.first

when {
resultCode != null -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.emerchantpay.gateway.genesisandroid.api.ui

import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.net.http.SslError
import android.view.View
Expand All @@ -11,9 +9,8 @@ import android.webkit.WebViewClient
import android.widget.ProgressBar

import com.emerchantpay.gateway.genesisandroid.api.constants.ErrorMessages
import com.emerchantpay.gateway.genesisandroid.api.constants.IntentExtras
import com.emerchantpay.gateway.genesisandroid.api.constants.URLConstants
import com.emerchantpay.gateway.genesisandroid.api.models.GenesisError
import com.emerchantpay.gateway.genesisandroid.api.util.WebViewUtil

open class GenesisWebViewClient(// WebView Activity
private val webViewActivity: GenesisWebViewActivity, // Progress Bar
Expand All @@ -26,27 +23,13 @@ open class GenesisWebViewClient(// WebView Activity
progressBar.visibility = View.VISIBLE

// Destroy webview activity
val returnIntent = Intent()
var resultCode: Int? = null
val result = WebViewUtil.getResultIntent(url)
val resultCode = result.first
val resultIntent = result.second

when {
url.contains(URLConstants.FAILURE_ENDPOINT) -> {
returnIntent.putExtra(IntentExtras.EXTRA_RESULT, "failure")
resultCode = Activity.RESULT_OK
}
url.contains(URLConstants.CANCEL_ENDPOINT) -> {
returnIntent.putExtra("cancel", "cancel")
resultCode = Activity.RESULT_CANCELED
}
url.contains(URLConstants.SUCCESS_ENDPOINT) -> {
returnIntent.putExtra("success", "success")
resultCode = Activity.RESULT_OK
}
}

when {
resultCode != null -> {
resultCode?.let { webViewActivity.setResult(it, returnIntent) }
result.first != null -> {
resultCode?.let { webViewActivity.setResult(it, resultIntent) }
stopLoading()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.emerchantpay.gateway.genesisandroid.api.util

import android.app.Activity
import android.content.Intent
import com.emerchantpay.gateway.genesisandroid.api.constants.IntentExtras
import com.emerchantpay.gateway.genesisandroid.api.constants.URLConstants

class WebViewUtil {

companion object {
fun getResultIntent(url: String): Pair<Int?, Intent?> {
val returnIntent = Intent()

when {
url.contains(URLConstants.FAILURE_ENDPOINT, ignoreCase = true) -> {
returnIntent.putExtra(IntentExtras.EXTRA_RESULT, "failure")
return Pair(Activity.RESULT_OK, returnIntent)
}

url.contains(URLConstants.CANCEL_ENDPOINT, ignoreCase = true) -> {
returnIntent.putExtra("cancel", "cancel")
return Pair(Activity.RESULT_CANCELED, returnIntent)
}

url.contains(URLConstants.SUCCESS_ENDPOINT, ignoreCase = true) -> {
returnIntent.putExtra("success", "success")
return Pair(Activity.RESULT_OK, returnIntent)
}
}
return Pair(null, null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConfigurationUnitTest {
internal var language = Locales.EN

internal var environment = Environments("staging.gate")
internal var endpoint = Endpoints("emerchantpay.net")
internal var endpoint = Endpoints.EMERCHANTPAY

internal var configuration = Configuration(username, password, environment, endpoint, language)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- JDK >= 1.8
- Gradle >= 4.1
- Android >= 4.4
- Android >= 5.0 Lollipop
- Android Studio >= 3.0

Installation and Setup
Expand All @@ -31,7 +31,7 @@ cd GenesisAndroid
* Add the dependency in your build.gradle:
```
dependencies {
implementation 'com.emerchantpay.gateway:genesis-android:1.3.93'
implementation 'com.emerchantpay.gateway:genesis-android:1.3.94'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
kotlin_version = '1.7.20'
gradle_plugin_version = '7.0.4'
gradle_plugin_version = '7.4.2'
android_material_version = '1.6.1'
junit_version = '4.13.2'
junit5_version = '5.9.1'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 30 14:27:15 EET 2020
#Mon Apr 15 10:40:33 EEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

0 comments on commit ede1cc4

Please sign in to comment.