2010-04-20 19 views
0

Lorsque je mets à jour les informations d'abonnement existantes en utilisant la méthode update_recurring de la passerelle autorize.net, les détails de paiement (numéro de carte de crédit, numéro CVV et date d'expiration) ne sont pas mis à jour.Mettre à jour les détails de paiement en utilisant Authorize.net

Mon extrait de code est le suivant: -

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 

Répondre

0

Essayez quelque chose comme ceci:

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 => "[email protected]" 
    },    
    :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 
    } 
    })