Help for payment plugin

Discussion in 'aMember Pro v.4' started by fmagusto, Dec 21, 2011.

  1. fmagusto

    fmagusto Guest

    Hello, i have a error with my my plugin payment

    Request not handled - createTransaction() returned null

    have you a idéa ?

    Frédéric
  2. gregatbizop

    gregatbizop Member

    Joined:
    Nov 3, 2011
    Messages:
    33
    Which plugin? paypal, plimus,2co?
  3. fmagusto

    fmagusto Guest

    Which a plugin plims modified for my CB systeme

    class Am_Paysystem_Transaction_Plimus2 extends Am_Paysystem_Transaction_Incoming{

    public function findInvoiceId(){
    return $this->request->get('custom1');

    }
    public function getUniqId() {
    return $this->request->get("ref");

    }

    public function validateSource() {
    // there must be some code to validate if IPN came from payment system, and not from a "hacker"
    return true;
    }

    public function validateStatus() {
    // there must be code to check post variables and confirm that the post indicates successful payment transaction
    return true;
    }

    public function validateTerms() {
    // compare our invoice payment settings, and what payment system handled
    // if there is difference, it is possible that redirect url was modified
    // before payment

    //$invoice->first_total=$invoice->first_total*100;
    //return ($this->request->get('montant') == $this->invoice->first_total);
    return true;
    }


    }
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Please paste your entire plugin source code.
    Put
    Code:
    [php]
    ....
    [/php]
    around your code for formatting.

    In short, you have to implement createTransaction() method in your payment plugin to return a transaction object.
  5. fmagusto

    fmagusto Guest

    PHP:
    <?php

    class Am_Paysystem_Plimus2 extends Am_Paysystem_Abstract {
    const 
    PLUGIN_STATUS self::STATUS_DEV;
    const 
    PLUGIN_REVISION '4.1.6.07372be';
    protected 
    $defaultTitle 'Paybox2';
    protected 
    $defaultDescription 'Carte bancaire sécurisée';
    const 
    URL "[URL]http://www.xxxxxxx.cgi[/URL]";
    const 
    TESTING_URL "[URL]http://www.xxxxxxx.cgi[/URL]";
    const 
    MODE_LIVE 'live';
    const 
    MODE_SANDBOX 'sandbox';
    const 
    MODE_TEST 'test';

    public function 
    _initSetupForm(Am_Form_Setup $form) {
    $s $form->addSelect("testing")
    ->
    setLabel("test Mode Enabled");
    $s->addOption("Live account"self::MODE_LIVE);
    $s->addOption("Sandbox account"self::MODE_SANDBOX);
    // $s->addOption("Account in test mode", self::MODE_TEST);
    }

    public function 
    getSupportedCurrencies()
    {
    return array(
    'EUR');
    }

    public function 
    init()
    {
    parent::init();
    $this->getDi()->billingPlanTable->customFields()
    ->
    add(new Am_CustomFieldText('plimus_contract_id'"Plimus Contract ID",
    "You must enter the contract id of Plimus product.<br/>Plimus contract must have the same settings as amember product."));
    }
    public function 
    _process(Invoice $invoiceAm_Request $requestAm_Paysystem_Result $result)
    {
    $a = new Am_Paysystem_Action_Redirect((($this->getConfig('testing')==self::MODE_SANDBOX) ? self::TESTING_URL self::URL));
    $a->contract_id $invoice->getItem(0)->getBillingPlanData("plimus_contract_id");
    $a->custom1 $invoice->public_id;
    $a->member_id $invoice->user_id;
    $a->currency $this->getCurrencyCode();
    $a->Nom$invoice->getFirstName();
    $a->Prénom $invoice->getLastName();
    $a->PBX_PORTEUR $invoice->getEmail();
    $a->PBX_MODE "1";
    $a->PBX_SITE "xxxxx";
    $a->PBX_RANG "01";
    $a->PBX_IDENTIFIANT "xxxxxx";
    $invoice->first_total=$invoice->first_total*100;
    $a->PBX_TOTAL $invoice->first_total;
    $a->PBX_WAIT "0";
    $a->PBX_DEVISE "978";
    $a->PBX_CMD "custom1:$a->custom1";
    $a->PBX_RETOUR "montant:M;ref:R;auto:A;trans:T;numabo:B,datefin:D;tes:K;custom1:$a->custom1;nom:$a->Nom;prenom:$a->Prénom;obj:$a->member_id;obj2";
    $a->PBX_EFFECTUE "[URL]http://www.xxxxxx/plimus2/ipn[/URL]";
    $a->PBX_REFUSE "[URL]http://www.xxxxxr[/URL]";
    $a->PBX_ANNULE "$this->getCancelUrl()";
    $a->filterEmpty();
    $result->setAction($a);
    }

    public function 
    createTransaction(Am_Request $requestZend_Controller_Response_Http $response, array $invokeArgs) {
    switch(
    $request->get("transactionType")){
    }
    }

    function 
    getCurrencyCode()
    {
    return 
    strtoupper($this->invoice->currency);
    }
    // let aMember know how this plugin is going to deal with recurring payments
    public function getRecurringType()
    {
    return 
    self::REPORTS_EOT;
    }
     
    function 
    getReadme(){
    return <<<CUT
    Ici le texte pour décrire l'explication de paiement
    CUT;
    }
    }

    class 
    Am_Paysystem_Transaction_Plimus2 extends Am_Paysystem_Transaction_Incoming{

    public function 
    findInvoiceId(){
    return 
    $this->request->getFiltered('custom1');

    }
    public function 
    getUniqId() {
    return 
    $this->request->get("ref");
      
    }

    public function 
    validateSource() {
    // there must be some code to validate if IPN came from payment system, and not from a "hacker"
    return true;
    }

    public function 
    validateStatus() {
    // there must be code to check post variables and confirm that the post indicates successful payment transaction
    return true;
    }

    public function 
    validateTerms() {
    // compare our invoice payment settings, and what payment system handled
    // if there is difference, it is possible that redirect url was modified
    // before payment

    //$invoice->first_total=$invoice->first_total*100;
    //return ($this->request->get('montant') == $this->invoice->first_total);
    return true;
    }
     
    }
     
    ?>
  6. fmagusto

    fmagusto Guest

    And the link in return

    /plimus2/ipn?custom1=421N5&psReceipt=dd&montant=18500&ref=3335&auto=032651&trans=351185110&numabo:B,datefin=1404&tes=TA4dgMQpfJml7LE9pQjklHHq4QeC%2BDoYF30Uu%2Bb%2FnRiYQgqKudxppFTLvKD1s%2BZbtNjxHMxn99q
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Replace
    public function createTransaction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) {
    switch($request->get("transactionType")){
    }
    }

    to:

    public function createTransaction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) {
    return new Am_Paysystem_Transaction_Plimus2($this, $request, $response, $invokeArgs);
    }
  8. fmagusto

    fmagusto Guest

    Thx Alex.

    But now, when i return in site, i have a blanck page. But for the payment is OK Now
  9. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I guess this parameter $a->PBX_EFFECTUE = "http://www.xxxxxx/plimus2/ipn"; is used as return url by your payment system and not as hidden postback. If there is no special parameter for hidden postback, add redirect to thanks page after postback will be processed.
    For example in process validated method:
    PHP:
        public function processValidated()
        {
            
    $this->invoice->addPayment($this);
            
    Am_Controller::redirectLocation($this->getPlugin()->getReturnUrl());
        }
  10. fmagusto

    fmagusto Guest

    When i add this i have
    Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /home/infoconc/www/amember/application/default/plugins/payment/plimus2.php on line 118
  11. fmagusto

    fmagusto Guest

    for the getReturnUrl() where is declared ?
  12. fmagusto

    fmagusto Guest

    i have testing with :
    public function processValidated() {
    Am_Controller::redirectLocation($this->request->get("ret"));


    }

    ret = http://www.ypurssite.com
    and i have
    Fatal error: Class '��������Am_Controller' not found in /home/infoconc/www/amember/application/default/plugins/payment/plimus2.php on line 121
  13. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Dear fmagusto,
    I believe it is better to hire a PHP programmer to do the job. I do not think we can debug a script via forum.

    P.S. Regarding last problem - there are not-printable chars in your PHP source code before Am_Controller.
  14. fmagusto

    fmagusto Guest

    Sorry alex, it s ok. Finaly it s just the space (i work in mac) and in linux, the space is not egal.

    Thx, the pluggin work.

Share This Page