Prerequisites

You must create a P12 certificate. See the .
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 later (developer version including header files)
  • OpenSSL 3.4.0 or later (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:
    • UnixBuildAllCommented.Makefile
    • UnixQuickBuild.Makefile
    • WindowsBuildAllCommented.Makefile
    • WindowsQuickBuild.Makefile
    We recommend that you use
    UnixBuildAllCommented.Makefile
    or
    WindowsBuildAllCommented.Makefile
    . If you need to make changes to individual targets, we recommend 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";
  5. Include these new source files in your project:
    • BinarySecurityTokenHandler.cpp
    • BinarySecurityTokenHandler.h
    • PropertiesUtil.cpp
    • PropertiesUtil.h
    • stdsoap2.cpp
    • stdsoap2.h
  6. 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
    =
    .
  7. Run this command in your terminal:
    make header
    This generates the
    cybersource.h
    file.
  8. Insert this text in the Import section of
    cybersource.h
    :
    #import "WS-Header.h"
  9. 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
  10. Run these commands in your terminal:
    make wsseapi.o make smdevp.o make cybsdemo
    This generates the
    cybsdemo.exe
    executable.
  11. Add your P12 certificate to the
    KEY_DIRECTORY
    .
  12. 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

Sample Payload Using P12 Authentication

<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:schemas-cybersource-com:transaction-data-1.215"> <SOAP-ENV:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="X509Token"> MIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigAMIICXzCCAcigA........ </wsse:BinarySecurityToken> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> <ds:SignatureMethodAlgorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /> <ds:Reference URI="#Body"> <ds:Transforms> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> <ds:DigestValue> KRmKx6digestvalye12389012367u7hlkV1vvbtec........... </ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>otrfnrck17dwxI4UR12345612yNG7TtE8L3XFhfEa/63r2uBDsg7b2YY8C6nKvkJGop4NHW7d30yfrz5dK2CHkp18TM+hVkyNIVLGokZzZpAwuc0sXm33+J4i765421duLsE4jM0FfIABsPHT2vgSq+T0g+812312jOeIk5R5kLhwnlVd92wQvBmpxINBW2Hh5adwwtpv+gj4AtvuhLYe1ky4R/oDNSWLPmyY1dSIyGDKO4ko8CT0mFlAvxECa8dLHRsyFrZVlK6................ </ds:SignatureValue> <ds:KeyInfo> <wsse:SecurityTokenReference> <wsse:Reference URI="#X509Token" /> </wsse:SecurityTokenReference> </ds:KeyInfo> </ds:Signature> </wsse:Security> </SOAP-ENV:Header> <soapenv:Body> <requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.215"> <merchantID>johndoe</merchantID> <merchantReferenceCode>MRC-123</merchantReferenceCode> <billTo> <firstName>John</firstName> <lastName>Doe</lastName> <street1>123 Example Road</street1> <city>Austin</city> <state>TX</state> <postalCode>12345</postalCode> <country>US</country> <email>abc@company.com</email> </billTo> <shipTo> <firstName>John</firstName> <lastName>Doe</lastName> <street1>123 Example Road</street1> <city>Austin</city> <state>TX</state> <postalCode>12345</postalCode> <country>US</country> </shipTo> <purchaseTotals> <currency>USD</currency> <grandTotalAmount>100.00</grandTotalAmount> </purchaseTotals> <card> <accountNumber>4111111111111111</accountNumber> <expirationMonth>12</expirationMonth> <expirationYear>2029</expirationYear> <cvNumber>111</cvNumber> </card> <ccAuthService run="true"></ccAuthService> <ccCaptureService run="true"></ccCaptureService> </requestMessage> </soapenv:Body> </soapenv:Envelope>