-
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.
Add feature to pass through payment credentials w/o saving (APPS-1648) (
#217)
- Loading branch information
Showing
10 changed files
with
168 additions
and
50 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
32 changes: 32 additions & 0 deletions
32
core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsFlow.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 @@ | ||
@file:JvmName("PaymentCredentialsFlow") | ||
|
||
package io.snabble.sdk.payment | ||
|
||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
|
||
internal interface MutableCredentialsFlow { | ||
|
||
fun tryEmitCredentials(credentials: PaymentCredentials): Boolean | ||
} | ||
|
||
/** | ||
* This flow is emitting payment credentials if adding a payment method has been configured to be added without being | ||
* saved. | ||
* | ||
* Payment method being added the regular way, won't be emitted here. | ||
* The [PaymentCredentialsStore.OnPaymentCredentialsAddedListener] is called in that case. | ||
*/ | ||
object PaymentCredentialsFlow : MutableCredentialsFlow { | ||
|
||
private val _credentialsFlow = MutableStateFlow<PaymentCredentials?>(null) | ||
|
||
/** | ||
* Collect this flow to be notified if payment credentials has been created successfully. | ||
* If there are no collectors, it will be discarded. | ||
*/ | ||
val credentialsFlow: SharedFlow<PaymentCredentials?> = _credentialsFlow.asSharedFlow() | ||
|
||
override fun tryEmitCredentials(credentials: PaymentCredentials): Boolean = _credentialsFlow.tryEmit(credentials) | ||
} |
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
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
Oops, something went wrong.