chthread
I'm trying to create an application that checks the status of recurring subscriptions with authorize.net. To check subscriptions with auth.net, you must send an xml file with your content - For example.
<?xml version="1.0" encoding="utf-8"?> <ARBGetSubscriptionStatusRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>mytestacct</name> <transactionKey>112223344</transactionKey> </merchantAuthentication> <refId>Sample</refId> <subscriptionId>100748</subscriptionId> </ARBGetSubscriptionStatusRequest> |
Then, you receive an xml response. I can make this application work the following code below, but any more than 30 subscriptions, the application will timeout. I heard that if you use cfthread you can avoid timeout. I read the documentation but don't get how you integrate it when you are sending data such as xml and requesting data. Any ideas would be great.
<cfloop from="1" to="#query.RecordCount#" index="i">
<cfoutput>
<cfsavecontent variable="strXML">
<?xml version="1.0" encoding="utf-8"?>
<ARBGetSubscriptionStatusRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>#LoginID#</name>
<transactionKey>#TransactionKey#</transactionKey>
</merchantAuthentication>
<refId>#PolicyNumber#</refId>
<subscriptionId>#SubID#</subscriptionId>
</ARBGetSubscriptionStatusRequest>
</cfsavecontent>
<cfhttp url="https://api.authorize.net/xml/v1/request.api" method="POST" >
<cfhttpparam type="XML" value="#strXML.Trim()#"/>
</cfhttp>
</cfoutput>
<!--- Output the return message. --->
<cfoutput>
<cfset xmlDoc = XmlParse(#cfhttp.FileContent#)>
<cfset refID="#xmlDoc.xmlroot.refID.XmlText#">
<cfset ResponseCode="#xmlDoc.xmlroot.messages.resultCode.XmlText#">
<cfset Message="#xmlDoc.Xmlroot.messages.message.code.XmlText#">
<cfset MessageTxt="#xmlDoc.Xmlroot.messages.message.text.XmlText#">
<cfset Status="#xmlDoc.Xmlroot.status.XmlText#">
<cfset SubId="#refID#, #ResponseCode#, #Message#, #MessageTxt#, #Status#">
<p>The result is:<br />
#SubID#</p>
</cfoutput>
</cfloop>
