【问题标题】:Recurly: How i can Update the Recurly subscription & Billing Token in one requestRecurly:如何在一个请求中更新 Recurly 订阅和计费令牌
【发布时间】:2015-11-06 07:37:51
【问题描述】:
在其他一些计划中,我有一个免费计划。当用户使用免费计划注册时,我在 RECURLY 中创建了没有订阅和账单信息的帐户。当用户尝试升级到某些付费计划时。我创建一个订阅。但是通过订阅,我还需要在 1 个请求中设置 Billing 帐户令牌,我如何使用 Ruby on rails 在 Recurly 中做到这一点。
if account.present && subscription.blank?
recurly_result =subscription.update_attributes(subscription attributes & Account billing token)
end
【问题讨论】:
标签:
ruby-on-rails
ruby
ruby-on-rails-4
stripe-payments
recurly
【解决方案2】:
试试这个
// 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调整它