On This Page
C++
C++ Prerequisites
You must create a P12 certificate. See the REST Getting Started Developer Guide.
With this change to use a P12 certificate in your C++ SOAP toolkit configuration, the new
requirements for your application will be:
- GSOAP 2.8.135 or higher (developer version including header files)
- OpenSSL 3.4.0 or higher (developer version including header files)
- G++ compiler
Migration Steps
Follow these steps to upgrade your existing C++ code:
- Update your existing Makefile.Change thecybsdemotarget from:cybsdemo: sample.cpp $(SOAPH) $(SOAPCPP) ../gsoap/dom.cpp wsseapi.o smdevp.o $(CPP) $(CFLAGS) -o cybsdemo sample.cpp soapC.cpp soapClient.cpp ../gsoap/dom.cpp $(SOAPCPP) wsseapi.o smdevp.o $(LIBS)To:cybsdemo: sample.cpp $(SOAPH) $(SOAPCPP) ../gsoap/dom.cpp wsseapi.o smdevp.o $(CPP) $(CFLAGS) -o cybsdemo sample.cpp soapC.cpp ../gsoap/dom.cpp stdsoap2.cpp ../gsoap/import/custom/struct_timeval.cpp ../gsoap/plugin/threads.c ../gsoap/plugin/mecevp.c ../gsoap/plugin/wsaapi.c wsseapi.o smdevp.o soapITransactionProcessorProxy.cpp ../gsoap/import/gsoapWinInet.cpp PropertiesUtil.cpp BinarySecurityTokenHandler.cpp $(LIBS)If you do not have an existing Makefile, you can use one of the following Makefiles:Cybersourcerecommends that you use UnixBuildAllCommented.Makefile or WindowsBuildAllCommented.Makefile. If you need to make changes to individual targets,Cybersourcerecommends that you use UnixQuickBuild.Makefile or WindowsQuickBuild.Makefile, as each target can be built individually.
- CyberSourceTransaction WSDL and XSD version 1.224 are available here:If you want to use a different version, download your preferred version to the project directory and update the versions in theheadertarget of your makefile. For example, change:header: CyberSourceTransaction_1.224.wsdl $(GWSDL) -t ../gsoap/WS/WS-typemap.dat -s -o cybersource.h CyberSourceTransaction_1.224.wsdlto:header: CyberSourceTransaction_1.219.wsdl $(GWSDL) -t ../gsoap/WS/WS-typemap.dat -s -o cybersource.h CyberSourceTransaction_1.219.wsdl
- Add gsoap to the compile path. You can do this by using one of these methods:
- Copy the gsoap directory, including the header files, to one level above the project directory.
- Update all paths in the Makefile that reference 'gsoap' to point to where gsoap is located.
- Update your sample.cpp file to match your test credentials:
If you do not have an existing sample.cpp file, you can use the version that is provided here: sample.cpp.const char *MERCHANT_ID = "your_merchant_id"; const char *TRANSACTION_KEY = "your_transaction_key";If you are using an existing sample.cpp file from a previous C++ SOAP Toolkit, you must refer to all "upgrading from previous versions" comments throughout sample.cpp to see what has changed. - Include these new source files in your project:
- The toolkit.properties configuration file is read from the same location as the executable at run time.Edit the toolkit.properties configuration file to match your test credentials:MERCHANT_ID= KEY_ALIAS= KEY_FILE= KEY_PASS= KEY_DIRECTORY=You must make sure that there are no spaces at the start and end of the lines, or either side of=.
- Run this command in your terminal:make headerThis generates the cybersource.h file.
- Insert this text in the Import section of cybersource.h:#import "WS-Header.h"
- Run this command in your terminal:make sourceThis generates these files:
- soapITransactionProcessorProxy.cpp
- soapITransactionProcessorProxy.h
- ITransactionProcessor.runTransaction.req.xml
- ITransactionProcessor.runTransaction.res.xml
- ITransactionProcessor.nsmap
- soapStub.h
- soapH.h
- soapC.cpp
- Run these commands in your terminal:make wsseapi.o make smdevp.o make cybsdemoThis generates the cybsdemo.exe executable.
- Add your P12 certificate to theKEY_DIRECTORY.
- Run the cybsdemo.exe executable in your terminal.A successful console output consists of thekeyFilefull path, followed by the response from the web service and no errors. For example:keyFile full path: C:/keys/test_p12_file.p12 decision = APPROVED reasonCode = 0 requestID = 6017349752184504643266 requestToken = Axxd6DCgJoj77wSTjm5pe7DwFPfjpNDMyadDIZ/u1Pfje7D9IGU1ogwAGkmXoDc3JoZmTToZDIAAvxSz ccAuthReply.reasonCode = 0