Skip to content

Commit

Permalink
PIMOB:3162 - Add token_format for Googlepay token
Browse files Browse the repository at this point in the history
  • Loading branch information
chintan-soni-cko committed Jan 14, 2025
1 parent bf539fd commit 4e8f7b0
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void createPayment(String token, Callback callback) {
RequestBody requestBody = buildPaymentRequestBody(token);
Request paymentRequest = new Request.Builder()
.url("https://api.sandbox.checkout.com/payments")
.addHeader("Authorization", Constants.SECRET_KEY)
.addHeader("Authorization", "Bearer "+Constants.SECRET_KEY)
.post(requestBody)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ internal class CardTokenizationNetworkDataMapper : TokenizationNetworkDataMapper
PhoneEntityToPhoneDataMapper().map(from = it to result.billingAddress?.country)
},
name = result.name,
tokenFormat = result.tokenFormat,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ public data class TokenDetails(

val phone: Phone? = null,

val tokenFormat: String? = null,

val name: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ internal data class TokenDetailsResponse(
@Json(name = "phone")
val phone: PhoneEntity? = null,

@Json(name = "token_format")
val tokenFormat: String?,

@Json(name = "name")
val name: String?,
)
119 changes: 0 additions & 119 deletions checkout/src/test/java/com/checkout/mock/CardTokenTestData.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ internal object TokenizationRequestTestData {
billingAddress = null,
phone = null,
name = "Bruce Wayne",
tokenFormat = "Test token format",
)

val invalidAddress = Address(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ internal class CardTokenizationNetworkDataMapperTest {
from = TokenizationRequestTestData.phoneEntity to TokenizationRequestTestData.addressEntity.country,
),
name = "Bruce Wayne",
tokenFormat = "Test token format",
)

private fun setupMockResponses(
Expand All @@ -115,6 +116,7 @@ internal class CardTokenizationNetworkDataMapperTest {
every { mockGetTokenDetailsResponse.cardCategory } returns tokenDetails.cardCategory
every { mockGetTokenDetailsResponse.issuer } returns tokenDetails.issuer
every { mockGetTokenDetailsResponse.issuerCountry } returns tokenDetails.issuerCountry
every { mockGetTokenDetailsResponse.tokenFormat } returns tokenDetails.tokenFormat
every { mockGetTokenDetailsResponse.productId } returns tokenDetails.productId
every { mockGetTokenDetailsResponse.productType } returns tokenDetails.productType
every { mockGetTokenDetailsResponse.billingAddress } returns tokenDetails.billingAddress?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,21 @@ fun invokeCheckoutSDKToGenerateTokenForGooglePay(context: Context) {
)

/**
* Invoke createToken method from checkoutApiClient
* Pass tokenJsonPayload as parameter. The JSON string generated by GooglePay into [GooglePayTokenRequest]
* Invoke createToken method from checkoutApiClient Pass tokenJsonPayload as parameter. The JSON string generated by
* GooglePay into [GooglePayTokenRequest]
*/
checkoutApiClient.createToken(
GooglePayTokenRequest(
"{" + "\t\"protocolVersion\": \"ECv1\",\n" + "\t\"signature\":" +
"\"MEYCIQDRBIlMOzMjCEduZ6ENicfHlVx8679owbXV0lWbJ7pKDAIhAMEKPvzx8AlW6zxFNePoQMHCXjsHe" +
"PAhxnZwPkVywI2I\"," +
"\t\"signedMessage\": \"{\\\"encryptedMessage\\\":" +
"\\\"/rICAjT7ge2qvw0BU86Kt/v/5nLMiMdDhx6EXRRpKPvZGfZThR7FADqfrPvVJ0eStDTwD1v" +
"Xq+l+sXhBrQ+EdpHSv2oow3nQZeYwNU+nofKxfqSIDJBPgTMemphcBFkRsCdyDtOTI6AtVM7mxFm/QOiMzX0MdRNBrpLJp9" +
"cfQcxVX7O3z5IjG0t50dy4XtJPrdAd7N+0XG/KbrY466iNFPQuRYET65H4jXLGFK0RN+EQYe4gVAib91Y9KFenCh0x94V" +
"hoq4ayd6PCOL7Apj4G+yceDOoL5OAseGYk2JGwlW1DVLOj0YLUVBsWh86n0mRCARcgI5IuV6acHVL9XzEJQY/Z98oVSyVTo/" +
"PbeQKeaWR/qjcI9bdbpa9XIrYBCiKXrIau/mU2zg/Bq+OMrVJhRuFWFK9HMgxol0U+zNUVA9tOY4/QcHAEmfJgA2bhPCQQz" +
"qHYTn6g5Mv4vqCeV+k0MMcauinrDeJDgrFWKc2+Hu26uImWVk4\\\",\\\"ephemeralPublicKey\\\":\\\"BPPQFAG" +
"zdzp/TeDiBNABnju6FsL0lTNqKZTpUhzcyeWaK8XV19gtf1zhVAiZjOrLVGj3txoge9fW+x8bBghnFQc\\\\u003d\\\"," +
"\\\"tag\\\":\\\"Ewh1yD3bR5wqTRlEV6TPQpvWaUSBFTMsCAILpGejmtI\\\\u003d\\\"}\"\n" +
"}",
"{\"signature\":\"MEUCIBBkOdSeFLTyhtwGeBjyjUOGfY9w46ulDL/xIcQVsGPMAiEA+kcc7+" +
"yGgkpWRcT7QtDdvsi//BVGhboYagUyHlp+7eE\\u003d\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"" +
"{\\\"encryptedMessage\\\":\\\"Es/MqYVGHX/VltWkU8bdDE/xKCYMfyeBHmCuJojEzZC9JWM57BwoYf0H+9wb0ePmLuRZa5" +
"ZP+b2svI7Oy0WJjFgndIdsB2p0bxwE0JtrjYamHP51Aj8oPakxRsUN4YSfDukRPq2mWRNONJjN8o/6jvAW/710o9+JZ0PdHYnW/" +
"a8WR98Joh0AOMDTlyLOOHFsH5FkwoUCJlv4vcWxIE6ZQc4W/bQ/OGZ9B05kbFlOlLjmB4nDReqTvh1Vnv+v9B+C/OZg084OiC" +
"aAdjLZJeqqaZteVM3CSIIRly/1AMs+uCtPlBligTONqNXfhqce1LwY98y3H4l+Ef1eM4EmUjkCkvSN+sEaEn3btFOrBX7MQ/UU" +
"PGN8EgPmQBpRs3opqVwNFHwgsT+3eeags1NLGA7jSaI5ODXH8zl6KSIJsSFglhG2IT6axC8g6t0WsjxdQjMnqERYPQlQ4K" +
"ka\\\",\\\"ephemeralPublicKey\\\":\\\"BGRaMmC+vqUGkEy9wvPwp2Kp31bHJWjgtWJxa2v9Uwc2a6nOQcVthjcpcSsS" +
"h8C7dARuC6FalhHFXSss4G9uJus\\\\u003d\\\",\\\"tag\\\":\\\"aNjQvDRbEBHk65J6TkXx0BrsHGCLmK3sTLDh/zuGu" +
"gE\\\\u003d\\\"}\"}",
onSuccess = {
showAlertDialog(context, context.getString(R.string.token_generated), it.token)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,25 @@ internal class CardTokenizationUseCaseTest {
)
val capturedCardTokenRequest = slot<CardTokenRequest>()
val expectedTokenDetails = TokenDetails(
"type", "token_token", "02/23", 2, 23,
null, "", "", "", null, null, null, null,
null, null, null, null, null,
type = "type",
token = "token_token",
expiresOn = "02/23",
expiryMonth = 2,
expiryYear = 23,
scheme = null,
schemeLocal = "",
last4 = "",
bin = "",
cardType = null,
cardCategory = null,
issuer = null,
issuerCountry = null,
productId = null,
productType = null,
billingAddress = null,
phone = null,
tokenFormat = null,
name = null,
)
merchantResultTokenDetails = null
merchantResultErrorMessage = null
Expand Down

0 comments on commit 4e8f7b0

Please sign in to comment.