Problems, need help? Have a tip or advice? Post it here.
17 posts Page 2 of 2
Hi,

The button can be coded manually - it is just a form.
What is more complex is processing the IPN that PayPal sends back.

Even if it is a service that you are creating the button for, you'll have to ask yourself if you need to validate the IPN before considering the transaction valid and taking any action?
If so, you can use the paypal_processer tag for doing this painlessly for you.

Suppose your service is named 'my service' has three pricing options - Platinum, Gold and Silver.
What you can do is create a template named, for example, my_service.php and define within it the pp_price editable region required by paypal_button. Place the paypal_processor tag in this template also. Make the template clonable and create three cloned pages -one for each pricing options. You can name the pages as my-service-platinum, my-service-gold etc. Fill the pricing for each page.

What we can now do is list the three pages in a table on any other page
Code: Select all
<cms:pages masterpage='my_service.php'>
   <h2>Option: <cms:show k_page_title /></h2>
   <h4>Pricing: <cms:show pp_price /></h4>
   <cms:paypal_button />
</cms:pages>

This way we can use the paypal_processor tag to validate every transaction.

Please let me know if this helps.
Hi,

I don't understand everything, one because my english is bad, two because I don't know the IPN system.

For memories, I use Ajax, so I have one page (one template). I use Ajax just to show or hide a part of the site.

For the moment I test using that:

HTML CODE (part of the site):
Code: Select all
<cms:editable name='Consultation' type='richtext'> Texte pour les consultations </cms:editable>
<span class="paypal montant_Min">
   <cms:editable name='pp_price' label='Prix question' desc='Somme En Euro (maximum 2 chiffres apr&egrave;s la virgule)'
      maxlength='10'
      search_type='decimal'
      validator='non_negative_decimal'
      type='text' />
</span>
<span class="paypal montant_Max">
   <cms:editable name='pp_price2' label='Prix consultation illimité' desc='Somme En Euro (maximum 2 chiffres apr&egrave;s la virgule)'
      maxlength='10'
      search_type='decimal'
      validator='non_negative_decimal'
      type='text' />
</span>
<span class="paypal_seller">
   <cms:editable name='pp_seller' label='Adresse de votre compte Paypal' desc=''
      validator='email'
      type='text' />
</span>
<cms:paypal_processor>
   <cms:if k_paypal_success>               
      <!-- All PayPal variables and variables of the item's page are available here -->
      <p class="success">
         Votre paiement a bien &eacute;t&eacute; pris en compte.
      </p>
   </cms:if>            
   <cms:if k_paypal_error>            
      <!-- All PayPal variables and the error message is available here -->
      <p class="error">
         Votre paiement a &eacute;chou&eacute;.
      </p>
   </cms:if>
</cms:paypal_processor>

The <span> are hide with Jquery and their values are save. After that I replace a little part of 'Consultation' by the formulaire paypal, always with jQuery.
The paypal button works easely, but the paypal_processor doesn't work.

I think it's because I don't call "<cms:paypal_button image='5' />", I'm right ?
Hi,

Are you testing on your localhost or a web host?
If you happen to be on a web host, can you send me over your FTP and Couch usernames/passwords? Let me login and see the situation first hand.
It's on a localhost.

But I give you the file with the important part of the code.

I try to clean the file better I can.

If you have some questions, go enven if in France, it's night ^^.

Attachments

Hi,

No answers, it smell vacancy :D

No problem, for me too. Maybe we can work again to 2011.

Merry Christmas and Happy New Yea
Hi dutom,

Sorry for the delay in reply but don't worry I am working on it.
You have used a rather unusual way to create the paypal button and it will need a little time to tackle it.

Have a merry Xmax and a happy new year :)
Hi,

From what I saw from your code, you are trying to use a single template to define two paypal items.

We'll have to make the following changes -
1. Create a new template (e.g. montant.php), create the pp_price editable field in it and declare it clonable.
2. Create two pages from the template mentioned above. Name the first page 'montant_Min' and the second 'montant_Max'. In the pp_price fields of each enter the price values.
3. Now on the index.php we'll create two paypal buttons representing the above two items. To do so use the following code -
Code: Select all
<div id="consultation" class="content">
   <cms:editable name='Consultation' type='richtext'> Texte pour les consultations </cms:editable>
   
   <!-- set return URL to whatever page you wish -->
   <cms:set my_url="<cms:show k_page_link />#consultation" />
   
   <!-- Create paypal buttons for min & max -->
   <cms:pages masterpage='montant.php' page_name='montant_Min, montant_Max'>
      <span class="paypal <cms:show k_page_name />">
         <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
            <input type="hidden" name="cmd" value="_xclick"/>
            <input type="hidden" name="business" value="<cms:php>echo K_PAYPAL_EMAIL; </cms:php>"/>
            <input type="hidden" name="item_name" value="<cms:show k_page_title />"/>
            <input type="hidden" name="item_number" value="<cms:show k_page_id />"/>
            <input type="hidden" name="amount" value="<cms:show pp_price />"/>
            <input type="hidden" name="undefined_quantity" value="1"/>
            <input type="hidden" name="no_shipping" value="1"/>
            <input type="hidden" name="no_note" value="1"/>
            <input type="hidden" name="currency_code" value="<cms:php>echo K_PAYPAL_CURRENCY; </cms:php>"/>
            <input type="hidden" name="rm" value="2"/>
            <input type="hidden" name="return" value="<cms:show my_url />"/>
            <input type="hidden" name="cancel_return" value="<cms:show my_url />"/>
            <input type="hidden" name="notify_url" value="<cms:show my_url />?paypal_ipn=1"/>
            <input type="image" border="0" alt="PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée!" name="submit" src="https://www.paypal.com/fr_FR/FR/i/btn/btn_paynow_LG.gif"/>
            <img width="1" height="1" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" alt=""/>
         </form>
      </span>
   </cms:pages>

   
   <cms:paypal_processor>
      <cms:if k_paypal_success>
         <!-- All PayPal variables and variables of the item's page are available here-->      
         <!-- email or log success -->
      </cms:if>
      <cms:if k_paypal_error>
         <!-- All PayPal variables and the error message is available here -->
         <!-- email or log failure-->
      </cms:if>
   </cms:paypal_processor>
</div>

What we are doing is using the pages tag to fetch the two pages we created and then use each page's data to create the buttons.

Please note:
paypal_processor works in the background, i.e. you will not see its output and you cannot be sure when paypal will call it with the notification. It is meant to do something like email or log and not to display anything.
17 posts Page 2 of 2
cron