Jump to content
  • 0

Error Checking For Array


Question

Posted

Hello,

 

I'm trying to create a custom non-merchant payment gateway which can accept multiple payment method,

and I would like to control which payment method it uses.

 

I created a form which pass an array value of the payment method,

but upon passing it to the error checking, I always get

Undefined index: value on line 820 in {BLESTA}/components/record/record.php

it only occurs when the error checking passes (true value)

 

metas:

Array
(
    [merchant_id] => mercID
    [server_key] => servKey
    [client_key] => clientKey
    [acceptable_payment_type] => Array
        (
            [0] => cc
            [1] => transfer
        )

    [currencies] => Array
        (
            [0] => IDR
        )

)

and this causes the error message: (whenever the value is true)

$rules = array(
            'acceptable_payment_type' => array(
                'valid' => array(
                    'rule' => true,
                    'message' => "Payment type invalid"
                )
            )
        );

settings.pdt:

<?php
                        foreach($acceptablePayment as $ap) {
                            print "<li>";
                            $this->Form->fieldCheckbox("acceptable_payment_type[]", $ap, true, array('id'=>"acceptable_payment_type[]"));
                            print $this->_("test.payment_type_".$ap, true);
                            print "</li>";
                           
                        }
            ?>

1 answer to this question

Recommended Posts

  • 0
Posted
  On 10/26/2015 at 9:35 AM, eldzee said:

I created a form which pass an array value of the payment method,

but upon passing it to the error checking, I always get

Undefined index: value on line 820 in {BLESTA}/components/record/record.php

and this causes the error message: (whenever the value is true)

$rules = array(
            'acceptable_payment_type' => array(
                'valid' => array(
                    'rule' => true,
                    'message' => "Payment type invalid"
                )
            )
        );

 

You're not able to save the meta data for the gateway because the acceptable_payment_type is in an invalid format (i.e. an array). The system does not automatically serialize array data for storage with gateway meta like it does for modules, so you will need to serialize and unserialize it yourself.

$rules = array(
            'acceptable_payment_type' => array(
                'valid' => array(
                    'rule' => true,
                    'message' => "Payment type invalid",
                    'post_format' => array("serialize")
                )
            )
        );

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...