Marko I.
Marko I.

Reputation: 562

Not receiving money in Stripe test transactions (Rails)

So I created subscriptions in my Rails app with test API keys from Stripe. The charges I'm creating with dummy cards are going through successfully on my side, but when I'm in Stripe dashboard, the test balance remains the same, as well customer details are not added. I'm not sure what I did wrong.. Do you know why I can't and how can I add those test customer data to Stripe? In the logs, I'm getting 200 OK response, but I'm worried that something isn't going to function in live mode since test balance isn't being updated.

class SubscribersController < ApplicationController

   before_filter :authenticate_user!

    def new
    end

    def update

      token = params[:stripeToken]

      customer = Stripe::Customer.create(
          card: token,
          plan: 1020,
          email: current_user.email
          )
        current_user.subscribed = true
        current_user.stripeid = customer.id
        current_user.save

        redirect_to profiles_user_path
    end


end

and _form.html.erb

<%= form_tag profiles_user_path, method: :get do %>


<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
          data-description="A month's subscription"
          data-amount="8999"></script><span> $89 per month </span>
<% end %>   

Upvotes: 3

Views: 1197

Answers (2)

ofundefined
ofundefined

Reputation: 3330

It took my almost a year to find this out.

I was using tipsi-stripe on my react-native app, only.

I was not aware I needed to send the token to my own backend. And my backend needed to communicate with stripe REST API in order to use that token and create a payment out of that.

https://stripe.com/docs/payments/accept-a-payment-charges

Upvotes: 0

Anthony E
Anthony E

Reputation: 11245

Make sure you're using your Stripe test API keys, and not your live keys. These can be found in the "API keys" section of your account settings from the Stripe dashboard:

enter image description here

So the API keys you're using should include _test_.

For testing, you should also consider using StripeMock, which runs a virtual Stripe server to emulate Stripe: https://github.com/rebelidealist/stripe-ruby-mock.

EDIT

If you're still getting errors, then check your stripe logs and provide a redacted copy here:

enter image description here

Upvotes: 2

Related Questions