Skip to content

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
plpt88 committed Feb 7, 2023
1 parent fcc5c92 commit 0d40582
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 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.1'
PUBLISH_VERSION = '1.3.2'
PUBLISH_ARTIFACT_ID = 'genesis-android'
PUBLISH_DESCRIPTION = 'Genesis Android SDK'
PUBLISH_URL = 'https://github.com/GenesisGateway/android_sdk'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ open class PaymentRequest : Request, PaymentAttributes, CustomerInfoAttributes,
// Shipping Payment Address
setShippingFirstname(shippingAddress.firstName)
setShippingLastname(shippingAddress.lastname)
setShippingPrimaryAddress(shippingAddress.address1)
setShippingSecondaryAddress(shippingAddress.address2)
setShippingZipCode(shippingAddress.zipCode)
setShippingCity(shippingAddress.city)
shippingAddress.address1?.let { setShippingPrimaryAddress(it) }
shippingAddress.address2?.let { setShippingSecondaryAddress(it) }
shippingAddress.zipCode?.let { setShippingZipCode(it) }
shippingAddress.city?.let { setShippingCity(it) }
setShippingState(shippingAddress.state)
setShippingCountry(shippingAddress.countryName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class RequiredParameters {

fun getRequiredParametersForAddress(address: PaymentAddress): HashMap<String, String>? {
requiredParamsMap[firstName] = address.firstName
requiredParamsMap[address1] = address.address1
requiredParamsMap[zipCode] = address.zipCode
requiredParamsMap[country] = address.countryCode
requiredParamsMap[state] = address.state

Expand All @@ -91,13 +89,11 @@ class RequiredParameters {
requiredParamsMap[returnCancelUrl] = paymentRequest.returnCancelUrl
requiredParamsMap[customerEmail] = paymentRequest.customerEmail
when {
paymentRequest.customerEmail != null
&& !paymentRequest.customerEmail.isEmpty()
&& (paymentRequest.consumerId == null || paymentRequest.consumerId!!.isEmpty()) ->
!paymentRequest.customerEmail.isNullOrBlank()
&& paymentRequest.consumerId?.isEmpty() == true ->
requiredParamsMap[consumerId] = paymentRequest.consumerId as String
}
requiredParamsMap[notificationUrl] = paymentRequest.notificationUrl as String
requiredParamsMap[customerPhone] = paymentRequest.customerPhone
requiredParamsMap[notificationUrl] = paymentRequest.notificationUrl
requiredParamsMap[billingAddress] = paymentRequest.getBillingAddress().toXML()

return requiredParamsMap
Expand All @@ -114,7 +110,6 @@ class RequiredParameters {
const val returnCancelUrl = "return_cancel_url"
const val customerEmail = "customer_email"
const val consumerId = "consumer_id"
const val customerPhone = "customer_phone"
const val billingAddress = "billing_address"
const val shippingAddress = "shipping_address"
const val notificationUrl = "notification_url"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.emerchantpay.gateway.genesisandroid.api.models

class PaymentAddress(val firstName: String, val lastname: String, val address1: String, val address2: String,
val zipCode: String, val city: String, val state: String, private val country: Country) {
class PaymentAddress(val firstName: String, val lastname: String, val address1: String? = "", val address2: String? = "",
val zipCode: String? = "", val city: String? = "", val state: String, private val country: Country) {

val countryName: String
get() = country.countryName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ class PaymentRequestUnitTest {
assertEquals(paymentRequest!!.paymentAddress?.countryName, address!!.countryName)
}

@Test
@Throws(IllegalAccessException::class)
fun testLoadAddressWithEmptyValues() {
// Generate unique Id
val uniqueId = UUID.randomUUID().toString()

// Address
address = PaymentAddress("John", "Doe", "",
"", "", "",
"Berlin state", Country.Germany)

paymentRequest = PaymentRequest(context!!, uniqueId,
BigDecimal("2.00"), Currency.USD,
"[email protected]", "+55555555", address!!,
"https://example.com", transactionTypes!!)

assertTrue(paymentRequest!!.paymentAddress?.address1?.isEmpty() == true)
assertTrue(paymentRequest!!.paymentAddress?.address2?.isEmpty() == true)
assertFalse(paymentRequest!!.paymentAddress?.firstName?.isEmpty() == true)
assertFalse(paymentRequest!!.paymentAddress?.lastname?.isEmpty() == true)
assertFalse(paymentRequest!!.paymentAddress?.countryCode?.isEmpty() == true)
}

@Test
@Throws(IllegalAccessException::class)
fun testLoadTransactionTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class RequiredParametersValidatorUnitTest {
fun testWithMissingAddressParams() {
// Address
billingAddress = PaymentAddress("John", "Doe",
"", "", "10000", "New York",
"state", Country().getCountry("United States")!!)
"", "", "", "",
"", Country().getCountry("United States")!!)

requiredParamsMap = requiredParameters.getRequiredParametersForAddress(billingAddress!!)

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.1'
implementation 'com.emerchantpay.gateway:genesis-android:1.3.2'
}
```

Expand Down

0 comments on commit 0d40582

Please sign in to comment.