Scenario 2: VB.NET

From Intrannuity

Jump to: navigation, search

Download Source File

Imports System
Imports System.Collections.Generic
 
Imports iBilling.Client
 
Module Scenario2
 
Sub Main()
	'Set up clients' settings
	Dim config = new Dictionary(Of String, Object)()
	config(SessionConnection.PROCESSOR_HOST) = "http://server.ibillingclient.org/ibilling/xmlhttps"
	config(SessionConnection.PAYMENT_OPTION_VERIFICATION_AMOUNT) = 99
	config("debug") = true
	'Login
	Dim _session = Session.Login(2000, "welcome", config)
	'Create customer account
	Dim customerAccount = _session.CreateCustomerAccount()
	'code is optinal; if you specify the value, make sure the code is unique
	customerAccount.Code = "vb.ca-2"
	customerAccount.MerchantAccountCode = 2001
	customerAccount.FirstName = "John"
	customerAccount.LastName = "Smith"
	customerAccount.Type = CustomerAccountTypes.Male
	customerAccount.HomePhone = "2129856472"
	customerAccount.Email = "test@yahoo.com"
	customerAccount.Street1 = "233 12th Street"
	customerAccount.City = "Columbus"
	customerAccount.State = "NY"
	customerAccount.ZipCode = "31909"
	'Create payment option
	Dim paymentOption = customerAccount.CreatePaymentOption()
	'code is optinal; if you specify the value, make sure the code is unique
	paymentOption.Code = "vb.po-2"
	paymentOption.HolderName = "John Smith"
	paymentOption.Number = "1000121279381"
	'routing number
	paymentOption.Accessory = "610000227"
	paymentOption.Type = PaymentOptionTypes.Checking
	paymentOption.Street1 = "233 12th Street"
	paymentOption.City = "Columbus"
	paymentOption.State = "CA"
	paymentOption.ZipCode = "31909"
	'Create payment plan
	Dim paymentPlan = customerAccount.CreatePaymentPlan()
	'code is optinal; if you specify the value, make sure the code is unique
	paymentPlan.Code = "vb.pp-2"
	'all amounts are in cents
	paymentPlan.Amount = 1000
	'Item Codes must be setup in portal prior to being used
	paymentPlan.ItemCode = "Membership"
	paymentPlan.Type = PaymentPlanTypes.Perpetual
	'Billing Cycle codes must be setup in portal prior to being used
	paymentPlan.BillingCycleCode = "W01"
	'Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
	'paymentPlan.FirstBillingDate = <DateTime>
	paymentPlan.PaymentOption = paymentOption
	'Create invoice for downpayment
	Dim revenueTransaction = customerAccount.CreateRevenueTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	revenueTransaction.Code = "vb.rt-2"
	'll amounts are in cents
	revenueTransaction.Amount = 5000
	'Item Codes must be setup in portal prior to being used
	revenueTransaction.ItemCode = "Membership"
	'Type of transaction
	revenueTransaction.AccountActivityType = AccountActivityTypes.Invoice
	'Create payment for downpayment
	Dim transaction = customerAccount.CreateAssetTransaction()
	'code is optinal; if you specify the value, make sure the code is unique
	transaction.Code = "vb.at-2"
	'all amounts are in cents
	transaction.Amount = 5000
	transaction.TransactionType = AssetTransactionTypes.Visa
	'Credit card number to charge
	transaction.AccountNumber = "4111111111111111"
	'Credit card expiration date
	transaction.Accessory = "1209"
	'Type of transaction
	transaction.AccountActivityType = AccountActivityTypes.Payment
	'Add processing specific info (for better qualification rates
	Dim captureInfo = transaction.CaptureInfo
	captureInfo.HolderName = "John Smith"
	captureInfo.City = "Columbus"
	captureInfo.State = "CA"
	captureInfo.Street = "233 12th Street"
	captureInfo.ZipCode = "31909"
	captureInfo.Phone = "2129856472"
	captureInfo.Email = "test@yahoo.com"
	captureInfo.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
	'Get info from customer account
	Console.WriteLine(customerAccount.Code)
	Console.WriteLine(customerAccount.FirstName)
	Console.WriteLine(customerAccount.LastName)
	Console.WriteLine(customerAccount.CreateDate)
	'Get info from payment option
	Console.WriteLine(paymentOption.Code)
	Console.WriteLine(paymentOption.Accessory)
	Console.WriteLine(paymentOption.Number)
	Console.WriteLine(paymentOption.CreateDate)
	'Get info from payment plan
	Console.WriteLine(paymentPlan.Code)
	Console.WriteLine(paymentPlan.FirstBillingDate)
	Console.WriteLine(paymentPlan.BillingCycleCode)
	Console.WriteLine(paymentPlan.CreateDate)
	'Get info from revenue transaction
	Console.WriteLine(revenueTransaction.Code)
	Console.WriteLine(revenueTransaction.Amount)
	Console.WriteLine(revenueTransaction.AccountActivityType)
	Console.WriteLine(revenueTransaction.CreateDate)
	'Get info from asset transaction
	Console.WriteLine(transaction.Code)
	Console.WriteLine(transaction.Accessory)
	Console.WriteLine(transaction.AccountNumber)
	Console.WriteLine(transaction.CreateDate)
	'Get info from capture info
	Console.WriteLine(captureInfo.ReturnType)
	Console.WriteLine(captureInfo.ApprovalCode)
	Console.WriteLine(captureInfo.ReferenceNumber)
	'logout
	_session.Logout()
End Sub
 
End Module
Personal tools