Announcement

Collapse
No announcement yet.

PaaS Web Service SOAP calls from Salesforce APEX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CnP.Support
    replied
    Good day!

    The examples provided show a simple form to more complex forms. A number of companies are currently using the API Class Library for their development without any issues.

    It is hard for us to support your use of the API platform within APEX. The class library does it all for you.

    Have you reviewed the examples? There is a very simple example with 3 form fields that shows how it all works.

    Leave a comment:


  • rbowen
    started a topic PaaS Web Service SOAP calls from Salesforce APEX

    PaaS Web Service SOAP calls from Salesforce APEX

    I've tried creating a proof-of-concept for calling the C&P Paas Web Service from Salesforce APEX.

    I'm using the web service because there isn't ANY documentation for the C&P Class Library.

    I've created a set of XML that works when using the C&P sandbox, but I can't get it to work in APEX.

    I continue to either get no response from the website (if I add only the XML that works in the sandbox to the body, strings 1-8 below), or errors reported in the XML (expected element 'Operation" in namespace '...') when I try to add SOAP wrappers around the XML body (strings 0-9 below).

    Can anyone point me towards the needed BODY of the request? There isn't much in the manual pages. For example, does the request need a SOAPACTION? What namespaces are needed in the SOAP envelope? What Headers are needed? Any suggestions on how to do this in APEX?

    Here is my code (this generates errors in the XML):

    Code:
     webService static String createCnPDonation() {
    
      // build XML string
      String startXML0 = '<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="[URL]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:pay="[URL="https://ClickAndPledge.com/PaymentService/&quot;'"]https://ClickAndPledge.com/PaymentService/"'[/URL];
      startXML0 += '<soapenv:Body>';
      String startXML1 = '<CnPAPI xmlns="urn:APISchema.xsd"><Version>12</Version><Engine><Request><Operation><OperationType>Transaction</OperationType><IPAddress>192.168.0.11</IPAddress></Operation>';
      String startXML2 = '<Authentication><AccountGuid>xxx123</AccountGuid><AccountID>xxx123</AccountID></Authentication>';
      String startXML3 = '<Order><OrderMode>Test</OrderMode><CardHolder><BillingInformation><BillingFirstName>John</BillingFirstName><BillingMI>C</BillingMI><BillingLastName>Smith</BillingLastName><BillingEmail>[email protected]</BillingEmail><BillingPhone>123.456.7890</BillingPhone></BillingInformation>';
      String startXML4 = '<BillingAddress><BillingAddress1>Post Office Box 1000</BillingAddress1><BillingAddress2></BillingAddress2><BillingAddress3></BillingAddress3><BillingCity>Blacksburg</BillingCity><BillingStateProvince>VA</BillingStateProvince><BillingPostalCode>12346-4563</BillingPostalCode></BillingAddress>';
      String startXML5 = '<PaymentMethod><PaymentType>CreditCard</PaymentType><CreditCard><NameOnCard>John Smith</NameOnCard><CardNumber>4111111111111111</CardNumber><Cvv2>123</Cvv2><ExpirationDate>04/15</ExpirationDate></CreditCard></PaymentMethod></CardHolder>';
      String startXML6 = '<OrderItemList><OrderItem><ItemID>1</ItemID><ItemName>Donation</ItemName><Quantity>1</Quantity><UnitPrice>1111</UnitPrice><UnitDeductible>1111</UnitDeductible></OrderItem></OrderItemList>';
      String startXML7 = '<Receipt><SendReceipt>false</SendReceipt></Receipt><Transaction><TransactionType>Authorize</TransactionType><CurrentTotals><TotalDeductible>1111</TotalDeductible><Total>1111</Total></CurrentTotals>';
      String startXML8 = '</Transaction></Order></Request></Engine></CnPAPI>';
      String startXML9 = '</soapenv:Body></soapenv:Envelope>';
    
      String fullXML = startXML0 + startXML1 + startXML2 + startXML3 + startXML4 + startXML5 + startXML6 + startXML7 + startXML8 + startXML9;
    
      
      // create the request and get the response
      Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setMethod('POST');
      req.setHeader('Content-Type', 'text/xml; charset=utf-8');
      req.setHeader('SOAPAction', '"[URL="https://ClickAndPledge.com/PaymentService/IPaymentService/Operation&quot;'"]https://ClickAndPledge.com/PaymentService/IPaymentService/Operation"'[/URL]);
      req.setHeader('User-Agent', 'PHP-SOAP/5.3.5');
      req.setBody(fullXML);
    
      req.setEndpoint('https://paas.cloud.clickandpledge.com/PaymentService.svc?wsdl');
    
      // send the request and get the response
      HttpResponse res = h.send(req);
         
      return res.getBody();
     }
Working...
X