Scenario 1: VB.NET

From Intrannuity

Jump to: navigation, search

Download Source File

Imports System
Imports System.Collections.Generic
 
Imports iBilling.Client
 
Module Scenario1
 
Sub Main()
	'Set up clients' settings
	Dim config = new Dictionary(Of String, Object)()
	config(SessionConnection.PROCESSOR_HOST) = "http://server.ibillingclient.org/ibilling/xmlhttps"
	'Amount to be used for test transactions that are processed to validate new payment options; optional
	config(SessionConnection.PAYMENT_OPTION_VERIFICATION_AMOUNT) = 99
	'Set the value to true to view XML exchanged between your client and the server
	config(SessionConnection.DEBUG) = true
	'Data for increased fraud protection, all of these values are optional
	'Domain name of user's e-mail (user on behalf of whom the transaction is processed)
	config(SessionConnection.CLIENT_EMAIL_DOMAIN) = "hotmail.com"
	'IP Address of the user's machine (user on behalf of whom the transaction is processed)
	config(SessionConnection.CLIENT_IP_ADDRESS) = "145.21.0.1"
	'Full e-mail address of the user as MD5 (user on behalf of whom the transaction is processed)
	config(SessionConnection.CLIENT_EMAIL_ENCODED) = "8d89c3087cc6cb98793ab7c0f5658c56"
	'Full user name of the user as MD5 (user on behalf of whom the transaction is processed)
	config(SessionConnection.CLIENT_USER_NAME_ENCODED) = "435e0648d634175c46bd40ac366545a8"
	'Password of the user as MD5 (user on behalf of whom the transaction is processed)
	config(SessionConnection.CLIENT_PASSWORD_ENCODED) = "5f4dcc3b5aa765d61d8327deb882cf99"
	'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-1"
	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 = "Honolulu"
	customerAccount.State = "CA"
	customerAccount.ZipCode = "31904"
	'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-1"
	paymentOption.HolderName = "John Smith"
	paymentOption.Number = "4111111111111111"
	'expiration date
	paymentOption.Accessory = "1209"
	paymentOption.Street1 = "233 12th Street"
	paymentOption.City = "Honolulu"
	paymentOption.State = "CA"
	paymentOption.ZipCode = "31904"
	'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-1"
	'all amounts are in cents
	paymentPlan.Amount = 5000
	'Item Codes must be setup in portal prior to being used
	paymentPlan.ItemCode = "Membership"
	paymentPlan.Type = PaymentPlanTypes.Fixed
	'Billing Cycle codes must be setup in portal prior to being used
	paymentPlan.BillingCycleCode = "M03"
	'Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
	'paymentPlan.FirstBillingDate = <DateTime>
	paymentPlan.Add(0, 12, false)
	' 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-1"
	'all amounts are in cents
	revenueTransaction.Amount = 10000
	'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-1"
	'all amounts are in cents
	transaction.Amount = 10000
	transaction.TransactionType = AssetTransactionTypes.Cash
	transaction.AccountActivityType = AccountActivityTypes.Payment
	'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)
	'Get info from payment option
	Console.WriteLine(paymentOption.Code)
	Console.WriteLine(paymentOption.Accessory)
	Console.WriteLine(paymentOption.Number)
	'Get info from payment plan
	Console.WriteLine(paymentPlan.Code)
	Console.WriteLine(paymentPlan.FirstBillingDate)
	Console.WriteLine(paymentPlan.BillingCycleCode)
	'Get info from revenue transaction
	Console.WriteLine(revenueTransaction.Code)
	Console.WriteLine(revenueTransaction.Amount)
	Console.WriteLine(revenueTransaction.AccountActivityType)
	'Get info from asset transaction
	Console.WriteLine(transaction.Code)
	Console.WriteLine(transaction.Amount)
	Console.WriteLine(transaction.AccountActivityType)
	'logout
	_session.Logout()
End Sub
 
End Module
Personal tools