Task 2: Migrate with C++
This section explains how to edit the files in your application to use P12
authentication. If you do not have the files that are mentioned in this section, you can
find them in the most recent version of the C++ SOAP toolkit in GitHub.
Follow these steps to upgrade your existing C++ code:
- Update your existing.Makefileby changing thecybsdemotarget from the text in the first example to the text in the second example: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)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 these.Makefilefiles from theCPlusPlusSoapToolkitfolder in GitHub:Cybersourcerecommends that you useUnixBuildAllCommented.MakefileorWindowsBuildAllCommented.Makefile. If you need to make changes to individual targets,Cybersourcerecommends that you useUnixQuickBuild.MakefileorWindowsQuickBuild.Makefile, which enable you to build each target individually.
- Download either theCyberSourceTransactionWSDL or XSD version 1.224 file from theCPlusPlusSoapToolkitfolder in GitHub to your project directory:If you want to use a different version, download your preferred version to the project directory and update the versions in theheadertarget of your.Makefilefrom the text in the first example to the text in the second example.header: CyberSourceTransaction_1.224.wsdl $(GWSDL) -t ../gsoap/WS/WS-typemap.dat -s -o cybersource.h CyberSourceTransaction_1.224.wsdlheader: CyberSourceTransaction_1.219.wsdl $(GWSDL) -t ../gsoap/WS/WS-typemap.dat -s -o cybersource.h CyberSourceTransaction_1.219.wsdl
- Addgsoapto the compile path by using one of these methods:
- Option 1:Copy thegsoapdirectory, including the header files, to one level above the project directory.
- Option 2:Update all paths in the .Makefile that referencegsoapto point to thegsoaplocation.
- Update yoursample.cppfile to include your test credentials:
If you do not have an existingconst char *MERCHANT_ID = "your_merchant_id"; const char *TRANSACTION_KEY = "your_transaction_key";sample.cppfile, you can use thefile in thesample.cppCPlusPlusSoapToolkitfolder in GitHub.If you are using an existingsample.cppfile from a previous C++ SOAP Toolkit, you must refer to current version of thesample.cppfile and find allupgrading from previous versionscomments to see what has changed. - Include these new source files from theCPlusPlusSoapToolkitfolder in your project:
- TheEdit thetoolkit.propertiesconfiguration file to include your test credentials:MERCHANT_ID= KEY_ALIAS= KEY_FILE= KEY_PASS= KEY_DIRECTORY=toolkit.propertiesconfiguration file is read from the same location as the executable at run time.You must verify that there are no spaces at the start and end of each line, or on either side of the equal sign (=).If you do not have an existingtoolkit.propertiesfile, you can use thefile in thetoolkit.propertiesCPlusPlusSoapToolkitfolder in GitHub.
- Run this command in your terminal:make headerThis command generates thecybersource.hfile.
- Insert this text in the Import section of thecybersource.hfile:#import "WS-Header.h"
- Run this command in your terminal:make sourceThis command 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 three commands in this order in your terminal to generate thecybsdemo.exeexecutable file:make wsseapi.o make smdevp.o make cybsdemo
- Add your P12 certificate to the Key directory.
- Run thecybsdemo.exeexecutable file in your terminal.A successful console output consists of thekeyFilefull path, followed by the response from the web service, and no errors.keyFile full path: C:/keys/test_p12_file.p12 decision = APPROVED reasonCode = 0 requestID = 6017349752184504643266 requestToken = Axxd6DCgJoj77wSTjm5pe7DwFPfjpNDMyadDIZ/u1Pfje7D9IGU1ogwAGkmXoDc3JoZmTToZDIAAvxSz ccAuthReply.reasonCode = 0