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

iOS: undefined paymentToken on real device. #380

Open
feraswfares opened this issue Dec 26, 2022 · 0 comments
Open

iOS: undefined paymentToken on real device. #380

feraswfares opened this issue Dec 26, 2022 · 0 comments

Comments

@feraswfares
Copy link

this is my code

card_token always undefined
what should i do to get back the paymentToken


showPaymentSheet = (succeed = true) => {
    const {amount} = this.props;
    const newStr = amount.replace(/,/, '');

    console.log('Here is amount', amount, newStr);

    const paymentRequest = new PaymentRequest(
      [
        {
          supportedMethods: ['apple-pay'],
          data: {
            merchantIdentifier: '****',
            //supportedNetworks: ['visa', 'mastercard', 'mada'],
            supportedNetworks: ['mada'],
            countryCode: 'SA',
            currencyCode: 'SAR',
            // // uncomment this block to activate automatic Stripe tokenization.
            // // try putting your key pk_test... in here and see how the token format changes.
            // paymentMethodTokenizationParameters: {
            // 	parameters: {
            // 		gateway: 'stripe',
            // 		'stripe:publishableKey': Config.STRIPE_KEY,
            // 	},
            // },
          },
        },
      ],
      {
        id: 'basic-example',
        displayItems: [
          {
            label: 'Deposit',
            amount: {currency: 'SAR', value: newStr},
          },
        ],
        total: {
          label: `${strings('global.appName')} ${strings('title.wallet')}`,
          amount: {currency: 'SAR', value: newStr},
        },
      },
    );
    paymentRequest
      .show()
      .then((paymentResponse) => {
        console.log('paymentResponse',  paymentResponse.details)
        const card_token = paymentResponse.details.paymentToken;

        if (succeed) {
          paymentResponse.complete('success');
          this.apiPostApplePay();
          showToast(`Payment request completed with card token ${card_token}`);
        } else {
          paymentResponse.complete('failure');
          showDangerToast('Payment request failed');
        }
      })
      .catch((error) => {
        console.log('error', error);
        if (error.message === 'AbortError') {
          showDangerToast('Payment request was dismissed');
          // this.debug('Payment request was dismissed');
        }
      });
  };
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