Announcement

Collapse
No announcement yet.

ColdFusion and CnP API

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

  • ColdFusion and CnP API

    I have tried to rewrite your sample php application in ColdFusion but i'm receiving errors.

    It's a simple application, but I keep getting this error:
    Code:
    Cannot perform web service invocation Operation.
    The fault returned when invoking the web service operation is: AxisFault faultCode: {http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher}InternalServiceFault faultSubcode: faultString: Object reference not set to an instance of an object. faultActor: faultNode: faultDetail: {http://schemas.datacontract.org/2004/07/System.ServiceModel}ExceptionDetail:Object reference not set to an instance of an object. at PaymentService.Operation(String instruction) at SyncInvokeOperation(Object , Object [] , Object[] ) at ...
    Here's the code for my coldfusion app:
    Code:
    <cfif isdefined('form.submit')>    <cfsavecontent variable="xml">
        <cfoutput>#txtParam#</cfoutput>
        </cfsavecontent>
        
        <cfif form.txtParam NEQ ''>
            <cfscript>
                   cnp_client = createobject('webservice','https://paas.cloud.clickandpledge.com/paymentservice.svc?wsdl');
            </cfscript>
            <cfset params=StructNew()>
            <cfset params.instruction = form.txtParam>
            <cfset result = cnp_client.Operation(params)>
            <cfdump var="#result#">
        </cfif>
    
    
    </cfif>
    <HTML>
        <HEAD>
            <TITLE>Click & Pledge API</TITLE>
        </HEAD
        ><BODY>
        <cfform action="" method="post">
            <!-- Copy & paste the XML request below  -->
            <p><cftextarea id="txtParam" name="txtParam" rows="5" cols="60"></cftextarea>
               <br />
               <cfinput type="submit" value="Process Request" name="submit"/>
            </p>
        </cfform>
     </BODY>
    </HTML>
    Here's the XML that I am posting:
    Code:
    <CnPAPI xmlns="urn:APISchema.xsd">  <Version>12</Version> 
      <Engine>
        <Request>
          <Operation>
            <OperationType>Transaction</OperationType>
            <IPAddress>192.168.0.11</IPAddress>
          </Operation>
          <Authentication>
            <AccountGuid>ddd31189-9a80-41d9-99e7-fdbb4350893c</AccountGuid>
            <AccountID>14521</AccountID>
          </Authentication>
          <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>
              <BillingAddress>
                <BillingAddress1>Post Office Box 1000</BillingAddress1>
                <BillingAddress2></BillingAddress2>
                <BillingAddress3></BillingAddress3>
                <BillingCity>Blacksburg</BillingCity>
                <BillingStateProvince>VA</BillingStateProvince>
                <BillingPostalCode>12346-4563</BillingPostalCode>
                <BillingCountryCode>840</BillingCountryCode>
              </BillingAddress>
              <CustomFieldList>
                <CustomField>
                  <FieldName>Employer</FieldName>
                  <FieldValue>Good Company</FieldValue>
                </CustomField>
                <CustomField>
                  <FieldName>Occupation</FieldName>
                  <FieldValue>Good Job</FieldValue>
                </CustomField>
                <CustomField>
                  <FieldName>Place of Employment</FieldName>
                  <FieldValue>Blacksburg, Virginia</FieldValue>
                </CustomField>
              </CustomFieldList>
              <PaymentMethod>
                <PaymentType>CreditCard</PaymentType>
                <CreditCard>
                  <NameOnCard>John Smith</NameOnCard>
                  <CardNumber>4111111111111111</CardNumber>
                  <Cvv2>123</Cvv2>
                  <ExpirationDate>04/15</ExpirationDate>
                </CreditCard>
              </PaymentMethod>
            </CardHolder>
                    <ThirdParty>
                        <SocialNetworks>
                            <Network>
                                <NetworkName>Twitter</NetworkName>
                                <NetworkUserID>UserID</NetworkUserID>
                                <NetworkPassword>Password</NetworkPassword>
                                <NetworkComment>Sample twitter message</NetworkComment>
                            </Network>            
                        </SocialNetworks>    
                    </ThirdParty>           
            <OrderItemList>
              <OrderItem>
                <ItemID>1</ItemID>
                <ItemName>Donation</ItemName>
                <Quantity>1</Quantity>
                <UnitPrice>1000</UnitPrice>
                <UnitDeductible>1000</UnitDeductible>
              </OrderItem>
            </OrderItemList>
            <Receipt>
                         <SendReceipt>true</SendReceipt>
                         <WID>30168</WID>  
              <Deductible>0</Deductible>
            </Receipt>
            <Transaction>
              <TransactionType>Authorize</TransactionType>
              <CurrentTotals>
                <TotalDeductible>1000</TotalDeductible>
                <Total>1000</Total>
              </CurrentTotals>
            </Transaction>
          </Order>
        </Request>
      </Engine>
    </CnPAPI>
    and if I just post the XML file to the webservice (like this: <cfset result = cnp_client.Operation(form.txtParam)> rather than placing it in an array), I get this response:
    Class Name org.datacontract.schemas._2004._07.CcTransactionRe sult
    Methods
    equals(java.lang.Object) boolean
    getAdditionalInfo() java.lang.String
    getAuthorizationCode() java.lang.String
    getDeserializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName) org.apache.axis.encoding.Deserializer
    getEchoInput() java.lang.String
    getFraudReview() java.lang.String
    getGatewayTransactionNumber() java.lang.String
    getResultCode() java.lang.Integer
    getResultData() java.lang.String
    getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName) org.apache.axis.encoding.Serializer
    getServer() java.lang.String
    getTransactionNumber() java.lang.String
    getTypeDesc() org.apache.axis.description.TypeDesc
    getVaultGUID() java.lang.String
    getVersion() java.lang.String
    hashCode() int
    setAdditionalInfo(java.lang.String) void
    setAuthorizationCode(java.lang.String) void
    setEchoInput(java.lang.String) void
    setFraudReview(java.lang.String) void
    setGatewayTransactionNumber(java.lang.String) void
    setResultCode(java.lang.Integer) void
    setResultData(java.lang.String) void
    setServer(java.lang.String) void
    setTransactionNumber(java.lang.String) void
    setVaultGUID(java.lang.String) void
    setVersion(java.lang.String) void

    Any idea what i'm doing wrong here? I don't have much experience with any SOAP API's and I don't really know what I should be receiving or passing into these soap requests.. The samples I have seen haven't given me much direction.

    Thanks for any help,
    -Jason

  • #2
    If anyone could even post an example of what the sample PHP file returns when you post the first XML example that'd be helpful.. I have no idea what i'm supposed to be receiving when I send these XML requests.

    Comment


    • #3
      Is this thing on? *tap*tap*

      Comment


      • #4
        Good day!

        We have a PHP example at:

        http://manual.clickandpledge.com/Sample-Programs.html

        have you seen that example?
        Regards,
        Click & Pledge Support Department

        On Salesforce? Help us by rating our app: Click & Pledge Donor Management on AppExchange

        Join us @ the educational webinars: https://clickandpledge.com/webinars/
        Live Support available Join between 3:00 - 3:30 p.m. ET Monday - Thursday: https://clickandpledge.com/webinars/
        Are you on Salesforce? Join us at the Power of Us Hub: https://powerofus.force.com/0F980000000CjpC

        Comment


        • #5
          Yes but I am trying to convert that into ColdFusion which we use. I'm not sure what I should be receiving when I post that sample XML file. If you could tell me what kind of response I should be getting from your WSDL file that'd be great.

          Comment


          • #6
            The following is what you will get from the WSDL:

            <xs:element minOccurs="0" name="AdditionalInfo" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="AuthorizationCode" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="EchoInput" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="FraudReview" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="GatewayTransactionNumber" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="ResultCode" type="xs:int"/>
            <xs:element minOccurs="0" name="ResultData" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="Server" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="TransactionNumber" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="VaultGUID" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="Version" nillable="true" type="xs:string"/>

            hope the above is what you are looking for.
            Regards,
            Click & Pledge Support Department

            On Salesforce? Help us by rating our app: Click & Pledge Donor Management on AppExchange

            Join us @ the educational webinars: https://clickandpledge.com/webinars/
            Live Support available Join between 3:00 - 3:30 p.m. ET Monday - Thursday: https://clickandpledge.com/webinars/
            Are you on Salesforce? Join us at the Power of Us Hub: https://powerofus.force.com/0F980000000CjpC

            Comment


            • #7
              I finally got it working, here's the code for any other coldfusion developers:


              Code:
              <cfsavecontent variable="soapBody">
              <CnPAPI xmlns="urn:APISchema.xsd">
                <Version>12</Version> 
                <Engine>
                  <Request>
                    <Operation>
                      <OperationType>Transaction</OperationType>
                      <IPAddress>192.168.0.11</IPAddress>
                    </Operation>
                    <Authentication>
                      <AccountGuid>*****Your API key goes here****</AccountGuid>
                      <AccountID>***** Your Account ID *****</AccountID>
                    </Authentication>
                    <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>
                        <BillingAddress>
                          <BillingAddress1>Post Office Box 1000</BillingAddress1>
                          <BillingAddress2></BillingAddress2>
                          <BillingAddress3></BillingAddress3>
                          <BillingCity>Blacksburg</BillingCity>
                          <BillingStateProvince>VA</BillingStateProvince>
                          <BillingPostalCode>12346-4563</BillingPostalCode>
                          <BillingCountryCode>840</BillingCountryCode>
                        </BillingAddress>
                        <CustomFieldList>
                          <CustomField>
                            <FieldName>Employer</FieldName>
                            <FieldValue>Good Company</FieldValue>
                          </CustomField>
                          <CustomField>
                            <FieldName>Occupation</FieldName>
                            <FieldValue>Good Job</FieldValue>
                          </CustomField>
                          <CustomField>
                            <FieldName>Place of Employment</FieldName>
                            <FieldValue>Blacksburg, Virginia</FieldValue>
                          </CustomField>
                        </CustomFieldList>
                        <PaymentMethod>
                          <PaymentType>CreditCard</PaymentType>
                          <CreditCard>
                            <NameOnCard>John Smith</NameOnCard>
                            <CardNumber>4111111111111111</CardNumber>
                            <Cvv2>123</Cvv2>
                            <ExpirationDate>04/15</ExpirationDate>
                          </CreditCard>
                        </PaymentMethod>
                      </CardHolder>
                      <OrderItemList>
                        <OrderItem>
                          <ItemID>1</ItemID>
                          <ItemName>Donation</ItemName>
                          <Quantity>1</Quantity>
                          <UnitPrice>1000</UnitPrice>
                          <UnitDeductible>1000</UnitDeductible>
                        </OrderItem>
                      </OrderItemList>
                      <Receipt>
                               <SendReceipt>true</SendReceipt>
                               <WID>48778</WID>  
                        <Deductible>0</Deductible>
                      </Receipt>
                      <Transaction>
                        <TransactionType>Authorize</TransactionType>
                        <CurrentTotals>
                          <TotalDeductible>1000</TotalDeductible>
                          <Total>1000</Total>
                        </CurrentTotals>
                      </Transaction>
                    </Order>
                  </Request>
                </Engine>
              </CnPAPI>
              </cfsavecontent>
              <cfscript> 
                  ws = CreateObject("webservice", "https://paas.cloud.clickandpledge.com/paymentservice.svc?wsdl"); 
                  ret = ws.operation("#soapBody#"); 
              </cfscript> 
               
              <cfset soapreq = GetSOAPRequest(ws)>  
              <h2>SOAP Request</h2> 
              <cfdump var="#soapreq#"> 
               
              <cfset soapresp = GetSOAPResponse(ws)> 
              <h2>SOAP Response</h2> 
              <cfdump var="#soapresp#"> 
              ...

              Comment


              • #8
                Great!

                Do you mind if we put this in our manual?
                Regards,
                Click & Pledge Support Department

                On Salesforce? Help us by rating our app: Click & Pledge Donor Management on AppExchange

                Join us @ the educational webinars: https://clickandpledge.com/webinars/
                Live Support available Join between 3:00 - 3:30 p.m. ET Monday - Thursday: https://clickandpledge.com/webinars/
                Are you on Salesforce? Join us at the Power of Us Hub: https://powerofus.force.com/0F980000000CjpC

                Comment


                • #9
                  Originally posted by Support.Department View Post
                  Great!

                  Do you mind if we put this in our manual?

                  Not at all. That's fine!

                  Comment

                  Working...
                  X