3

I use stripe/stripe-ph": "^7.2" in my laravel 5.8 app in 2 places with testing keys:

  1. Express payments and that works ok
  2. I started making subscription in other page with similar code and making subscription I got error :

No such payment_method: tok_1FRCLkI5xQuRgDRPpX22Y64B.

Searching in net I found possible reason of this error that invalid keys are used, but checking it I see valid keys and I wonder how 1 page works ok, second fails, but they seems identical :

VALID page with express payment has code:

<div class="row row_content_centered p-3 m-3" style="justify-self: flex-start;">
    <form action="http://local-votes.com/stripe_express_payment_callback" method="GET">
        <script src="https://checkout.stripe.com/checkout.js"
                class="stripe-button active"
                data-key="pk_test_NNNNNNNN"
                data-amount="260"
                data-name="Select &amp; Vote"
                data-description=" selected 2 services"
                data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
                data-locale="auto"
                data-currency="usd"
        >
        </script>
        <button type="submit" class="stripe-button-el" style="visibility: visible;"><span style="display: block; min-height: 30px;">Pay with Card</span>
        </button>
    </form>
    <button type="button" class="btn btn-inverse" onclick="javascript:document.location='http://local-votes.com/home'" style="margin-right:50px;"><span
            class="btn-label"><i class="fa fa-arrows-alt"></i></span> &nbsp;Cancel
    </button>&nbsp;&nbsp;

</div>

Invalid page with subscription has code :

<form action="/subscribe_process" method="post">
    <input type="hidden" name="_token" value="mjnmminrSADnv2Rpl5jTzPzyGl9mcqvMQGBlrLfy">
    <script
            src="https://checkout.stripe.com/checkout.js"
            class="stripe-button"
            data-key="pk_test_NNNNNNNN"
            data-amount="987"
            data-name="Select &amp; Vote"
            data-description="Online course about integrating Stripe"
            data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
            data-locale="auto"
            data-currency="usd">
    </script>

My private key is not tok_1FRCLkI5xQuRgDRPpX22Y64B as in error. Any hints? If there is a way of debugging the errors ?

Thanks!

zlatan
  • 3,346
  • 2
  • 17
  • 35
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
  • 4
    This type of error is usually caused by accidentally using API keys from a different account. Try to check with Postman. This way you can make sure that you're using correct keys. – jones Oct 08 '19 at 11:38
  • 1
    Try to check with Postman. This way you can make sure that you're using correct keys. https://api.stripe.com/v1/tokens/tok_1FRCLkI5xQuRgDRPpX22Y64B. Also pass with headers: Authorization:Bearer sk_test_XXXXXXX Content-Type:application/x-www-form-urlencoded – jones Oct 08 '19 at 11:46
  • 2
    I think you're experiencing this issue https://stackoverflow.com/questions/57501889/trouble-setting-up-a-subscription-with-laravel-5-8-cashier-stripe – Shevy Nov 02 '19 at 19:13

1 Answers1

0

I was using stripe connect and was creating a payment profile on the connect account. Then while retrieving I wasn't passing the stripe account correctly. Once I did, the payment method was retrieved correctly. Here is the code I used. Might help someone

//retrieve account
    $stripe = new \Stripe\StripeClient({platform api key});
    $payment_method = $stripe->paymentMethods->retrieve(
      {payment method id from payment_intent},
      [],
      ['stripe_account' => {stripe connect account id}]
    );