developer:comobject_v2

COM Object v2.0

Download

USAePay Gateway Wrapper COM

The USAePay COM component uses the Transaction API to send requests to the gateway. The component allows you to set any field for the request and to receive the resulting fields as returned by the gateway. It also performs transparent URL encoding/decoding for the field values. Since the component is based on COM, it can be used in different applications including those written in C++, Visual Basic, Visual Basic .NET, C#, and various other languages.

Requirements and Installation Instructions

To register the COM object, place the “USAepayComObject” folder on your hard drive, open the console (cmd.exe) as an administrator and type:

regsvr32 C:\(PATH TO THE FOLDER USAePayCom_v2)\USAePayCOM.dll

To uninstall the COM object, run:

regsvr32 \u C:\(PATH TO THE FOLDER USAePayCom_v2)\USAePayCOM.dll

Once the COM component has been installed and properly registered, you can use it in your applications. We have included two example applications, one in C++ (unmanaged) and one in Visual Basic .NET to demonstrate how the component can be used in projects written in those two languages.

For C++, you need to include the files “USAePayCOM.h” and “USAePayCOM_i.c” in your project. For Visual Basic .NET, you need to add the “USAePay COM” component from the list of available COM component as a Reference. Similar actions need to be taken for other .NET languages.

This component is compatible with the IIS environment.

Compiling Your Program

Once you've installed the COM object, you can start using it in your applications. We have provided a sample application using the COM object called USAePayClient to serve as a reference on how to connect and use the COM object. You will need to compile two files: “USAepay.h” and “USAepay_i.c” (they can be found in the Client Samples folder). Copy these files to your project folder and include them in your project.

Example Of Sale

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
					LPSTR lpCmdLine, int nCmdShow)
{
	HRESULT result;
 
	result = CoInitialize(0);
 
	if (SUCCEEDED(result)) {
		IUSAePayService* service = NULL;
 
		result = CoCreateInstance(CLSID_USAePayService, NULL, CLSCTX_INPROC_SERVER, IID_IUSAePayService, (void**) &service);
 
		if (! SUCCEEDED(result)) {
			printf("Error creating instance (%x)", result);
		} else {
			service->put_GatewayUrl(CComBSTR(L"https://sandbox.usaepay.com/gate"));
 
			service->UpdateField(CComBSTR(L"UMcommand"), CComBSTR(L"cc:sale"));
			service->UpdateField(CComBSTR(L"UMkey"), CComBSTR(L"WJF4B92MJ3t5Ui1b089ogn1Ko32R7V48"));
			service->UpdateField(CComBSTR(L"UMname"), CComBSTR(L"John Smith"));
			service->UpdateField(CComBSTR(L"UMcard"), CComBSTR(L"4000100011112224"));
			service->UpdateField(CComBSTR(L"UMexpir"), CComBSTR(L"1212"));
			service->UpdateField(CComBSTR(L"UMamount"), CComBSTR(L"6.00"));
			service->UpdateField(CComBSTR(L"UMinvoice"), CComBSTR(L"12345"));
			service->UpdateField(CComBSTR(L"UMline1name"), CComBSTR(L"book"));
			service->UpdateField(CComBSTR(L"UMline1sku"), CComBSTR(L"12"));
			service->UpdateField(CComBSTR(L"UMcustom1"), CComBSTR(L"13"));
 
 
			CComBSTR pin(L"1234");
			service->UpdateHashField(pin);
 
			service->PerformTransaction();
 
			CComBSTR refNum;
			service->GetResponseField(CComBSTR(L"UMrefNum"), &refNum);
			CW2CT szRefNum(refNum);
			MessageBox(NULL, szRefNum, "warning", MB_OK | MB_ICONEXCLAMATION);
		}
	} else {
		printf("Error initializing COM");
	}
 
	CoUninitialize();
 
	return 0;
}
developer/comobject_v2.txt · Last modified: 2011/11/22 12:19 by vladg

Page Tools