Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass card info in payment edit #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions mobile/Account/Account.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { Box, Button, Flex, Sans, Separator, Skeleton, Spacer } from "components"
import { useDrawerContext } from "components/Drawer/DrawerContext"
import {
ChevronIcon, LogoutIcon, MembershipInfoIcon, PaymentShippingIcon, PersonalPreferencesIcon,
PrivacyPolicy, QuestionMark, TermsOfService
ChevronIcon,
LogoutIcon,
MembershipInfoIcon,
PaymentShippingIcon,
PersonalPreferencesIcon,
PrivacyPolicy,
QuestionMark,
TermsOfService,
} from "components/Icons"
import { AppleSVG, InstagramSVG } from "components/SVGs"
import gql from "graphql-tag"
Expand Down Expand Up @@ -213,7 +219,6 @@ export const Account = screenTrack()(({ navigation }) => {
return (
<WaitlistedCTA
authorizedAt={!!customer?.authorizedAt ? DateTime.fromISO(customer?.authorizedAt) : null}
authorizationWindowClosesAt={DateTime.fromISO(customer?.admissions?.authorizationWindowClosesAt)}
onPressLearnMore={() =>
tracking.trackEvent({
actionName: Schema.ActionNames.LearnMoreTapped,
Expand Down
29 changes: 18 additions & 11 deletions mobile/Account/PaymentAndShipping/EditPaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useDrawerContext } from "components/Drawer/DrawerContext"
import { PaymentForm } from "components/Payment"
import { PaymentBillingAddress } from "components/Payment/PaymentBillingAddress"
import {
PaymentExpressButtons, PaymentExpressButtonsFragment_PaymentPlan
PaymentExpressButtons,
PaymentExpressButtonsFragment_PaymentPlan,
} from "components/Payment/PaymentExpressButtons"
import { Formik } from "formik"
import React, { useState } from "react"
Expand All @@ -16,8 +17,6 @@ import { CardNumberElement, useElements, useStripe } from "@stripe/react-stripe-

import { EditPaymentMethod_Query } from "./EditPaymentMethod"

const EnableExpressCheckout = process.env.ENABLE_EXPRESS_CHECKOUT == "true"

export const EditPaymentFormFragment_Query = gql`
fragment EditPaymentFormFragment_Query on Query {
me {
Expand All @@ -41,8 +40,8 @@ export const EditPaymentFormFragment_Query = gql`
`

const UpdatePaymentMethod_Mutation = gql`
mutation UpdatePaymentMethod_Mutation($paymentMethodID: String!, $planID: String!, $billing: JSON) {
updatePaymentMethod(paymentMethodID: $paymentMethodID, planID: $planID, billing: $billing)
mutation UpdatePaymentMethod_Mutation($paymentMethodID: String!, $planID: String!, $billing: JSON, $card: JSON) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/seasons/monsoon/blob/master/src/modules/Payment/mutations/payment.mutations.ts#L77-L90 are we missing a PR for monsoon. That mutation doesn't take $card as a param

updatePaymentMethod(paymentMethodID: $paymentMethodID, planID: $planID, billing: $billing, card: $card)
}
`

Expand Down Expand Up @@ -110,16 +109,24 @@ export const EditPaymentForm: React.FC<{ data: any }> = ({ data }) => {
},
}

const response = await updatePaymentMethod({
variables: {
paymentMethodID: paymentMethod.id,
planID,
billing,
const variables = {
paymentMethodID: paymentMethod.id,
planID,
billing,
card: {
last4: paymentMethod.card.last4,
expYear: paymentMethod.card.exp_year,
expMonth: paymentMethod.card.exp_month,
brand: paymentMethod.card.brand,
},
}

const response = await updatePaymentMethod({
variables,
})

const paymentIntent = response.data.updatePaymentMethod
const result = await stripe.handleCardAction(paymentIntent.client_secret)
await stripe.handleCardAction(paymentIntent.client_secret)

await confirmPaymentMethodUpdate({
variables: {
Expand Down
25 changes: 11 additions & 14 deletions mobile/Account/PaymentAndShipping/PaymentAndShipping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export const PaymentAndShipping = screenTrack()(({ navigation }) => {
phoneNumber: customer?.detail?.phoneNumber,
})
}

if (customer) {
const details = customer.detail
if (details?.shippingAddress) {
Expand All @@ -179,20 +178,18 @@ export const PaymentAndShipping = screenTrack()(({ navigation }) => {
})
}

if (customer?.billingInfo) {
billingInfo = customer.billingInfo
sections.push({
title: "Billing address",
value: createBillingAddress(customer.billingInfo),
onClick: () => openDrawer("editPaymentMethod"),
})
billingInfo = customer?.billingInfo
sections.push({
title: "Billing address",
value: billingInfo ? createBillingAddress(billingInfo) : "",
onClick: () => openDrawer("editPaymentMethod"),
})

sections.push({
title: "Payment info",
value: `${customer.billingInfo.brand.toUpperCase()} ${customer.billingInfo.last_digits}`,
onClick: () => openDrawer("editPaymentMethod"),
})
}
sections.push({
title: "Payment info",
value: billingInfo ? `${customer.billingInfo.brand.toUpperCase()} ${customer.billingInfo.last_digits}` : "",
onClick: () => openDrawer("editPaymentMethod"),
})

if (details?.phoneNumber) {
phoneNumber = details?.phoneNumber
Expand Down