I am trying to stay away from the deprecated parameters in the paypal api
call to method SetExpressCheckout.

I am getting this error with the wall:
Order total is missing.
L_ERRORCODE0=10400

But I am passing "PAYMENTREQUEST_0_AMT" which should replace
AMT(deprecated).

If I add AMT, the call goes through, but when I continue to paypal, I don't
get any item details.


<cffunction access="public" name="set_express_checkout" output="no"
returntype="struct">
        <cfargument name="app_user_id" type="numeric" required="yes">
        <cfargument name="live_or_sandbox" required="yes" type="string">
        <cfargument name="add_insurance" required="yes" type="string">
        <cfobject component="redhotkittiescfcs.qry" name="qry" />
        <cfset qry_paypallock_get = qry.qry_paypallock_get(
app_user_id="#arguments.app_user_id#") />
        <cfobject component="redhotkittiescfcs.paypal" name="paypal">
        <cfset paypal_enviroment = structnew()>
        <cfset paypal_enviroment = paypal.select_enviroment( live_or_sandbox
= "#arguments.live_or_sandbox#" ) />
        <cfset variables.shipping_cost = 5.00>
        <cfif arguments.add_insurance>
            <cfset variables.insuranceamt = 2.00>
        <cfelse>
            <cfset variables.insuranceamt = 0>
        </cfif>
        <cfhttp method="get" url="#paypal_enviroment.api_url#"
throwonerror="yes">
            <cfhttpparam type="url" name="user"
value="#paypal_enviroment.api_user#">
            <cfhttpparam type="url" name="pwd"
value="#paypal_enviroment.api_pwd#">
            <cfhttpparam type="url" name="signature"
value="#paypal_enviroment.api_signature#">
            <cfhttpparam type="url" name="returnurl"
value="#paypal_enviroment.return_url#">
            <cfhttpparam type="url" name="cancelurl"
value="#paypal_enviroment.cancel_url#">
            <cfhttpparam type="url" name="method"
value="SetExpressCheckout">
            <cfhttpparam type="url" name="PAYMENTREQUEST_0_PAYMENTACTION"
value="Sale">
            <cfhttpparam type="url" name="PAYMENTREQUEST_0_CURRENCYCODE"
value="USD">
            <cfhttpparam type="url" name="allownote" value="1">
            <cfhttpparam type="url" name="version" value="60.0">
            <cfhttpparam type="url" name="noshipping" value="2">
            <cfhttpparam type="url" name="PAYMENTREQUEST_0_SHIPPINGAMT"
value="#numberformat( variables.shipping_cost, "9999.99" )#">
            <cfif arguments.add_insurance>
                <cfhttpparam type="url"
name="PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED" value="true">
                <cfhttpparam type="url" name="PAYMENTREQUEST_0_INSURANCEAMT"
value="#numberformat( variables.insuranceamt, "9999.99" )#">
            </cfif>
            <cfset variables.item_total = 0>
            <cfloop query="qry_paypallock_get">
                <cfset variables.item_total = variables.item_total + (
qry_paypallock_get.unitprice * qry_paypallock_get.quantity )>
                <cfset variables.paypal_item_row =
qry_paypallock_get.currentrow - 1>
                <cfhttpparam type="url"
name="L_PAYMENTREQUEST_0_NAME#variables.paypal_item_row#" value="#
qry_paypallock_get.name#">
                <cfhttpparam type="url"
name="L_PAYMENTREQUEST_0_NUMBER#variables.paypal_item_row#"
value="#qry_paypallock_get.tblproductsfk#">
                <cfhttpparam type="url"
name="L_PAYMENTREQUEST_0_DESC#variables.paypal_item_row#"
value="#qry_paypallock_get.shortdescription#">
                <cfhttpparam type="url"
name="L_PAYMENTREQUEST_0_AMT#variables.paypal_item_row#"
value="#numberformat(qry_paypallock_get.unitprice, "9999.99" )#">
                <cfhttpparam type="url"
name="L_PAYMENTREQUEST_0_QTY#variables.paypal_item_row#"
value="#qry_paypallock_get.quantity#">
            </cfloop>
            <cfhttpparam type="url" name="PAYMENTREQUEST_0_ITEMAMT"
value="#numberformat( variables.item_total, "9999.99" )#">
            <cfset variables.order_total = variables.item_total +
variables.shipping_cost + variables.insuranceamt>
            <cfhttpparam type="url" name="PAYMENTREQUEST_0_AMT"
value="#numberformat( variables.order_total, "9999.99" )#">
        </cfhttp>
        <cfset variables.response_code = paypal.save_express_checkout(
api_response="#cfhttp.FileContent#" )>
        <!--- this portion adds the required vars for paypal link creation
--->
        <cfset variables.response_code.amt = numberformat(
variables.order_total, "9999.99" )>
        <cfset variables.response_code.currency_code = "USD">
        <cfset variables.response_code.return_url =
paypal_enviroment.return_url>
        <cfset variables.response_code.cancel_url =
paypal_enviroment.cancel_url>
        <cfreturn variables.response_code>
    </cffunction>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334587
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to