Jump to content
  • 0

Error Checking For Array


eldzee

Question

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>";
                           
                        }
            ?>
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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")
                )
            )
        );
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...