Scenario 9: Ruby

From Intrannuity

Jump to: navigation, search

Download Source File

require "lib/iBilling"
 
	#Set up clients' settings
	config = Map.new
	config.put(SessionConnection::PROCESSOR_HOST, "http://server.ibillingclient.org/ibilling/xmlhttps")
	config.put("debug", true)
	#Login
	session = Session::login(2000, "welcome", config)
	#Find customer account
	customerAccount = session.loadCustomerAccount("rb.ca-2")
	#Create invoice1
	invoice1 = customerAccount.createRevenueTransaction()
	#code is optinal; if you specify the value, make sure the code is unique
	invoice1.code = "rb.rt-9-1"
	#all amounts are in cents
	invoice1.amount = 2000
	#Item Codes must be setup in portal prior to being used
	invoice1.itemCode = "T-Shirt"
	#Type of transaction
	invoice1.accountActivityType = AccountActivityType::Invoice
	#Create payment1
	payment1 = customerAccount.createAssetTransaction()
	#code is optinal; if you specify the value, make sure the code is unique
	payment1.code = "rb.at-9-1"
	#all amounts are in cents
	payment1.amount = 2000
	payment1.transactionType = AssetTransactionType::Visa
	payment1.accountActivityType = AccountActivityType::Payment
	#Credit card number to charge
	payment1.accountNumber = "4111111111111111"
	#Credit card expiration date
	payment1.accessory = "1209"
	#Add processing specific info (for better qualification rates)
	captureInfo1 = payment1.captureInfo
	captureInfo1.holderName = "John Smith"
	captureInfo1.city = "Columbus"
	captureInfo1.state = "CA"
	captureInfo1.street = "233 12th Street"
	captureInfo1.zipCode = "31909"
	captureInfo1.phone = "2129856472"
	captureInfo1.email = "test@yahoo.com"
	captureInfo1.cvv2 = "999"
	#Create invoice2
	invoice2 = customerAccount.createRevenueTransaction()
	#code is optinal; if you specify the value, make sure the code is unique
	invoice2.code = "rb.rt-9-2"
	#all amounts are in cents
	invoice2.amount = 1500
	#Item Codes must be setup in portal prior to being used
	invoice2.itemCode = "T-Shirt"
	#Type of transaction
	invoice2.accountActivityType = AccountActivityType::Invoice
	#Create payment2
	payment2 = customerAccount.createAssetTransaction()
	#code is optinal; if you specify the value, make sure the code is unique
	payment2.code = "rb.at-9-2"
	#/all amounts are in cents
	payment2.amount = 1500
	payment2.transactionType = AssetTransactionType::Visa
	payment2.accountActivityType = AccountActivityType::Payment
	#Credit card number to charge
	payment2.accountNumber = "4111111111111111"
	#Credit card expiration date
	payment2.accessory = "1209"
	#Add processing specific info (for better qualification rates)
	captureInfo2 = payment2.captureInfo
	captureInfo2.holderName = "John Smith"
	captureInfo2.city = "Columbus"
	captureInfo2.state = "CA"
	captureInfo2.street = "233 12th Street"
	captureInfo2.zipCode = "31909"
	captureInfo2.phone = "2129856472"
	captureInfo2.email = "test@yahoo.com"
	captureInfo2.cvv2 = "999"
	#Mark object for persistence
	session.save(customerAccount)
	#Synchronize changes with the server
	begin
		session.synchronize()
	rescue Exception => ex
		#Be sure to properly handle exception, this is just a sample solution
		puts(ex.message)
		return 
	end
	#Logout
	session.logout()


Download Source File

Personal tools