-
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.
Added Result passing mech to tell app about the payment result. (#26)
- Loading branch information
Showing
25 changed files
with
441 additions
and
38 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
android/src/main/java/com/komoju/android/sdk/ExperimentalStdlibApi.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,22 @@ | ||
package com.komoju.android.sdk | ||
|
||
/** | ||
* This annotation means that this option is experimental and subject to change in Future. | ||
* Please test your behaviour overall once you update the komoju SDK Version | ||
*/ | ||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING) | ||
@Retention(AnnotationRetention.BINARY) | ||
@Target( | ||
AnnotationTarget.CLASS, | ||
AnnotationTarget.ANNOTATION_CLASS, | ||
AnnotationTarget.PROPERTY, | ||
AnnotationTarget.FIELD, | ||
AnnotationTarget.LOCAL_VARIABLE, | ||
AnnotationTarget.VALUE_PARAMETER, | ||
AnnotationTarget.CONSTRUCTOR, | ||
AnnotationTarget.FUNCTION, | ||
AnnotationTarget.PROPERTY_GETTER, | ||
AnnotationTarget.PROPERTY_SETTER, | ||
AnnotationTarget.TYPEALIAS, | ||
) | ||
annotation class ExperimentalKomojuPaymentApi |
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
19 changes: 19 additions & 0 deletions
19
android/src/main/java/com/komoju/android/sdk/navigation/PaymentResultScreenModel.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,19 @@ | ||
package com.komoju.android.sdk.navigation | ||
|
||
import androidx.compose.runtime.Composable | ||
import cafe.adriel.voyager.core.model.ScreenModel | ||
import cafe.adriel.voyager.core.model.rememberNavigatorScreenModel | ||
import cafe.adriel.voyager.navigator.Navigator | ||
import com.komoju.android.sdk.KomojuSDK | ||
|
||
internal class PaymentResultScreenModel : ScreenModel { | ||
var result: KomojuSDK.PaymentResult? = null | ||
private set | ||
|
||
fun setResult(result: KomojuSDK.PaymentResult) { | ||
this.result = result | ||
} | ||
} | ||
|
||
@Composable | ||
internal fun Navigator.paymentResultScreenModel() = rememberNavigatorScreenModel(PaymentResultScreenModel::class.simpleName) { PaymentResultScreenModel() } |
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
35 changes: 35 additions & 0 deletions
35
android/src/main/java/com/komoju/android/sdk/ui/screens/failed/Reason.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,35 @@ | ||
package com.komoju.android.sdk.ui.screens.failed | ||
|
||
/** | ||
* Enum class representing the reasons for a payment failure. | ||
* | ||
* This enum provides various constants that describe common reasons why a payment may fail. | ||
* These reasons can be used to handle different error cases in the application and provide | ||
* appropriate feedback to the user. | ||
*/ | ||
enum class Reason { | ||
|
||
/** | ||
* Payment was canceled by the user. | ||
* | ||
* This reason indicates that the user deliberately canceled the payment process. | ||
* It typically happens when the user decides not to complete the transaction. | ||
*/ | ||
USER_CANCEL, | ||
|
||
/** | ||
* Payment failed due to a credit card error. | ||
* | ||
* This reason indicates that there was an issue with the user's credit card, such as | ||
* an invalid card number, insufficient funds, or the card being declined by the issuer. | ||
*/ | ||
CREDIT_CARD_ERROR, | ||
|
||
/** | ||
* Payment failed due to another unspecified reason. | ||
* | ||
* This reason is used when the cause of the failure does not fit into any of the other | ||
* predefined categories. | ||
*/ | ||
OTHER, | ||
} |
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
13 changes: 13 additions & 0 deletions
13
android/src/main/java/com/komoju/android/sdk/ui/screens/success/PaymentSuccessScreenModel.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,13 @@ | ||
package com.komoju.android.sdk.ui.screens.success | ||
|
||
import com.komoju.android.sdk.navigation.RouterStateScreenModel | ||
|
||
internal class PaymentSuccessScreenModel : RouterStateScreenModel<Unit>(Unit) { | ||
fun onCloseButtonClicked() { | ||
mutableRouter.pop() | ||
} | ||
|
||
fun onBackToStoreButtonClicked() { | ||
mutableRouter.pop() | ||
} | ||
} |
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
Oops, something went wrong.