-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from xendit/finalizing
Ready for Android release
- Loading branch information
Showing
17 changed files
with
150 additions
and
119 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
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
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,37 @@ | ||
# Keep CardSession related classes | ||
-keep class com.cards.session.cards.models.** { *; } | ||
-keep class com.cards.session.cards.network.** { *; } | ||
-keep class com.cards.session.cards.sdk.** { *; } | ||
-keep class com.cards.session.cards.ui.** { *; } | ||
|
||
# Keep Kotlin serialization | ||
-keepattributes *Annotation*, InnerClasses | ||
-dontnote kotlinx.serialization.AnnotationsKt | ||
|
||
-keepclassmembers class kotlinx.serialization.json.** { | ||
*** Companion; | ||
} | ||
-keepclasseswithmembers class kotlinx.serialization.json.** { | ||
kotlinx.serialization.KSerializer serializer(...); | ||
} | ||
|
||
# Keep `Companion` object fields of serializable classes. | ||
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects. | ||
-if @kotlinx.serialization.Serializable class ** | ||
-keepclassmembers class <1> { | ||
static <1>$Companion Companion; | ||
} | ||
|
||
# Keep MethodHandles Lookup | ||
-keepclasseswithmembers class java.lang.invoke.MethodHandles$Lookup { | ||
*; | ||
} | ||
|
||
# Keep toString() methods | ||
-keepclassmembers class * { | ||
java.lang.String toString(); | ||
} | ||
|
||
## don't warn on non-existent classes | ||
-dontwarn java.lang.invoke.StringConcatFactory | ||
|
8 changes: 8 additions & 0 deletions
8
cardsSdk/src/androidMain/kotlin/com/cards/session/cards/network/NetworkConstants.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,8 @@ | ||
package com.cards.session.cards.network | ||
|
||
import com.cards.session.BuildConfig | ||
|
||
actual object NetworkConstants { | ||
actual val BASE_URL: String | ||
get() = BuildConfig.BASE_URL | ||
} |
60 changes: 6 additions & 54 deletions
60
cardsSdk/src/androidMain/kotlin/com/cards/session/cards/sdk/CardSessions.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 |
---|---|---|
@@ -1,59 +1,11 @@ | ||
package com.cards.session.cards.sdk | ||
|
||
import android.content.Context | ||
import com.cards.session.cards.models.CardsResponseDto | ||
import com.cards.session.cards.ui.CardSessionState | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
/** | ||
* Core interface for card data collection functionality. | ||
* This interface provides methods to collect card data and CVN in a platform-independent way. | ||
*/ | ||
interface CardSessions { | ||
/** | ||
* Current state of the card session including loading, response and error states | ||
*/ | ||
val state: StateFlow<CardSessionState> | ||
actual fun CardSessions.Factory.create(apiKey: String): CardSessions { | ||
throw IllegalStateException("On Android, use create(context, apiKey)") | ||
} | ||
|
||
/** | ||
* Collects card data from the user. | ||
* @param cardNumber Card number | ||
* @param expiryMonth Card expiry month (2 digits) | ||
* @param expiryYear Card expiry year (4 digits) | ||
* @param cvn Card verification number (optional) | ||
* @param cardholderFirstName Cardholder's first name | ||
* @param cardholderLastName Cardholder's last name | ||
* @param cardholderEmail Cardholder's email | ||
* @param cardholderPhoneNumber Cardholder's phone number | ||
* @param paymentSessionId Payment session ID from the backend | ||
* @return CardsResponseDto representing the current state of card data collection | ||
*/ | ||
suspend fun collectCardData( | ||
cardNumber: String, | ||
expiryMonth: String, | ||
expiryYear: String, | ||
cvn: String?, | ||
cardholderFirstName: String, | ||
cardholderLastName: String, | ||
cardholderEmail: String, | ||
cardholderPhoneNumber: String, | ||
paymentSessionId: String | ||
): CardsResponseDto | ||
|
||
/** | ||
* Collects CVN (Card Verification Number) from the user. | ||
* @param cvn Card verification number | ||
* @param paymentSessionId Session ID received from the backend | ||
* @return CardsResponseDto representing the current state of CVN collection | ||
*/ | ||
suspend fun collectCvn( | ||
cvn: String, | ||
paymentSessionId: String | ||
): CardsResponseDto | ||
|
||
companion object { | ||
fun create(context: Context, apiKey: String): CardSessions { | ||
return CardSessionsImpl.create(context, apiKey) | ||
} | ||
} | ||
} | ||
fun CardSessions.Factory.create(context: Context, apiKey: String): CardSessions { | ||
return CardSessionsImpl.create(context, apiKey) | ||
} |
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
6 changes: 2 additions & 4 deletions
6
cardsSdk/src/commonMain/kotlin/com/cards/session/cards/network/NetworkConstants.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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package com.cards.session.cards.network | ||
|
||
// TODO split this | ||
object NetworkConstants { | ||
const val PROD_URL = "https://api.xendit.co/v3" | ||
const val STG_URL = "https://api.stg.tidnex.dev/v3" | ||
expect object NetworkConstants { | ||
val BASE_URL: String | ||
} |
30 changes: 30 additions & 0 deletions
30
cardsSdk/src/commonMain/kotlin/com/cards/session/cards/sdk/CardSessions.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,30 @@ | ||
package com.cards.session.cards.sdk | ||
|
||
import com.cards.session.cards.models.CardsResponseDto | ||
import com.cards.session.cards.ui.CardSessionState | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface CardSessions { | ||
val state: StateFlow<CardSessionState> | ||
|
||
suspend fun collectCardData( | ||
cardNumber: String, | ||
expiryMonth: String, | ||
expiryYear: String, | ||
cvn: String?, | ||
cardholderFirstName: String, | ||
cardholderLastName: String, | ||
cardholderEmail: String, | ||
cardholderPhoneNumber: String, | ||
paymentSessionId: String | ||
): CardsResponseDto | ||
|
||
suspend fun collectCvn( | ||
cvn: String, | ||
paymentSessionId: String | ||
): CardsResponseDto | ||
|
||
companion object Factory | ||
} | ||
|
||
expect fun CardSessions.Factory.create(apiKey: String): CardSessions |
14 changes: 14 additions & 0 deletions
14
cardsSdk/src/iosMain/kotlin/com/cards/session/cards/network/NetworkConstants.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,14 @@ | ||
package com.cards.session.cards.network | ||
|
||
import platform.Foundation.NSBundle | ||
|
||
actual object NetworkConstants { | ||
actual val BASE_URL: String | ||
get() = if (isDebugBuild()) "https://api.xendit.co/v3" else "https://api.stg.tidnex.dev/v3" | ||
|
||
// please check this logic | ||
private fun isDebugBuild(): Boolean { | ||
val bundle = NSBundle.mainBundle | ||
return bundle.infoDictionary?.get("Debug") as? Boolean ?: false | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
cardsSdk/src/iosMain/kotlin/com/cards/session/cards/sdk/CardSessions.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,5 @@ | ||
package com.cards.session.cards.sdk | ||
|
||
actual fun CardSessions.Factory.create(apiKey: String): CardSessions { | ||
return CardSessionsImpl.create(apiKey) | ||
} |
7 changes: 7 additions & 0 deletions
7
cardsSdk/src/iosMain/kotlin/com/cards/session/cards/sdk/CardSessionsIos.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,7 @@ | ||
package com.cards.session.cards.sdk | ||
|
||
object CardSessionsIos { | ||
fun create(apiKey: String): CardSessions { | ||
return CardSessionsImpl.create(apiKey) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ struct ContentView: View { | |
cardNumber: "4242424242424242", | ||
expiryMonth: "12/22", | ||
expiryYear: "2026", | ||
cvn: nil, | ||
cardholderFirstName: "First", | ||
cardholderLastName: "Name", | ||
cardholderEmail: "[email protected]", | ||
|
Oops, something went wrong.