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:
  1. Update your existing Makefile.
    Change the
    cybsdemo
    target 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:
    Cybersource
    recommends that you use UnixBuildAllCommented.Makefile or WindowsBuildAllCommented.Makefile. If you need to make changes to individual targets,
    Cybersource
    recommends that you use UnixQuickBuild.Makefile or WindowsQuickBuild.Makefile, as each target can be built individually.
  2. 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 the
    header
    target 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.wsdl
    to:
    header: CyberSourceTransaction_1.219.wsdl $(GWSDL) -t ../gsoap/WS/WS-typemap.dat -s -o cybersource.h CyberSourceTransaction_1.219.wsdl
  3. 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.
  4. Update your sample.cpp file to match your test credentials:
    const char *MERCHANT_ID = "your_merchant_id"; const char *TRANSACTION_KEY = "your_transaction_key";
    If you do not have an existing sample.cpp file, you can use the version that is provided here: sample.cpp.
    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.
  5. Edit the toolkit.properties configuration file to match your test credentials:
    MERCHANT_ID= KEY_ALIAS= KEY_FILE= KEY_PASS= KEY_DIRECTORY=
    The toolkit.properties configuration file is read from the same location as the executable at run time.
    You must make sure that there are no spaces at the start and end of the lines, or either side of
    =
    .
  6. Run this command in your terminal:
    make header
    This generates the cybersource.h file.
  7. Insert this text in the Import section of cybersource.h:
    #import "WS-Header.h"
  8. Run this command in your terminal:
    make source
    This generates these files:
    • soapITransactionProcessorProxy.cpp
    • soapITransactionProcessorProxy.h
    • ITransactionProcessor.runTransaction.req.xml
    • ITransactionProcessor.runTransaction.res.xml
    • ITransactionProcessor.nsmap
    • soapStub.h
    • soapH.h
    • soapC.cpp
  9. Run these commands in your terminal:
    make wsseapi.o make smdevp.o make cybsdemo
    This generates the cybsdemo.exe executable.
  10. Add your P12 certificate to the
    KEY_DIRECTORY
    .
  11. Run the cybsdemo.exe executable in your terminal.
    A successful console output consists of the
    keyFile
    full 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