0

当我使用 autorize.net 网关的 update_recurring 方法更新现有订阅信息时,付款详细信息(信用卡号、CVV 号和到期日)不会被更新。

我的代码片段如下:-

  def create_card_subscription
    credit_card = ActiveMerchant::Billing::CreditCard.new(
      :first_name         => params[:payment_details][:name],
      :last_name          => params[:payment_details][:last_name],
      :number             => params[:payment_details][:credit_card_number],
      :month              => params[:expiry_date_month],
      :year               => params[:expiry_date_year],
      :verification_value => params[:payment_details][:cvv_code]
    )
    if credit_card.valid?
      gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(:login => '*********', :password => '**************')
      response = gateway.update_recurring(
                {
          "subscription.payment.credit_card.card_number" => "4111111111111111",
                 :duration =>{:start_date=>'2010-04-21', :occurrences=>1},
                 :billing_address=>{:first_name=>'xyz', :last_name=>'xyz'},
         :subscription_id=>"******"
                 }
               )
      if response.success?
        puts response.params.inspect
        puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}. The Account number is #{response.params['rbAccountId']}"
      else
        puts response.message
      end
    else
      #Credit Card information is invalid
    end
    render :action=>"card_payment"
  end
4

1 回答 1

0

尝试这样的事情:

credit_card = ActiveMerchant::Billing::CreditCard.new({
  :number => self.ccnum,
  :verification_value => self.ccv,
  :month => self.exp_month,
  :year => self.exp_year,
  :first_name => self.first_name,
  :last_name => self.last_name
})

response = gateway.update_recurring({
    :subscription_id => self.subscription_id,
    :amount => 10000000,
    :credit_card => credit_card,
    :customer => {
      :email => "fjdksl@jklfdsjflkd.com"
    },            
    :billing_address => {
      :first_name => self.first_name,
      :last_name => self.last_name,
      :address1 => self.address + " " + self.address2,
      :city => self.city,
      :state => self.state,
      :country => "US",
      :zip => self.zip
    }
  })
于 2010-11-13T02:14:25.160 回答