最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Pay Invalid token id error with stripe gateway - Stack Overflow

programmeradmin8浏览0评论

I'm integrating Google Pay with Stripe in my webshop. The integration works perfectly in test mode, but when I switch to production, I get Invalid token id from stripe

(Stripe\Exception\InvalidRequestException(code: 0): Invalid token id: tok_xxx at /home/zastita/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php:38)

My javascript code: ( I successfully retrieve the Google Pay token and send it to my backend )

let paymentToken = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);
let transactionInfo = await getGoogleTransactionInfo();

let response = await fetch('/stripe/processGooglePayPayment', {
   method: 'POST',
   headers: {
       'Content-Type': 'application/json',
       'Accept': 'application/json',
   },
   body: JSON.stringify({
        token: paymentToken.id,
        totalPrice: transactionInfo.totalPrice,
        currencyCode: transactionInfo.currencyCode,
   })
});

My backend code:

 Stripe::setApiKey(config('shop.stripe_keys.stripe_secret_key'));

 $googlePayToken = $request->input('token');
 $totalPrice = $request->input('totalPrice');
 $currencyCode = $request->input('currencyCode');

 $paymentMethod = PaymentMethod::create([
    'type' => 'card',
    'card' => [
        'token' => "$googlePayToken", // Invalid token id
    ],
 ]);

I ensure that both of Stripe and Google Pay is in production, Google Pay environment variable is set to PRODUCTION, I pass the merchantID too, and I use the live secret key to initialize Stripe.

I searched for the solution in Stripe and Google Pay documentations, but I can't find anything related to this, anyone who is faced with this error too?

Any help would be appreciate!

发布评论

评论列表(0)

  1. 暂无评论