-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
957b5c6
commit 204a50b
Showing
15 changed files
with
286 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
local.properties | ||
.idea/ | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
.../com/emerchantpay/gateway/genesisandroid/api/interfaces/financial/DescriptorAttributes.kt
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...erchantpay/gateway/genesisandroid/api/interfaces/financial/DynamicDescriptorAttributes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.emerchantpay.gateway.genesisandroid.api.interfaces.financial | ||
|
||
import com.emerchantpay.gateway.genesisandroid.api.util.RequestBuilder | ||
|
||
interface DynamicDescriptorAttributes { | ||
fun setMerchantName(merchantName: String): DynamicDescriptorAttributes { | ||
requestBuilder.addElement("merchant_name", merchantName.take(MERCHANT_NAME_LENGTH)) | ||
return this | ||
} | ||
|
||
fun setMerchantCity(merchantCity: String): DynamicDescriptorAttributes { | ||
requestBuilder.addElement("merchant_city", merchantCity.take(MERCHANT_CITY_LENGTH)) | ||
return this | ||
} | ||
|
||
fun setSubMerchantId(subMerchantId: String): DynamicDescriptorAttributes { | ||
requestBuilder.addElement("sub_merchant_id", subMerchantId.take(SUB_MERCHANT_ID_LENGTH)) | ||
return this | ||
} | ||
|
||
fun buildDescriptorParams(): RequestBuilder { | ||
return requestBuilder | ||
} | ||
|
||
companion object { | ||
private val requestBuilder = RequestBuilder("") | ||
|
||
private const val MERCHANT_NAME_LENGTH = 25 | ||
private const val MERCHANT_CITY_LENGTH = 13 | ||
private const val SUB_MERCHANT_ID_LENGTH = 15 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...chantpay/gateway/genesisandroid/api/interfaces/financial/googlepay/GooglePayAttributes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.emerchantpay.gateway.genesisandroid.api.interfaces.financial.googlepay | ||
|
||
import com.emerchantpay.gateway.genesisandroid.api.interfaces.financial.googlepay.definitions.GooglePayPaymentSubtype | ||
import com.emerchantpay.gateway.genesisandroid.api.util.RequestBuilder | ||
|
||
interface GooglePayAttributes { | ||
fun setPaymentSubtype(paymentSubtype: GooglePayPaymentSubtype): GooglePayAttributes = apply { | ||
requestBuilder.addElement(PAYMENT_SUBTYPE, paymentSubtype.toString()) | ||
} | ||
|
||
fun buildGooglePayParams(): RequestBuilder { | ||
return requestBuilder | ||
} | ||
|
||
companion object { | ||
private val requestBuilder = RequestBuilder("") | ||
|
||
const val PAYMENT_SUBTYPE = "payment_subtype" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../genesisandroid/api/interfaces/financial/googlepay/definitions/GooglePayPaymentSubtype.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.emerchantpay.gateway.genesisandroid.api.interfaces.financial.googlepay.definitions | ||
|
||
enum class GooglePayPaymentSubtype(private val value: String) { | ||
AUTHORIZE("authorize"), | ||
SALE("sale"), | ||
INIT_RECURRING_SALE("init_recurring_sale"); | ||
|
||
override fun toString(): String { | ||
return value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...roid/src/test/java/com/emerchantpay/gateway/genesisandroid/GooglePayAttributesUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.emerchantpay.gateway.genesisandroid | ||
|
||
import com.emerchantpay.gateway.genesisandroid.api.interfaces.financial.googlepay.GooglePayAttributes | ||
import com.emerchantpay.gateway.genesisandroid.api.interfaces.financial.googlepay.definitions.GooglePayPaymentSubtype.* | ||
import junit.framework.TestCase.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.DisplayName | ||
|
||
internal class GooglePayAttributesUnitTest : GooglePayAttributes { | ||
@Test | ||
@DisplayName("Given attributes with assigned values, When serialized to XML, Then should be valid") | ||
fun testValidXmlIsGeneratedOnSerialization() { | ||
setPaymentSubtype(AUTHORIZE) | ||
|
||
val generatedXml = buildGooglePayParams().toXML() | ||
|
||
assertEquals(EXPECTED_XML, generatedXml) | ||
} | ||
|
||
companion object { | ||
private val EXPECTED_XML = | ||
"<payment_subtype>authorize</payment_subtype>" | ||
} | ||
} |
Oops, something went wrong.