From Intrannuity
Download Source File
#include "stdafx.h"
using namespace System;
using namespace System::Collections::Generic;
using namespace iBilling::Client;
int Scenario9(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);
//Find customer account;
CustomerAccount^ customerAccount = session->LoadCustomerAccount("cpp.ca-2");
//Create invoice1;
RevenueTransaction^ invoice1 = customerAccount->CreateRevenueTransaction();
//code is optinal; if you specify the value, make sure the code is unique;
invoice1->Code = "cpp.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;
AssetTransaction^ payment1 = customerAccount->CreateAssetTransaction();
//code is optinal; if you specify the value, make sure the code is unique;
payment1->Code = "cpp.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);
CaptureInfo^ 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;
RevenueTransaction^ invoice2 = customerAccount->CreateRevenueTransaction();
//code is optinal; if you specify the value, make sure the code is unique;
invoice2->Code = "cpp.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;
AssetTransaction^ payment2 = customerAccount->CreateAssetTransaction();
//code is optinal; if you specify the value, make sure the code is unique;
payment2->Code = "cpp.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);
CaptureInfo^ 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(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;
}