Sha256: e88187f4f2fc9053dd5a354b5bb32192e97b0a94b15f027d5bfa14e450de580f

Contents?: true

Size: 1.3 KB

Versions: 36

Compression:

Stored size: 1.3 KB

Contents

require 'rubygems'
require 'yaml'
require 'authorizenet' 
require 'securerandom'

  include AuthorizeNet::API

  def update_customer_payment_profile(customerProfileId = '35894174', customerPaymentProfileId = '33605803')
    config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")

    transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
    
    request = UpdateCustomerPaymentProfileRequest.new

    payment = PaymentType.new(CreditCardType.new('4111111111111111','2025-05'))
    profile = CustomerPaymentProfileExType.new(nil,nil,payment,nil,nil)

    request.paymentProfile = profile
    request.customerProfileId = customerProfileId
    profile.customerPaymentProfileId = customerPaymentProfileId

    response = transaction.update_customer_payment_profile(request)


    if response.messages.resultCode == MessageTypeEnum::Ok
      puts "Successfully updated customer payment profile with  ID #{request.paymentProfile.customerPaymentProfileId}."
    else
      puts response.messages.messages[0].text
      raise "Failed to update customer with customer payment profile ID #{request.paymentProfile.customerPaymentProfileId}."
    end
    return response
  end
  
if __FILE__ == $0
  update_customer_payment_profile()
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
authorizenetsample-1.2.5 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.2.4 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.2.3 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.2.2 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.2.1 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.2.0 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.9 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.8 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.7 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.5 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.4 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.3 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.2 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.1 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.1.0 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.0.9 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.0.8 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.0.7 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.0.6 lib/CustomerProfiles/update-customer-payment-profile.rb
authorizenetsample-1.0.5 lib/CustomerProfiles/update-customer-payment-profile.rb