我有一个免费的计划和其他的计划。当用户注册免费计划时,我会在RECURLY中创建没有订阅和计费信息的帐户。当用户试图升级到某个付费计划时。我创建了一个订阅。但通过订阅,还需要在1请求中设置计费帐户令牌,如何使用 rails在Recurly中做到这一点。
if account.present && subscription.blank?
recurly_result =subscription.update_attributes(subscription attributes & Account billing token)
end发布于 2015-08-14 13:46:53
您可以使用Recurly.js功能来完成此操作。当您进行订阅调用时,只需使用现有的account_code,以便在注册期间生成的订阅和计费信息将与现有帐户相关联。看看https://github.com/recurly/recurly-js-examples上的代码示例
发布于 2015-08-25 10:36:30
尝尝这个
// Specify the minimum subscription attributes: plan_code, account, and currency
$subscription = new Recurly_Subscription();
$identity_token = "identity token"
$subscription = Recurly_Subscription::get($identity_token);
try{
$accountcode = "account code";
$account = Recurly_Account::get($accountcode);
$account->first_name = $_POST['first-name'];
$account->last_name = $_POST['last-name'];
$account->email = $_POST['email'];
$account->update();
$billing_info = new Recurly_BillingInfo();
$billing_info->account_code = $accountcode;
$billing_info->token_id = $_POST['recurly-token'];
$billing_info->update();
$sub_response = $subscription->updateImmediately();
$uuid = $subscription->uuid;
.........
.........
}catch (Exception $e){
echo $e->getMessage();
}它的PHP代码,您可以根据ROR来调整它。
https://stackoverflow.com/questions/31986483
复制相似问题