Skip to content

Commit

Permalink
add saving payment method to late pledge flow (#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgriego authored Apr 1, 2024
1 parent 400bba3 commit b4b7f50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/main/graphql/checkout.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ query ValidateCheckout($checkoutId:ID!, $paymentSourceId:String!, $paymentIntent
}
}

mutation CompleteOnSessionCheckout($checkoutId: ID!, $paymentIntentClientSecret: String!, $paymentSourceId: String) {
completeOnSessionCheckout(input:{ checkoutId: $checkoutId, paymentIntentClientSecret: $paymentIntentClientSecret, paymentSourceId: $paymentSourceId } ) {
mutation CompleteOnSessionCheckout($checkoutId: ID!, $paymentIntentClientSecret: String!, $paymentSourceId: String, $paymentSourceReusable: Boolean) {
completeOnSessionCheckout(input:{ checkoutId: $checkoutId, paymentIntentClientSecret: $paymentIntentClientSecret, paymentSourceId: $paymentSourceId, paymentSourceReusable: $paymentSourceReusable } ) {
checkout {
id
backing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ open class MockApolloClientV2 : ApolloClientTypeV2 {
override fun completeOnSessionCheckout(
checkoutId: String,
paymentIntentClientSecret: String,
paymentSourceId: String?
paymentSourceId: String?,
paymentSourceReusable: Boolean
): io.reactivex.Observable<Pair<String, Boolean>> {
return io.reactivex.Observable.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ interface ApolloClientTypeV2 {
fun completeOnSessionCheckout(
checkoutId: String,
paymentIntentClientSecret: String,
paymentSourceId: String?
paymentSourceId: String?,
paymentSourceReusable: Boolean
): Observable<Pair<String, Boolean>>

fun createAttributionEvent(eventInput: CreateAttributionEventData): Observable<Boolean>
Expand Down Expand Up @@ -1565,7 +1566,8 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient
override fun completeOnSessionCheckout(
checkoutId: String,
paymentIntentClientSecret: String,
paymentSourceId: String?
paymentSourceId: String?,
paymentSourceReusable: Boolean
): Observable<Pair<String, Boolean>> {
return Observable.defer {
val ps = PublishSubject.create<Pair<String, Boolean>>()
Expand All @@ -1575,6 +1577,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient
.checkoutId(Base64Utils.encodeUrlSafe(("Checkout-$checkoutId").toByteArray(Charset.defaultCharset())))
.paymentIntentClientSecret(paymentIntentClientSecret)
.paymentSourceId(paymentSourceId)
.paymentSourceReusable(paymentSourceReusable)
.build()
).enqueue(object : ApolloCall.Callback<CompleteOnSessionCheckoutMutation.Data>() {
override fun onFailure(e: ApolloException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ class LatePledgeCheckoutViewModel(val environment: Environment) : ViewModel() {
apolloClient.completeOnSessionCheckout(
checkoutId = checkoutId ?: "",
paymentIntentClientSecret = clientSecret,
paymentSourceId = if (selectedCard == newStoredCard) null else selectedCard.id() ?: ""
paymentSourceId = if (selectedCard == newStoredCard) null else selectedCard.id() ?: "",
paymentSourceReusable = true
).asFlow().map { iDRequiresActionPair ->
if (iDRequiresActionPair.second) {
mutablePaymentRequiresAction.emit(clientSecret)
Expand Down

0 comments on commit b4b7f50

Please sign in to comment.