ZenPayPal 2-alpha

Hi, all.

I rewrite my code about zenpaypal plugin, in new version.
I attempt to use the "Paypal REST API PHP SDK".

I need to create a checkout php script receiving posted datas from the form html (wrote by function zenpaypal into zenPaypal.php script).

How to do it for running correctly with zenphoto, and my zenpaypal plugin?


  • acrylian Administrator
    Great, third party contributionsl like this are always very welcome.

    I don't know the paypal framework and what you specifially need to do with it. But via PHP you can generally check for POST/GET data directy in your main plugin file using

    `if(isset($_POST['your-paypal-form-stuff'`]) {`
    `//here whatever you need to do with the code - Don't forget to sanitize properly!`
    `exitZP(); // to avoid other plugin code being executed afterwards`

    If all can happen on page reload after submitting you can do that within a theme function of the plugin naturally. See for example the `printContactForm()` function from the contact_form plugin.

    Does that help? Or do you mean anything else?
  • ok, thank you.
    I see that! ;)
  • Hi...

    I've one problem, with my script.

    If i test as:


    $ php-7.0 -l zenpaypal.php

    No syntax errors detected in zenpaypal.php

    $ php-7.0 -l zenpaypal/class.ZenPayPal.php

    No syntax errors detected in zenpaypal/class.ZenPayPal.php


    But, when i upload my plugin, the zenphoto website is blank!
    When i delete my plugin, the website run correctly.
    One idea?

    My first lines code into zenpaypal.php:


    <?php<br />

    * zenPaypal -- PayPal ordering support


    * Provides a PayPal ordering form for image print ordering.


    * Price lists can also be passed as a parameter to the zenPaypal() function. See also

    * zenPaypalPricelistFromString() for parsing a string into the pricelist array. This could be used,

    * for instance, by storing a pricelist string in the 'customdata' field of your images and then parsing and

    * passing it in the zenPaypal() call. This would give you individual pricing by image.


    * @author Ebrahim Ezzy (Nimbuz) adapted as a plugin by Stephen Billard (sbillard)

    * modified by Stephane HUC (hucste)


    * @package plugins - divers



    define('ZPP', 'zenpaypal');

    // include class ZPP

    include(__DIR__ .'/'.ZPP.'/class.ZenPayPal.php');

    //include_once(__DIR__ .'/'.ZPP.'/PayPal-PHP-SDK/autoload.php');

    // here declarate new zenpaypal !

    $zenpaypal = new ZenPayPal();

    // needed variables for ZenPhoto

    $option_interface = 'zenPaypalOptions';

    $plugin_author = gettext('Ebrahim Ezzy (Nimbuz), adapted as a plugin by Stephen Billard (sbillard), modified by Stephane HUC (hucste).');

    $plugin_description = gettext('PayPal Integration');

    //$plugin_disable = (version_compare(PHP_VERSION, '5.0.0') != 1) ? gettext('PHP version 5 or greater is required.') : false;

    $plugin_is_filter = 5|ADMIN_PLUGIN|THEME_PLUGIN;

    $plugin_URL = 'https://framagit.org/hucste/ZenPayPal';

    $plugin_version = $zenpaypal->getPluginVersion();






  • acrylian Administrator
    Some observations and recommendations.
    • Best use lowercase file names to avoid accidental typos regarding the case. Same for variable names. Function and method names where the case doesn't matter use camelCase.
    • Include classes, functions and filter defines after the $plugin definition.
      Instead `include(__DIR__ .'/'.ZPP.'/class.ZenPayPal.php');` use
      `require_once(SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/zenpaypal/class.ZenPayPal.php');` Not sure if the define of the constant ZPP is really necessary.
    • if `$zenpaypal = new ZenPayPal();` is meant to be used as a global object variable name it accordingly like `$_zenpayapl` or even `$_zp_zenpaypal` (this is how globals should be named internally - sadly ZP does not do this consequently as well in some places ;-))
    • Additionally you zp_register_filter calls might not be correct. If these are not static functions it will not work. If these are methods of the class you have to use static methods like `zp_register_filter('admin_head', 'ZenPayPal::printCSS');`
    The blank page might of course also be caused by the code following that.
Sign In or Register to comment.