diff --git a/app/src/main/graphql/checkout.graphql b/app/src/main/graphql/checkout.graphql index 58727bb6b4..a57c5022d4 100644 --- a/app/src/main/graphql/checkout.graphql +++ b/app/src/main/graphql/checkout.graphql @@ -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 } } @@ -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 } } diff --git a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt index 552218e4bc..0c7ac17d03 100644 --- a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt +++ b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt @@ -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 @@ -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() @@ -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() { override fun onFailure(e: ApolloException) {