Scenario 4: Visual C++.NET

From Intrannuity

Jump to: navigation, search

Download Source File

#include "stdafx.h"
 
using namespace System;
using namespace System::Collections::Generic;
using namespace iBilling::Client;
 
int Scenario4(array<System::String ^> ^args)
{
	//Set up clients' settings;
	Dictionary<String^, Object^>^ config = gcnew Dictionary<String^, Object^>();
	config[SessionConnection::PROCESSOR_HOST] = "http://server.ibillingclient.org/ibilling/xmlhttps";
	config["debug"] = true;
	//Login;
	Session^ session = Session::Login(2000, "welcome", config);
	//Create customer account;
	CustomerAccount^ customerAccount = session->CreateCustomerAccount();
	//code is optinal; if you specify the value, make sure the code is unique;
	customerAccount->Code = "cpp.ca-4";
	customerAccount->MerchantAccountCode = 2001;
	customerAccount->FirstName = "Mary";
	customerAccount->LastName = "Doe";
	customerAccount->Type = CustomerAccountTypes::Female;
	customerAccount->HomePhone = "5469856876";
	customerAccount->Email = "test@google.com";
	customerAccount->Street1 = "203 16th Street";
	customerAccount->City = "Honolulu";
	customerAccount->State = "CA";
	customerAccount->ZipCode = "30904";
	//Create payment plan;
	PaymentPlan^ paymentPlan = customerAccount->CreatePaymentPlan();
	//code is optinal; if you specify the value, make sure the code is unique;
	paymentPlan->Code = "cpp.pp-4";
	//all amounts are in cents;
	paymentPlan->Amount = 3000;
	//Item Codes must be setup in portal prior to being used;
	paymentPlan->ItemCode = "Membership";
	paymentPlan->Type = PaymentPlanTypes::Complimentary;
	//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>;
	//Mark object for persistence;
	session->Save(customerAccount);
	//Synchronize changes with the server;
	try{
		session->Synchronize();
	}
	catch(Exception^ ex){
		//Be sure to properly handle exception, this is just a sample solution;
		Console::WriteLine(ex->Message);
		return 0;
	}
	//Logout;
	session->Logout();
return 0;
}
Personal tools