Magento 2 - MasterCard Payment Gateway Services - magento

https://ontap.wiki/magento-mastercard-payment-gateway-services/
I added this extension on my website but trasaction is declined.
giving this response
'response' =>
array (
'error' =>
array (
'cause' => 'INVALID_REQUEST',
'explanation' => 'Value 'AUTHORIZE' is invalid. Authorization request not permitted for this merchant.',
'field' => 'apiOperation',
'validationType' => 'INVALID',
),
'result' => 'ERROR',
),
https://ontap.wiki/magento-mastercard-payment-gateway-services/
I added this extension on my website but trasaction is declined.
giving this response
'response' =>
array (
'error' =>
array (
'cause' => 'INVALID_REQUEST',
'explanation' => 'Value \'AUTHORIZE\' is invalid. Authorization request not permitted for this merchant.',
'field' => 'apiOperation',
'validationType' => 'INVALID',
),
'result' => 'ERROR',
),

Related

Telegram bot webhook returns user identifier id as null

I am working on a telegram bot and set up a webhook to store chat id of users into my laravel app's DB.
I was getting the chat id previously but today, I getting NULL.
I am using ngok for https to work with webhooks.
When webhook is deleted and I used /getUpdates method on telegram api, that time I am getting chat id, but I need to use webhook, this is my project's requirement.
array (
'update_id' => 995486499,
'message' =>
array (
'message_id' => 3,
'from' =>
array (
'id' => NULL, <----------- This message.from.id is NULL in webhook response
'is_bot' => false,
'first_name' => 'XXXX',
'last_name' => 'XXXX',
'username' => 'XXXX',
'language_code' => 'en',
),
'chat' =>
array (
'id' => NULL, <----------- This chat.id is NULL in webhook response
'first_name' => 'XXXX',
'last_name' => 'XXXX',
'username' => 'XXXX',
'type' => 'private',
),
'date' => 1629195470,
'text' => 'hello world',
),
)

Cakephp Data Validation: Checking if at least one field is populated and multiple rules not validating

Folks,
I'm trying to ensure at least one of two fields (last_name or email) is being populated. Each field also has multiple rules. I'm using CakePHP version 2.4.2.
The problem I have at the moment, after multiple permutations of updating and/or moving around the use 'last', 'allowEmpty', 'required', etc, is that the fields just aren't validating at all, or aren't executing all the rules when a field is populated.
Any advice on how to modify the code below to achieve the following behaviour is much appreciated:
1. One of the two fields must be populated;
2. The other rules attached to each field must validate as well (i.e. if a last name is passed, then it must be between 2 and 45 chars and alphanumeric only)
Here's the model code:
public $validate = array(
'last_name'=> array(
'needOne' => array (
'required' => FALSE,
'allowEmpty' => TRUE,
'last' => TRUE,
'rule' => array('checkOne','last_name'),
'message' => 'You must enter at least a contact name or email address.'
),
'alphaNumeric' => array(
'rule' => 'alphaNumeric',
'message' => 'Alphabets and numbers only'
),
'between' => array(
'rule' => array('between', 2, 45),
'message' => 'Between 2 to 45 characters'
)
),
'email' => array(
'needOne' => array (
'required' => FALSE,
'allowEmpty' => TRUE,
'last' => TRUE,
'rule' => array('checkOne','email'),
'message' => 'You must enter at least a contact name or email address.'
),
'emailAddress' => array (
'last' => TRUE,
'rule' => array('email', FALSE),
'message' => 'A valid Email address is required'
)
)
);
// Ensure at least the last name or email field value is provided
function checkOne($field) {
if(!empty($this->data[$this->User]['last_name']) ||
!empty($this->data[$this->User]['email'])){
return true;
} else {
return false;
}
}
Thanks in advance!
Thanks very much vicocamacho. I kept at it and, in addition to your advice, found the solution also lay in adding a 'required' => false in the view.
Here's the working solution for any one else with this problem:
The model:
public $validate = array(
'last_name'=> array(
'needOne' => array (
'rule' => 'checkOne',
'message' => 'You must enter at least a contact name or email address.'
),
'alphaNumeric' => array(
'rule' => 'alphaNumeric',
'message' => 'Alphabets and numbers only',
'allowEmpty' => TRUE
),
'between' => array(
'rule' => array('between', 2, 45),
'message' => 'Between 2 to 45 characters',
'allowEmpty' => TRUE
)
),
'email' => array(
'needOne' => array (
'rule' => 'checkOne',
'message' => 'You must enter at least a contact name or email address.'
),
'emailAddress' => array (
'rule' => 'email',
'message' => 'A valid Email address is required',
'allowEmpty' => TRUE
)
)
);
// Ensure at least the last name or email field value is provided
public function checkOne($data) {
if(!empty($this->data[$this->alias]['last_name'])
|| !empty($this->data[$this->alias]['email'])) {
return TRUE;
} else {
return FALSE;
}
}
The view/fields (I'm using Bootstrap):
echo $this->Form->input('last_name', array(
'required' => false,
'fieldset' => false,
'label' => false,
'before' => '<label class="control-label">Last Name <span class="one-required">*</span></label>',
'class' => 'form-control',
'placeholder' => 'Last Name',
'div' => 'form-group col-sm-12',
'error' => array(
'attributes' => array(
'wrap' => 'div',
'class' => 'alert alert-danger'
)
)
)
);
echo $this->Form->input('email', array(
'required' => false,
'fieldset' => false,
'label' => false,
'before' => '<label class="control-label">Email <span class="one-required">*</span></label>',
'after' => '',
'class' => 'form-control',
'div' => 'form-group col-sm-12 col-xs-12',
'error' => array(
'attributes' => array(
'wrap' => 'div',
'class' => 'alert alert-danger'
)
)
)
);
Thanks.
Write a custom rule that will check if one of both fields is not empty and use that rule on both fields. And set allowEmpty to true for the other rules.
You should allowEmpty in all the rules that do not check if the fields are present, i updated your code so you can see what i mean, also you need to change the $this->User index in your checkOne to $this->alias otherwise it will always return false:
public $validate = array(
'last_name'=> array(
'alphaNumeric' => array(
'rule' => 'alphaNumeric',
'message' => 'Alphabets and numbers only',
'allowEmpty' => true
),
'between' => array(
'rule' => array('between', 2, 45),
'message' => 'Between 2 to 45 characters',
'allowEmpty' => true
)
),
'email' => array(
'needOne' => array (
'rule' => 'checkOne',
'message' => 'You must enter at least a contact name or email address.'
),
'emailAddress' => array (
'allowEmpty' => true,
'rule' => 'email',
'message' => 'A valid Email address is required'
)
)
);
// Ensure at least the last name or email field value is provided
function checkOne($field) {
if(
!empty($this->data[$this->alias]['last_name']) ||
!empty($this->data[$this->alias]['email'])
)
{
return true;
} else {
return false;
}
}

Cakephp Form Validation empty indeces

Okay, so, in short, I'm trying to validate a form, as I've done a million times before with no trouble. However, I'm finding that on logging the validation errors, all the invalidated fields have an index in the validationErrors array but the messages are empty.
Yes, I've definitely set the validation messages in the model so I'm unsure why it's empty.
Here are my model validations:
public $validate = array(
'effective_policy_date' => array(
'date' => array(
'rule' => array('date'),
'message' => 'Invalid date format',
),
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Policy date required',
),
),
'business_address' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Business address required',
),
),
'city' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'City required',
),
),
'zip_code' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Zip code required',
),
),
'state_id' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'State required',
),
),
'contact_person' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Contact person required',
),
),
'phone' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Phone number required',
),
),
'email' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => 'Email address required',
),
'email' => array(
'rule' => array('email'),
'message' => 'Invalid email format',
),
),
);
Here's the output of the validationErrors array after submitting the form with empty fields:
[AccountsRequest] => Array
(
[effective_policy_date] => Array
(
)
[policy_number_one] => Array
(
)
[policy_number_two] => Array
(
)
[policy_number_three] => Array
(
)
[policy_number_four] => Array
(
)
[business_address] => Array
(
)
[city] => Array
(
)
[zip_code] => Array
(
)
[state_id] => Array
(
)
)
For completeness sake, here's my Form->create array I use in the view and the controller action responsible for handling the form submission:
Form create() method
<?php
echo $this->Form->create(
'Request',
array(
'novalidate' => 'novalidate',
'action' => 'new_request',
'inputDefaults' => array(
'label' => false,
'div' => false,
'error' => array(
'attributes' => array(
'wrap' => 'label', 'class' => 'error'
)
)
)
)
);
?>
Controller action
public function new_request()
{
$this->page_id = 'requester_newform';
if($this->request->is('post'))
{
if($this->Request->saveAll($this->request->data, array('deep' => true, 'validate' => 'only')))
{
$this->Session->setFlash('Request saved successfully', 'flash/success');
}
else
{
$this->Session->setFlash('Could not save request. Please correct validation errors', 'flash/error');
}
}
}
You'll see some indeces in the validation array that aren't in the validationErrors, that's simply because I haven't quite finished converting the raw HTML to CakePHP forms.
Problem: The validationErrors array shouldn't be empty. It should contain the messages for the notEmpty rules and as a result there are empty error validation elements on the Form's frontend. Any ideas about what I'm doing wrong?
Aarg, how annoying. I've figured it out and it's a lesson well learnt.
For anyone having a similar issue in the future, make sure that your input fields conform to the relationships of the current form's Model.
For instance, in this example, my form's model is 'Request'. Request hasMany 'AccountsRequest'. So my form inputs were something like:
AccountsRequest.effective_policy_date
where it should have been
AccountsRequest.0.effective_policy_date
With this change, my model validation messages are now showing without issue.
I'd still love to know, however, why CakePHP even picked up those fields as invalid and further, if it was intelligent enough to pick up those fields as invalid why it didn't give me validation messages.
Oh well.....

Zend2: Limiting e-mail validation to only one error message?

I have the following validation setup for an email field:
$inputFilter->add($factory->createInput(array(
'name' => 'email',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 255,
),
),
array(
'name' => 'EmailAddress',
'options' => array(
'messages' => array(
\Zend\Validator\EmailAddress::INVALID_HOSTNAME => 'You did not enter a valid e-mail address.'
),
),
)
),
)));
The problem is that if I type in something like: "bla#bla", I get the following triggered errors:
You did not enter a valid e-mail address.
The input does not match the expected structure for a DNS hostname
The input appears to be a local network name but local network names are not allowed
It's way too tedious to do this:
array(
'name' => 'EmailAddress',
'options' => array(
'messages' => array(
\Zend\Validator\EmailAddress::INVALID => 'You did not enter a valid e-mail address.' ,
\Zend\Validator\EmailAddress::INVALID_FORMAT => 'You did not enter a valid e-mail address.' ,
\Zend\Validator\EmailAddress::INVALID_HOSTNAME => 'You did not enter a valid e-mail address.' ,
\Zend\Validator\EmailAddress::INVALID_LOCAL_PART => 'You did not enter a valid e-mail address.' ,
\Zend\Validator\EmailAddress::INVALID_MX_RECORD => 'You did not enter a valid e-mail address.' ,
\Zend\Validator\EmailAddress::INVALID_SEGMENT => 'You did not enter a valid e-mail address.' ,
),
),
)
Is there no better way to do this?
UPDATE
Also, this doesn't work. I still end up with:
You did not enter a valid e-mail address.
The input does not match the expected structure for a DNS hostname
The input appears to be a local network name but local network names are not allowed
Any thoughts?
Calling setMessage on the validator without a second parameter will set all the messages:
$email = $factory->createInput(array(
'name' => 'email',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 255,
),
)
),
));
$emailValidate = new Zend_Validate_EmailAddress();
$emailValidate->setMessage('You did not enter a valid e-mail address.');
$email->addValidator($emailValidate, TRUE);
$inputFilter->add($email);
Not sure if the following also works, but you could give it a try:
array(
'name' => 'EmailAddress',
'options' => array(
'message' => 'You did not enter a valid e-mail address.'
),
)
The solution to the problem is as follows:
'message' => array(
\Zend\Validator\EmailAddress::INVALID_HOSTNAME=>'Email WRONG!',
),

ZF2 Doctrine2 Pagination Cache

Does anybody of you know how to configure cache for zf2 pagination using doctrine2?
The way i dot it:
$cache = \Zend\Cache\StorageFactory::factory (
array (
'adapter' => array (
'name' => 'Filesystem',
'options' => array (
'ttl' => 10,
'cache_dir' =>__DIR__.'/../../../data/cache/',
),
'plugins' => array (
'serializer' => array(
'serializer' => 'igbinary'
)
)
)
) );
return $cache;
But i get Exceptions like the following.
\Zend\Cache\Storage\Adapter\Filesystem.php:1549
Message:
fwrite() expects parameter 2 to be string, object given
\Zend\Cache\Storage\Adapter\Filesystem.php:1553
Message:
Error writing file '...\data\cache\zfcache-c0\zfcache-Zend_Paginator_2_722b98872575050f0443b2b626605650.dat'
\Zend\Paginator\Paginator.php:637
Message:
Error producing an iterator
The nesting was incorrect:
$cache = \Zend\Cache\StorageFactory::factory( array(
'adapter' => array(
'name' => 'Filesystem',
'options' => array (
'ttl' => 10,
'cache_dir' =>__DIR__.'/../../../data/cache/',
),
),
'plugins' => array (
'serializer' => array(
'serializer' => 'igbinary'
)
)
) );
return $cache;

Resources