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:
  1. Update your existing
    .Makefile
    by changing the
    cybsdemo
    target 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
    .Makefile
    files from the
    CPlusPlusSoapToolkit
    folder in GitHub:
    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
    , which enable you to build each target individually.
  2. Download either the
    CyberSourceTransaction
    WSDL or XSD version 1.224 file from the
    CPlusPlusSoapToolkit
    folder 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 the
    header
    target of your
    .Makefile
    from 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.wsdl
    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 by using one of these methods:
    • Option 1:
      Copy the
      gsoap
      directory, including the header files, to one level above the project directory.
    • Option 2:
      Update all paths in the .Makefile that reference
      gsoap
      to point to the
      gsoap
      location.
  4. Update your
    sample.cpp
    file to include 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
    sample.cpp
    file in the
    CPlusPlusSoapToolkit
    folder in GitHub.
    If you are using an existing
    sample.cpp
    file from a previous C++ SOAP Toolkit, you must refer to current version of the
    sample.cpp
    file and find all
    upgrading from previous versions
    comments to see what has changed.
  5. Include these new source files from the
    CPlusPlusSoapToolkit
    folder in your project:
  6. Edit the
    toolkit.properties
    configuration file to include 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 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 existing
    toolkit.properties
    file, you can use the
    toolkit.properties
    file in the
    CPlusPlusSoapToolkit
    folder in GitHub.
  7. Run this command in your terminal:
    make header
    This command generates the
    cybersource.h
    file.
  8. Insert this text in the Import section of the
    cybersource.h
    file:
    #import "WS-Header.h"
  9. Run this command in your terminal:
    make source
    This command generates these files:
    • soapITransactionProcessorProxy.cpp
    • soapITransactionProcessorProxy.h
    • ITransactionProcessor.runTransaction.req.xml
    • ITransactionProcessor.runTransaction.res.xml
    • ITransactionProcessor.nsmap
    • soapStub.h
    • soapH.h
    • soapC.cpp
  10. Run these three commands in this order in your terminal to generate the
    cybsdemo.exe
    executable file:
    make wsseapi.o make smdevp.o make cybsdemo
  11. Add your P12 certificate to the Key directory.
  12. Run the
    cybsdemo.exe
    executable file in your terminal.
    A successful console output consists of the
    keyFile
    full 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