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

Couldn't update total price #378

Open
etch01 opened this issue Dec 15, 2022 · 0 comments
Open

Couldn't update total price #378

etch01 opened this issue Dec 15, 2022 · 0 comments

Comments

@etch01
Copy link

etch01 commented Dec 15, 2022

I am trying to update total price when user adds promo code or use wallet using state but when Apple Pay shows up, price doesn't change !
here is my code:

applePayPressHandler=()=>{
 const paymentRequest = new PaymentRequest(
   this.METHOD_DATA,
   this.state.applePayDetails,
 );

 paymentRequest.canMakePayments().then((canMakePayment: any) => {
   //1- Check if user can make payment
   if (canMakePayment) {
     paymentRequest.show().then((paymentResponse: any) => {
       const { paymentData } = paymentResponse._details;
       //2-Check if payment succeeded or failed
       if (paymentData == null) {
         paymentResponse.complete('fail');
       } else {
         //API call goes here
         paymentResponse.complete('success');
       }
     });
   }
   else {
     console.log('Cant Make Payment');
   }
 }).catch((error: any) => {
   console.log("Can Make Payments Error", error );
});
}

and here is wallet code:

useWallet = () :void=>{
    if (!this.state.isWalletChecked){
      this.setState({
        totalCreditCardAmount : this.state.totalPrice - this.props.userStore.account.wallet.balance,
        isWalletChecked:!this.state.isWalletChecked
      })
    }else{
      this.setState({
        isWalletChecked:!this.state.isWalletChecked,
        totalCreditCardAmount : this.state.totalPrice
      })
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant