In Flow: The Mura Blog

How to: Mura and Paypal

This is a quick overview of how the Marketplace connects to PayPal.

1) We used the standard shopping cart display object from Mura.
This involved creating a custom template for the Marketplace that contains this form:

<form action="/index.cfm/marketplace/your-cart/" method="post" name="ProductDetails">
    <input type="hidden" name="quantity" value="1" />
    <input type="hidden" name="item_name" value="#request.contentbean.getvalue('productname')#" />
    <input type="hidden" name="item_number" value="#request.contentbean.getvalue('productid')#" />
    <input type="hidden" name="amount" value="#request.contentbean.getvalue('price')#" />
    <input type="hidden" name="doaction" value="addToCart" />
    <input type="submit" name="Add to Cart" value="Add to Cart" />

The form values are populated by extended attributes that have been set up in the Mura admin.  We created a custom type called "Plug-in" that uses the "Page" type as it's base attribute set.

The form posts to /index.cfm/marketplace/your-cart.  This page has the Mura PayPal shopping cart display object assigned.  This is basically where the cart lives.

2) At this point, the user would add a Plug-In to his or her cart and checkout through PayPal.  After the sale has been completed, PayPal sends the user back using the auto return url, which points here:

3) When the user is returned to, the code calls back out to PayPal with the PayPal provided transactionID to get the payment details using the code below:

<cfhttp url="" method="post" name="results">
    <cfhttpparam name="cmd" value="_notify-synch" type="formfield">
    <cfhttpparam name="tx" value="#url.tx#" type="formfield">
    <cfhttpparam name="at" value="XXXX" type="formfield">

<cfdump var="#results.columnList#">

If the transaction was a success, then the user's cart is verified against the purchase list and displayed the appropriate download link using the code below:

<cfif results.columnList contains "SUCCESS">
    <cfquery name="rsPluginList" datasource="#application.configBean.getDatasource()#" username="#application.configBean.getDBUsername()#" password="#application.configBean.getDBPassword()#">
        select d.baseID, d.attributeValue as pluginID from tcontent c
        inner join tclassextenddata d on c.contentHistID = d.baseID
        where c.subType = 'plug-in' and = 1 and d.attributeID = 11

    <cfset ppItemNumbers = "">
    <cfloop query="results">
        <cfif success contains "item_number">
            <cfset ppItemNumbers = listAppend(ppItemNumbers, right(success, 6))>
    <cfset getCart = session.cart.List()>
    <cfset s3 = createObject("component","mura.content.file.s3").init(
    <h3>Thank You</h3>
    <p>Thank you for your payment. Your transaction has been completed, and a receipt for your purchase
    has been emailed to you. You may log into your account at to view details of this transaction.</p>
    <p>Please note that the download link will expire in 24 hours.</p>
    <!--- Display link here --->
    <p>An error occured getting information from the payment gateway.  If you need assistance, please contact us using our contact form.</p>