Ich habe mit ein paar Fehlern zu tun bekommen und in letzter Zeit irgendwie machte ich es passiert, aber es gibt eine Sache, die ich Metadaten zu meinem Code hinzufügen muss, weiß aber nicht wo und wie ich Ihre Hilfe brauche.Bezahlte Mitgliedschaft Stripe Ruby
Bezahltes Mitglied wird registriert, aber es wird keine Gebühr erhoben, da es ohne Plan registriert wird.
Ich denke, das ist das, was ich :metadata[plan_id]=2
hinzufügen müssen:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
belongs_to :plan
has_one :profile
attr_accessor :stripe_card_token
def save_with_payment
if valid?
require "stripe"
Stripe.api_key = "********"
customer = Stripe::Customer.create(
:description => email,
:source => stripe_card_token # obtained with Stripe.js
)
self.stripe_customer_token = customer.id
save!
end
end
end
/* global $*/
/* global Stripe*/
/* global Token*/
$(document).ready(function() {
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'));
// Watch for a form submission:
$("#form-submit-btn").click(function(event) {
event.preventDefault();
$('input[type=submit]').prop('disabled', true);
var error = false;
var ccNum = $('#card_number').val(),
cvcNum = $('#card_code').val(),
expMonth = $('#card_month').val(),
expYear = $('#card_year').val();
if (!error) {
// Get the Stripe token:
Stripe::Token.create({
number: ccNum,
cvc: cvcNum,
exp_month: expMonth,
exp_year: expYear,
}, stripeResponseHandler);
}
return false;
}); // form submission
function stripeResponseHandler(status, response) {
// Get a reference to the form:
var f = $("#new_user");
// Get the token from the response:
var token = response.id;
// Add the token to the form:
f.append('<input type="hidden" name="user[stripe_card_token]" value="' + token + '" />');
// Submit the form:
f.get(0).submit();
}
});
auf diese Weise seines mir einen Fehler „Dieser Kunde hat keine anhängenden Zahlungsquelle“ –
Im macht zwei Arten von Kunden-Basic (kostenlos) und Pro (Paid) geben, so habe ich versucht, das Hinzufügen „: Metadaten => [ 'plan_id ': 2] "wird immer noch nicht geladen –
Bereits behoben des-> email thnx –