Skip to content

Commit

Permalink
1.3.92
Browse files Browse the repository at this point in the history
  • Loading branch information
plpt88 committed Jun 29, 2023
1 parent b52858f commit d08e83d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 48 deletions.
4 changes: 2 additions & 2 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.91'
PUBLISH_VERSION = '1.3.92'
PUBLISH_ARTIFACT_ID = 'genesis-android'
PUBLISH_DESCRIPTION = 'Genesis Android SDK'
PUBLISH_URL = 'https://github.com/GenesisGateway/android_sdk'
Expand All @@ -27,7 +27,7 @@ android {
minSdkVersion 19
targetSdkVersion 33
versionCode 1
versionName "1.3.91"
versionName "1.3.92"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,14 @@ open class GenesisClient : Request {
}

// Retrieve and store consumer id
val sharedPrefs = GenesisSharedPreferences()
val result = this.transaction?.request
var consumerId = result?.transaction?.consumerId
when {
Response(this).isSuccess!!
&& consumerId.isNullOrEmpty()
&& !paymentRequest?.getCustomerEmail().isNullOrEmpty() -> {
consumerId = retrieveConsumerIdFromGenesisGateway(paymentRequest?.getCustomerEmail())
when {
!consumerId.isNullOrEmpty() ->
sharedPrefs.putString(context, SharedPrefConstants.CONSUMER_ID,
KeyStoreUtil(context).encryptData(consumerId))
}
}
sharedPrefs?.getString(context, SharedPrefConstants.CONSUMER_ID).isNullOrEmpty()
&& response?.isSuccess == true
&& consumerId != null
&& consumerId.isNotEmpty() -> sharedPrefs.putString(context, SharedPrefConstants.CONSUMER_ID,
KeyStoreUtil(context).encryptData(result?.transaction?.consumerId))
}
} catch (e: Exception) {
GenesisError(ErrorCodes.SYSTEM_ERROR.code, e.message?: ErrorCodes.getErrorDescription(ErrorCodes.SYSTEM_ERROR.code?: 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,6 @@ open class PaymentRequest : Request, PaymentAttributes, CustomerInfoAttributes,

fun setConsumerId(consumerId: String): PaymentRequest {
this.consumerId = consumerId
try {
context?.let {
sharedPreferences.putString(it, SharedPrefConstants.CONSUMER_ID,
KeyStoreUtil(context!!).encryptData(consumerId))
}
} catch (e: Exception) {

}

return this
}

Expand Down Expand Up @@ -455,8 +446,9 @@ open class PaymentRequest : Request, PaymentAttributes, CustomerInfoAttributes,
paymentRequestBuilder?.addElement("recurring_category", it)
}
}

consumerId = getConsumerId()

if (!isRecurringEnabled(transactionTypesList))
addConsumerId()

when {
transactionTypes.transactionTypesList.contains(WPFTransactionTypes.KLARNA_AUTHORIZE.value) -> orderTaxAmount?.let {
Expand Down Expand Up @@ -517,24 +509,9 @@ open class PaymentRequest : Request, PaymentAttributes, CustomerInfoAttributes,
return rememberCard!!
}

fun getConsumerId(): String? {
try {
when {
consumerId != null && consumerId!!.isNotEmpty() ->
paymentRequestBuilder!!.addElement(SharedPrefConstants.CONSUMER_ID, consumerId!!)
else -> {
consumerId = context?.let {
KeyStoreUtil(it)
.decryptData(sharedPreferences.getString(context!!, SharedPrefConstants.CONSUMER_ID))
}.toString()
consumerId?.let { paymentRequestBuilder!!.addElement(SharedPrefConstants.CONSUMER_ID, it) }
}
}
} catch (e: Exception) {
consumerId = "0"
}

return consumerId
private fun addConsumerId() {
if (consumerId?.isNullOrBlank() == false)
paymentRequestBuilder!!.addElement(SharedPrefConstants.CONSUMER_ID, consumerId!!)
}

fun getKlarnaItemsRequest(paymentRequest: PaymentRequest): KlarnaItemsRequest? {
Expand All @@ -546,11 +523,7 @@ open class PaymentRequest : Request, PaymentAttributes, CustomerInfoAttributes,
}

private fun isRecurringEnabled(transactionTypesList: List<String>): Boolean {
return (transactionTypesList.contains(WPFTransactionTypes.AUTHORIZE.value)
|| transactionTypesList.contains(WPFTransactionTypes.AUTHORIZE3D.value)
|| transactionTypesList.contains(WPFTransactionTypes.SALE.value)
|| transactionTypesList.contains(WPFTransactionTypes.SALE3D.value)
|| transactionTypesList.contains(WPFTransactionTypes.INIT_RECURRING_SALE.value)
return (transactionTypesList.contains(WPFTransactionTypes.INIT_RECURRING_SALE.value)
|| transactionTypesList.contains(WPFTransactionTypes.INIT_RECURRING_SALE3D.value))
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cd GenesisAndroid
* Add the dependency in your build.gradle:
```
dependencies {
implementation 'com.emerchantpay.gateway:genesis-android:1.3.91'
implementation 'com.emerchantpay.gateway:genesis-android:1.3.92'
}
```

Expand Down

0 comments on commit d08e83d

Please sign in to comment.