Scenario 5: Visual C++.NET

From UniCharge Integration Library
Jump to: navigation, search

Download Source File

#include "stdafx.h"
 
using namespace System;
using namespace System::Collections::Generic;
using namespace iBilling::Client;
 
int Scenario5(array<System::String ^> ^args)
{
	//Set up clients' settings;
	Dictionary<String^, Object^>^ config = gcnew Dictionary<String^, Object^>();
	config[SessionConnection::PROCESSOR_HOST] = "https://[server-name]/ibilling/xmlhttps";
	config["debug"] = true;
	//Login;
	Session^ session = Session::Login(2000, "welcome", config);
	//execute find payment plan;
	PaymentPlan^ paymentPlan = session->LoadPaymentPlan("cpp.pp-3");
	Charge^ charge = paymentPlan->Charges[1];
	charge->IsPrepaid = true;
	//get customer account;
	CustomerAccount^ customerAccount = paymentPlan->CustomerAccount;
	//Create payment for downpayment;
	AssetTransaction^ transaction = customerAccount->CreateAssetTransaction();
	//code is optinal; if you specify the value, make sure the code is unique;
	transaction->Code = "cpp.at-5";
	//all amounts are in cents;
	transaction->Amount = 3000;
	//Type of transaction;
	transaction->AccountActivityType = AccountActivityTypes::Payment;
	transaction->TransactionType = AssetTransactionTypes::Check;
	//check number;
	transaction->AccountNumber = "10100125687";
	transaction->IsPrepayment = true;
	transaction->DueDate = charge->BillingDate;
	//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
Namespaces

Variants
Actions
Integration Info
Library Documentation
Toolbox