【问题标题】: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


    【解决方案1】:

    您可以使用 Recurly.js 功能来执行此操作。当您拨打订阅电话时,只需使用现有的 account_code,以便在注册过程中生成的订阅和计费信息将与现有帐户相关联。查看https://github.com/recurly/recurly-js-examples的代码示例

    【讨论】:

      【解决方案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调整它

      【讨论】:

        猜你喜欢
        • 2019-09-09
        • 2012-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-17
        • 1970-01-01
        • 1970-01-01
        • 2023-03-08
        相关资源
        最近更新 更多