This header file sets the macros for checking error codes and also provides the proper registry entry keys for registering the CPC with the Payment Selector. Use the unique name of your CPC as listed in the \CPCPlugIn directory to register the component.
The file common.h contains the comment MOD TODO in each line requiring modification. Search the file for the MOD TODO string and replace the default sample name Internet Cash
with the unique name of your CPC:
// MOD TODO: You must create a key in the registry that reflects your CPC name. To do this you must
// replace "Internet Cash" with the name of your CPC.
//
#define RV_CCPLUGIN TEXT("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Shopper\\PlugIns\\Internet Cash")
#define RV_CPCINSTALL TEXT("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Shopper\\Install")
#define RK_CHANGECOUNT TEXT("ChangeCount")
#define RK_CPC_STATE TEXT("State")
Generate new programmatic identifiers (ProgIDs) for your CPC. The Payment Selector uses the ProgID to load the CPC. Note that the CPC ProgID must match the ProgID assigned in CPCPlugIn.cpp:
// MOD TODO: You must create a unque PROGID that reflects the name of the CPC. The PROGID is used by the Wallet to load the CPC. This PROGID must match the PROGID found in sdkplugin.cpp.
#define RK_PLG_VAL_CCPROGID TEXT("CPCPLUGIN.CPCPlugInObject.1")
Refer to the OLE Programmer's Reference in the Win32® SDK for information regarding programmatic identifiers.
This key source file is generated by the ATL Wizard, and handles DLLMain integration and the MFC CWinApp creation.
It is important to note that the sample file provided has been modified to address MFC threading support for the component. If you do not use the sample file, you must devise a way to handle multiple threading and multiple processes on the client payment component level.
The CPCPlugIn.def file is created by the ATL Wizard, the CPCPlugIn.mak file is the make file generated by the sample CPC project, and the CPCPlugIn.rc file is the resource file used by your CPC.
The CPCPlugIn.idl file defines the CPC object. The MIDL compiler reads this file and then generates the type libraries and other linker files.
You should assign new globally unique identifiers (GUIDs) to configure the sample file for the CPC that you build. The file CPCPlugIn.idl contains the comment MOD TODO in each line requiring modification. Search the file for the MOD TODO comment and replace the existing GUID:
import "oaidl.idl";
import "ocidl.idl";
#include "iWalletCB.idl"
#include "iWalletCB2.idl"
#include "icpc.idl"
#include "ipayinst.idl"
// MOD TODO: Change all occurences of MyCPC to <YourCPCName>
//
// MOD TODO: you need to replace the following two uuid's with new generated
// uuid's. These are used to identify your object and typelib.
[
uuid(5AC9D181-EC1A-11D0-BB19-00AA00A13794),
version(1.0),
helpstring("MyCPC 1.0 Type Library")
]
library MyCPCLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(5AC9D18F-EC1A-11D0-BB19-00AA00A13794),
helpstring("MyCPC Class")
]
coclass MyCPC
{
[default] interface IClientPaymentProvider;
interface IPaymentProviderInstall;
};
};
Refer to the MAPI Programmer's Reference in the Win32 SDK for more information on creating new GUIDs.
This source file implements a generic registry class that controls registration with the Payment Selector.
This source file implements the member functions of the IClientPaymentProvider and ISelectorCallback interfaces that are used to create and configure payment types in the consumer's Payment Selector.
In the CPCObject.cpp file, you will need to modify most of this code to support the CPC you are creating. The file CPCObject.cpp contains the comment MOD TODO in each line requiring modification. You can search the file for the MOD TODO comment to make required changes.
Change the friendly name from the default Internet Cash to the friendly name of your CPC:
// MOD TODO: This is the Friendly Name of the CPC type. You must change "Internet Cash" to the friendly name of your CPC.
//
#define SDK_TYPE L"Internet Cash"
static CString szType = SDK_TYPE;
Modify the accepted type and short name to reflect the friendly name of your CPC:
// MOD TODO: This is the Accepted Type (and short name) of the type of this CPC. You must change "ICash" to the short name of your CPC.
//
#define SDK_ACCEPT_TYPE _T("ICash")
CString szThisType = SDK_ACCEPT_TYPE;
Change the fields PAYMENT_TYPE
, PAYMENT_ACCOUNT
, and PAYMENT_AMOUNT
given in the sample to reflect the fields that are being posted back as part of the payment instruction:
// MOD TODO: You should change this to reflect the fields that are being // posted back as part of the payment instruction. This defines a set of // constants and the names that are found in the post.
//
#define PAYMENT_TYPE 0
#define PAYMENT_ACCOUNT 1
#define PAYMENT_AMOUNT 2
static const cPaymentElements = 3; // MOD TODO: Should reflect the total number
static OLECHAR *rgszFieldNames[] =
{
L"Type",
L"Account",
L"Amount",
};
To prevent multiple processes from accessing critical sections, you should replace the sample mutex name "ICashSamplePlugin" with the unique name of your CPC:
// MOD TODO: You need to change the name of the Mutex to something that // reflects the CPC name.
//
m_hMutex = CreateMutex(
NULL, // No Scurity
FALSE, // initially not owned
"ICashSamplePluginMutex"); // name of the Mutex
if (m_hMutex == NULL)
return;
do {
dwWaitResult = WaitForSingleObject(
m_hMutex, // handle of mutex
1000L); // Wait for 1 second
Change the sample mapping file name "ICashSamplePlugin" to the unique name of your CPC:
// MOD TODO: You need to change the name of the Mapping file to something that reflects the CPC name.
//
if (dwWaitResult == WAIT_OBJECT_0) {
m_hMapObject = CreateFileMapping(
(HANDLE) 0xFFFFFFFF, // Use the Paging File
NULL, // No security
PAGE_READWRITE, // Read/Write access
0, // size: high 32-bits
sizeof(InstanceShare), // size: low 32-bits
"ICashSamplePluginShare");
if (!m_hMapObject)
return;
fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
Replace the fields "PAYMENT_TYPE," "PAYMENT_ACCOUNT", and "PAYMENT_AMOUNT" in the sample code with the fields that will be posted back as part of the payment instruction. The SAFEARRAY will consist of name/value pairs whose names and values are stored as BSTRs:
// MOD TODO: This section of code will build the SAFEARRAY of name/value pairs that is posted back to the server.
//
FillVariants(pvar, PAYMENT_TYPE, cPaymentElements, SDK_ACCEPT_TYPE);
FillVariants(pvar, PAYMENT_ACCOUNT, cPaymentElements, m_pData->m_gData[dwIdx].Name);
FillVariantsWide(pvar, PAYMENT_AMOUNT, cPaymentElements, bstrTotal);
hr = S_OK;
Explanation and examples of function syntax are provided in the "Client Payment Component (CPC) Interfaces" section.
This source file defines a simple utility routine used by the CPC object, and provides a message box. You can modify this program to perform routines on the CPC that you create.