Skip to content

Commit

Permalink
Merge pull request #359 from reactioncommerce/357-fix-machikoyasuda-b…
Browse files Browse the repository at this point in the history
…illing-address

fix(stripepaymentcheckoutaction): check for Stripe Form completion
  • Loading branch information
nnnnat authored Nov 8, 2018
2 parents c83e022 + 27ee2b9 commit 1cc9e16
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class StripePaymentCheckoutAction extends Component {
activeCountry: "US",
status: "active",
billingAddress: "same_as_shipping",
isStripeFormComplete: false,
countries: [
{ value: "US", label: "United States" },
{ value: "DE", label: "Germany" },
Expand Down Expand Up @@ -163,16 +164,26 @@ class StripePaymentCheckoutAction extends Component {
}

handleUseNewBillingAddress = (billingAddress) => {
// Only react to value changes
if (typeof billingAddress === "string") {
const { isStripeFormComplete } = this.state;
if (billingAddress === "use_different_billing_address") {
this.setState({ billingAddress });
} else if (billingAddress === "same_as_shipping") {
// If a user decides to use the same address
this.setState({ billingAddress });
// Confirm if Stripe Form is filled out
if (isStripeFormComplete) {
// Trigger onReadyForSaveChange()
this.handleStripeFormIsComplete(true);
}
}
}

handleStripeFormIsComplete = (isComplete) => {
const { onReadyForSaveChange } = this.props;

onReadyForSaveChange(isComplete);
this.setState({
isStripeFormComplete: true
});
}

renderBillingAddressForm = () => {
Expand Down

0 comments on commit 1cc9e16

Please sign in to comment.