Skip to content

Commit

Permalink
[MBL-1283] Add SetupIntentContext to SetupIntent calls (#1984)
Browse files Browse the repository at this point in the history
* add setupintentcontext to setupintent calls

* add payment context for payment intents as well, remove post campaign context for currently running campaigns
  • Loading branch information
mtgriego authored Mar 22, 2024
1 parent f647fa1 commit 1ef623c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/src/main/graphql/checkout.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ query GetBacking($backingId: ID!) {
}
}

mutation CreateSetupIntent($projectId: ID) {
createSetupIntent(input: { projectId: $projectId } ) {
mutation CreateSetupIntent($projectId: ID, $setupIntentContext: StripeIntentContextTypes) {
createSetupIntent(input: { projectId: $projectId, setupIntentContext: $setupIntentContext } ) {
clientSecret
}
}
Expand All @@ -49,8 +49,8 @@ mutation CreateCheckout($projectId: ID!, $amount: String!, $rewardIds: [ID!], $l
}
}

mutation CreatePaymentIntent($projectId: ID!, $amount: String!) {
createPaymentIntent(input: { projectId: $projectId, amount: $amount } ) {
mutation CreatePaymentIntent($projectId: ID!, $amount: String!, $paymentIntentContext: StripeIntentContextTypes) {
createPaymentIntent(input: { projectId: $projectId, amount: $amount, paymentIntentContext: $paymentIntentContext } ) {
clientSecret
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import type.BackingState
import type.CurrencyCode
import type.NonDeprecatedFlaggingKind
import type.PaymentTypes
import type.StripeIntentContextTypes

interface ApolloClientTypeV2 {
fun getProject(project: Project): Observable<Project>
Expand Down Expand Up @@ -232,7 +233,12 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient
return Observable.defer {
val createSetupIntentMut = CreateSetupIntentMutation.builder()
.apply {
if (project != null) this.projectId(encodeRelayId(project))
project?.let {
this.projectId(encodeRelayId(it))
this.setupIntentContext(StripeIntentContextTypes.CROWDFUNDING_CHECKOUT)
} ?: run {
this.setupIntentContext(StripeIntentContextTypes.PROFILE_SETTINGS)
}
}
.build()

Expand Down Expand Up @@ -1493,6 +1499,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient
CreatePaymentIntentMutation.builder()
.projectId(encodeRelayId(createPaymentIntentInput.project))
.amount(createPaymentIntentInput.amount)
.paymentIntentContext(StripeIntentContextTypes.POST_CAMPAIGN_CHECKOUT)
.build()
).enqueue(object : ApolloCall.Callback<CreatePaymentIntentMutation.Data>() {
override fun onFailure(e: ApolloException) {
Expand Down

0 comments on commit 1ef623c

Please sign in to comment.