Scenario 9: VB.NET

From Intrannuity

Jump to: navigation, search

Download Source File

Imports System
Imports System.Collections.Generic
 
Imports iBilling.Client
 
Module Scenario9
 
Sub Main()
	'Set up clients' settings
	Dim config = new Dictionary(Of String, Object)()
	config(SessionConnection.PROCESSOR_HOST) = "http://server.ibillingclient.org/ibilling/xmlhttps"
	config("debug") = true
	'Login
	Dim _session = Session.Login(2000, "welcome", config)
	'Find customer account
	Dim customerAccount = _session.LoadCustomerAccount("vb.ca-2")
	'Create invoice1
	Dim invoice1 = customerAccount.CreateRevenueTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	invoice1.Code = "vb.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 = AccountActivityTypes.Invoice
	'Create payment1
	Dim payment1 = customerAccount.CreateAssetTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	payment1.Code = "vb.at-9-1"
	'all amounts are in cents
	payment1.Amount = 2000
	payment1.TransactionType = AssetTransactionTypes.Visa
	payment1.AccountActivityType = AccountActivityTypes.Payment
	'Credit card number to charge
	payment1.AccountNumber = "4111111111111111"
	'Credit card expiration date
	payment1.Accessory = "1209"
	'Add processing specific info (for better qualification rates)
	Dim 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
	Dim invoice2 = customerAccount.CreateRevenueTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	invoice2.Code = "vb.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 = AccountActivityTypes.Invoice
	'Create payment2
	Dim payment2 = customerAccount.CreateAssetTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	payment2.Code = "vb.at-9-2"
	'/all amounts are in cents
	payment2.Amount = 1500
	payment2.TransactionType = AssetTransactionTypes.Visa
	payment2.AccountActivityType = AccountActivityTypes.Payment
	'Credit card number to charge
	payment2.AccountNumber = "4111111111111111"
	'Credit card expiration date
	payment2.Accessory = "1209"
	'Add processing specific info (for better qualification rates)
	Dim 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
	Try
		_session.Synchronize()
 
	Catch ex As Exception
		'Be sure to properly handle exception, this is just a sample solution
		Console.WriteLine(ex.Message)
		Exit Sub 
 
	End Try
	'Logout
	_session.Logout()
End Sub
 
End Module
Personal tools