0
我一直在处理一些错误,一直得到和最近以某种方式我让它发生,但有一件事我需要添加一个元数据到我的代码,但不知道在哪里以及我如何需要你的帮助。付费会员条纹红宝石
付费会员正在注册,但他没有被收费,因为它没有计划注册。
我想这就是我需要添加:metadata[plan_id]=2
:
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();
}
});
这样它给我 “这个客户已经没有附加的支付来源” –
林做两种类型的客户基础(自由)和专业版(付费)的错误,所以我尝试添加“:元=> ['plan_id的数据类型':2]“仍然没有收费 –
已经修复desc->电子邮件thnx –