Bharat_Naik wrote on Dec 6
th, 2011 at 9:39pm:
This sounds really great. If one can login to PayPal site using cURL, I am sure any other sites also can be logged in and perform whatever interchange of data needed to be performed can be carried out. Erika, can you please give some concrete examples automatic login and carrying out exchange of data using cURL? Thanks.
cURL has a whole lot of flags to meet the demands of various API's and every SOAP API has its own specific structure, so most examples don't extrapolate very well. However, here is what I use to capture an authorized PayPal transaction.
FUNCTION hdsBuildDoCaptureRequest(aTrx as String, aAmt as String) as String
var vRet as String
vRet = "<soapenv:Envelope xmlns:soapenv=" + @CHR(34) + "http://schemas.xmlsoap.org/soap/envelope/" + @CHR(34)
+ " xmlns:urn=" + @CHR(34) + "urn:ebay:api:PayPalAPI" + @CHR(34)
+ " xmlns:urn1=" + @CHR(34) + "urn:ebay:apis:eBLBaseComponents" + @CHR(34) + ">
<soapenv:Header>
<urn:RequesterCredentials>
<urn1:Credentials>
<urn1:Username>" + SOAP_USER + "</urn1:Username>
<urn1:Password>" + SOAP_PASS + "</urn1:Password>
<urn1:Signature>" + SOAP_SIG + "</urn1:Signature>
</urn1:Credentials>
</urn:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<urn:DoCaptureReq>
<urn:DoCaptureRequest>
<urn1:Version>84.0</urn1:Version>
<urn:AuthorizationID>" + aTrx + "</urn:AuthorizationID>
<urn:Amount currencyID=" + @CHR(34) + "USD" + @CHR(34) + ">" + aAmt + "</urn:Amount>
<urn:CompleteType>NotComplete</urn:CompleteType>
</urn:DoCaptureRequest>
</urn:DoCaptureReq>
</soapenv:Body>
</soapenv:Envelope>"
Return(vRet)
END FUNCTION
var vResult as String
var vAck as String
var vCode as String
var vTrxId as String
var vTrxAmt as String
var vGrossAmt as String
var vFeeAmt as String
// ----------------- Do Capture -----------------
vTrxId = CaptureTrxId
vTrxAmt = CaptureTrxAmt
If ((vTrxId <> "") And (@ToNumber(vTrxAmt) > 0))
{
vTrxAmt = @Decimals(vTrxAmt, 2)
vCode = hdsBuildDoCaptureRequest(vTrxId, vTrxAmt)
vResult = @RedirectProcess(curl_command, vCode)
vAck = hdsPPSOAPErrHandler(vResult)
If vAck = "Success"
{
vGrossAmt = @RegexBetweenString(vResult, "<GrossAmount[^>]*>", "</GrossAmount>", 1, 0)
vFeeAmt = @RegexBetweenString(vResult, "<FeeAmount[^>]*>", "</FeeAmount>", 1, 0)
@MsgBox("***** CAPTURE SUCCESSFUL *****", "Gross Amt: $" + @Decimals(vGrossAmt, 2) + @Newline() + "Fee Amt: $" + @Decimals(vFeeAmt, 2) + @Newline() + "Net Amt: $" + @Decimals(@ToNumber(vGrossAmt) - @ToNumber(vFeeAmt), 2), "")
}
}
Note that the stuff in caps, like SOAP_SERVER, SOAP_USER, SOAP_SIG, and SOAP_PASS are defines that provide the account-specific credentials. curl_command is a static variable that is set to provide what PayPal wants in GLOBAL CODE to:
curl_command = "curl.exe -s -H " + @chr(34) + "Content-Type: text/xml; charset=utf-8 SOAPAction:" + @chr(34) + " --insecure -d @- -X POST " + @chr(34) + SOAP_SERVER + @chr(34)