Opayo returning 5080 - opayo

Has anyone called OPAYO via curl? I am getting a 5080 and I have no idea why
$postArray = [
'VPSProtocol' => '4.00',
'TxType' => 'Payment',
'vendor' => 'rusticstone',
'Crypt' => $Crypt
];
$postBody = json_encode($postArray);
$curl = curl_init();
curl_setopt_array($curl, array(
//CURLOPT_URL => "https://test.sagepay.com/gateway/service/vspform-register.vsp",
CURLOPT_URL => "https://live.sagepay.com/gateway/service/vspform-register.vsp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $postBody,
CURLOPT_HTTPHEADER => array(
"Authorization: Basic " . $auth,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
));
I have just tried it using a form instead and it worked
$postBody is
{"VPSProtocol":"4.00","TxType":"Payment","vendor":"rusticstone","Crypt":"#15A496D03676639B8E842F7214455E71D22977384A358F34168CCF52C587AEE4BAB43463991678E55604A91976F88E700FA67CE64BDCCC2CB921B00AAB2A343792D4621FDF77AB542F2E46171F7F611073AE80CB79F587E8B3DD5F4133CE213F1B4AACBDE3B57F8A68238486E2EFE3C4A12234D60477F98212D595D72A42BB4D5181BCDB54627067B152A75F665F3120518D5157DB85976BD2FA0795FE0086D464A59EFB8E68BAB295A48F175519FFEF51611C1897F62888A73C3D1ECE181657FD267B8B28DA91B7D0D0BD58832B4866596D4B6630E7F1E961A1F281A1318DB3FB450DC4FB38C2E82AF2205F94601FDAC769471ADDFF1B01CD950FE54FA2D3DDAEF0388292B68617DC2FF04DF38BF4D5AF40FB0C2F52F095C3EA9539F2DC85DBCFAC572ED6E364D429984B6FE8EF00BFEBA590E8E81C4B277361D48E873DA90CBA3675D17AD6180B325294D542CA03A5C9E0FFEFC14C455E8BBFDEC9CF36FED346F21F4C3085217F8CCD13A8A211328295EDC697083D8E718AF0E4ED1602453A69E3211A379210D64A86D1FB19FE9F6D67A4A05079830A2CA1B2160E8CF3ACE2005A29FC1CC20B7FC7CCB4FB234781DA0C979502CC1E441FB0BCC7A6D062D96EC9B4DF6486CEE3E5B24B8099400D75C74EDC7EAD80A9690A0991D4C4B04FE78CCBB8A4F91CE643727EA46AC87840A42E98B06D766E9FCF25058EDACC1E7C71415A19CE5C235D85BF08F0D64A2763E372DD0D7164338616F98A1EB93D1EB22D959F3B333C48DBD0B392FB53096A5A9CE822E110BED1533738C0BA191281C9DD6E600812D01EABC543EB0CCBF2DEE2B4A58A40680DFF434608846B81E3DEB85B56CD81FA956713D0E18F9BE05D9CBF768C400A886BCC00738B784386851DA869CBADFB719DD0ADE084E75754404097B99D62A5F843FA168E4979716F7A6229558221EB5EB1013B3C290CEB2DB2E9FF612711281600FCFE19DB5CBE97629432FDA0AAA57FCABF72990CB1127A6EC4124897DB68E2C9FC1977FF5023EB29B693393D22AB79A2FD1BC8244F869AD6A2A0F9E9DF43A974D1892D8FDDD071D5A1159D5D45ED5B328F0E0CF9177744FA1F85B4A6D8231B967A7B87C8140A7B32AA02814BDB2AE2B1BAF00DF953F8F3D1C5F0EF2E96CF83940B49821C1BD7267B9FA450BC32188DCF03ED92A9ACA9D2CC3240F5963E01475E9B4A87E5029E61B6A335E1E087C7D48E91C5B82F1D89EC1F5F9C44D5099EC156972B0C9E21755630F209EC7E0FC1EF9BE526906896EABE6933ED4146D10CAB95BDDC93B6A04CA68AD6DE6292D63516506EF61E21FD7490AEEF76AC4649B4D005408A20ADA6E3A29B68D54F0FDBE35BA6F0D8D294C465C89F8CBAA0571E5A1CFD4371B7AC0D396C97E9216E04
Thanks

Related

How to Upload Products Image in zoho Inventory using postman

This code is working fine to uopload image in Zoho Inventory
*You can Used this code to upload image in zoho inventory.
Item id*
authtoken*
organization_id*
PHP Curl code
'https://inventory.zoho.com/api/v1/items//image?authtoken=xxxxxxx&organization_id=xxxxxxx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('/C:/Users/shobh/OneDrive/Pictures/WE\'RE HIRING (1).png')),
CURLOPT_HTTPHEADER => array(
'Authorization: Zoho-oauthtoken xxxxxxxxx',
'Cookie: xxxxxxx'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
*Response*
[enter image description here][1]
[1]: https://i.stack.imgur.com/jsKoV.png

orderby not working on wordpress

I trying to order by this values by a custom field (motor) and this is not working. Can you help me? I use acf to create the custom field. And when I do a var_dump it doesn't recognize the order by the parameter.
$args='';
$args = array(
'post_type' => 'grupoelectrogeno',
'post_status' => 'publish',
'posts_per_page' => '100',
'meta_query' => array(
array(
'key' => 'potencia_continua',
'value' => $postpotencia,
'compare' => 'like'
),
array(
'key' => 'motor',
'value' => $postmotor,
'compare' => 'like'
),
array(
'key' => 'version',
'value' => $postversion,
'compare' => 'like'
),
array(
'key' => 'gama',
'value' => 'industrial',
'compare' => 'like'
),
'orderby' => 'motor',
'order'=>'desc',
),
);

Drupal 8 add ajax form element after ajax callback

I am building a drupal form with multiple ajax enabled form elements.
I have one select list that does an ajax callback after change. The problem is that it adds a new select list to the page, which is also ajax enabled. This does not seem to work, which seems logical to me because the ajax is actually bundled an added to the page so it is lost in the replacecommand.
Is there anyone experienced with this, and does anyone have a solution ?
This is my code
/**
* {#inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form['city'] = [
'#type' => 'select',
'#title' => $this->t('Station'),
'#description' => $this->t('City'),
'#options' => array(
'Aalst' => $this->t('Aalst'),
'Brussel' => $this->t('Brussel'),
'Hasselt' => $this->t('Hasselt'),
'Leuven' => $this->t('Leuven'),
),
'#ajax' => [
'callback' => array($this, 'extendFormAjax'),
'event' => 'change',
'progress' => array(
'type' => 'throbber',
'message' => t('Choose City'),
),
],
'#suffix' => '<div id="extended-form"></div>',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
/**
* Ajax callback to validate the email field.
*/
public function extendFormAjax(array &$form, FormStateInterface $form_state)
{
$parking = [
'#type' => 'select',
'#title' => $this->t('Parking'),
'#description' => $this->t('Parking'),
'#options' => [
'P1' => $this->t('P1'),
'P2' => $this->t('P2'),
],
'#ajax' => [
'callback' => array($this, 'extendFormAjax'),
'event' => 'change',
'progress' => array(
'type' => 'throbber',
'message' => t('Choose parking'),
),
],
];
$response = new AjaxResponse();
$response->addCommand(new InsertCommand('#extended-form', $parking));
return $response;
}
I had a similar issue and i resolved it by adding the element in buildForm and adding a wrapper for it and sending the form element via HtmlCommand
/**
* {#inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form['city'] = [
'#type' => 'select',
'#title' => $this->t('Station'),
'#description' => $this->t('City'),
'#options' => array(
'Aalst' => $this->t('Aalst'),
'Brussel' => $this->t('Brussel'),
'Hasselt' => $this->t('Hasselt'),
'Leuven' => $this->t('Leuven'),
),
'#ajax' => [
'callback' => array($this, 'extendFormAjax'),
'event' => 'change',
'progress' => array(
'type' => 'throbber',
'message' => t('Choose City'),
),
],
];
$form['parking'] = [
'#prefix' => '<div id="extended-form">',
'#suffix' => '</div>',
'#type' => 'select',
'#title' => $this->t('Parking'),
'#description' => $this->t('Parking'),
'#options' => [
'P1' => $this->t('P1'),
'P2' => $this->t('P2'),
],
'#ajax' => [
'callback' => array($this, 'extendFormAjax'),
'event' => 'change',
'progress' => array(
'type' => 'throbber',
'message' => t('Choose parking'),
),
],
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
/**
* Ajax callback to validate the email field.
*/
public function extendFormAjax(array &$form, FormStateInterface $form_state)
{
$parking = [
'#type' => 'select',
'#title' => $this->t('Parking'),
'#description' => $this->t('Parking'),
'#options' => [
'P1' => $this->t('P1'),
'P2' => $this->t('P2'),
],
'#ajax' => [
'callback' => array($this, 'extendFormAjax'),
'event' => 'change',
'progress' => array(
'type' => 'throbber',
'message' => t('Choose parking'),
),
],
];
$response = new AjaxResponse();
$response->addCommand(new HtmlCommand('#extended-form', $parking));
return $response;
}
Try it like this. I have not tested the code.
Try call somewhere in JS Drupal.attachBehaviors();
I experienced this issue and resolved it by this way :
For each element which were populated by Ajax, I add the property "#validated" => true and in the callback, the returned field must have the same attributes (id, name) that the original field :
$form['example_field'] = array(
'#type' => 'select',
'#required' => FALSE,
'#options' => getDynamicOptions(),
'#prefix' => '<div id="etablissement-type-wrapper">',
'#suffix' => '</div>',
'#attributes' => [
'data-drupal-selector' => "edit-example",
'id' => "edit-example",
'name' => "example",
],
'#validated' => TRUE,
);
You need add ajax elements in buildForm methods and rebuild form. Something like this:
/**
* {#inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $no_js_use = FALSE) {
// We want to deal with hierarchical form values.
$form['#tree'] = TRUE;
$form['step'] = [
'#type' => 'value',
'#value' => !empty($form_state->getValue('step')) ? $form_state->getValue('step') : 1,
];
switch ($form['step']['#value']) {
case 1:
$limit_validation_errors = [['step']];
$form['step1'] = [
'#type' => 'fieldset',
'#title' => $this->t('Step 1: Personal details'),
];
$form['step1']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Your name'),
'#default_value' => $form_state->hasValue(['step1', 'name']) ? $form_state->getValue(['step1', 'name']) : '',
'#required' => TRUE,
];
break;
case 2:
$limit_validation_errors = [['step'], ['step1']];
$form['step1'] = [
'#type' => 'value',
'#value' => $form_state->getValue('step1'),
];
$form['step2'] = [
'#type' => 'fieldset',
'#title' => t('Step 2: Street address info'),
];
$form['step2']['address'] = [
'#type' => 'textfield',
'#title' => $this->t('Your street address'),
'#default_value' => $form_state->hasValue(['step2', 'address']) ? $form_state->getValue(['step2', 'address']) : '',
'#required' => TRUE,
];
break;
case 3:
$limit_validation_errors = [['step'], ['step1'], ['step2']];
$form['step1'] = [
'#type' => 'value',
'#value' => $form_state->getValue('step1'),
];
$form['step2'] = [
'#type' => 'value',
'#value' => $form_state->getValue('step2'),
];
$form['step3'] = [
'#type' => 'fieldset',
'#title' => $this->t('Step 3: City info'),
];
$form['step3']['city'] = [
'#type' => 'textfield',
'#title' => $this->t('Your city'),
'#default_value' => $form_state->hasValue(['step3', 'city']) ? $form_state->getValue(['step3', 'city']) : '',
'#required' => TRUE,
];
break;
}
$form['actions'] = ['#type' => 'actions'];
if ($form['step']['#value'] > 1) {
$form['actions']['prev'] = [
'#type' => 'submit',
'#value' => $this->t('Previous step'),
'#limit_validation_errors' => $limit_validation_errors,
'#submit' => ['::prevSubmit'],
'#ajax' => [
'wrapper' => 'ajax-example-wizard-wrapper',
'callback' => '::prompt',
],
];
}
if ($form['step']['#value'] != 3) {
$form['actions']['next'] = [
'#type' => 'submit',
'#value' => $this->t('Next step'),
'#submit' => ['::nextSubmit'],
'#ajax' => [
'wrapper' => 'ajax-example-wizard-wrapper',
'callback' => '::prompt',
],
];
}
if ($form['step']['#value'] == 3) {
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Submit your information"),
];
}
$form['#prefix'] = '<div id="ajax-example-wizard-wrapper">';
$form['#suffix'] = '</div>';
return $form;
}
public function prompt(array $form, FormStateInterface $form_state) {
return $form;
}
public function nextSubmit(array $form, FormStateInterface $form_state) {
$form_state->setValue('step', $form_state->getValue('step') + 1);
$form_state->setRebuild();
return $form;
}
public function prevSubmit(array $form, FormStateInterface $form_state) {
$form_state->setValue('step', $form_state->getValue('step') - 1);
$form_state->setRebuild();
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$messenger = \Drupal::messenger();
$messenger->addMessage($this->t('Your information has been submitted:'));
}

Is it possible to configure routes in a container (empty/non-routing parent)?

I'm creating an authentication module to deal with the login/logout of users into the website.
I want to keep the paths simple:
https://example.com/login
https://example.com/logout
But, for some functions within the application/module, it would make sense to me to set up the two routes under some kind of parent:
'routes' => array(
'auth' => array(
'type' => 'Literal',
'options' => array(
'route' => '',
),
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => '/login',
'defaults' => array(
'controller' => 'Base\Controller\Authentication',
'action' => 'login',
),
),
'may_terminate' => true,
),
'logout' => array(
'type' => 'Literal',
'options' => array(
'route' => '/logout',
'defaults' => array(
'controller' => 'Base\Controller\Authentication',
'action' => 'logout',
),
),
'may_terminate' => true,
),
),
),
The problem is - without any route in the parent, I can't get a match on either of the child routes (/login and /logout return 404 with routing errors).
If I do put a route in the parent, like /auth then the urls only match as /auth/login and /auth/logout.
I don't want the parent to interfere with routing in other modules - for example, the "home" route at '/' is already defined in a different module and I don't want to replace or modify that.
About the only thing I have found on the internet similar to what I'm trying is a resolved bug report from 2012.
Is there a way to define a non-routing parent that can hold routable children in ZF2 configuration?
'routes' => array(
'auth' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
),
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => 'login',
'defaults' => array(
'controller' => 'Base\Controller\Authentication',
'action' => 'login',
),
),
'may_terminate' => true,
),
'logout' => array(
'type' => 'Literal',
'options' => array(
'route' => 'logout',
'defaults' => array(
'controller' => 'Base\Controller\Authentication',
'action' => 'logout',
),
),
'may_terminate' => true,
),
),
),

Uploading file with jshelper in CakePHP 2.2.1

I am trying to made upload files with jshelper.
In my view:
<?php echo $this->Form->create('Form', array(
'inputDefaults' => array(
'format' => array('before', 'error', 'label', 'between', 'input', 'after'),),
'enctype' => 'multipart/form-data'
));
echo $this->Form->input('Form.file', array('type' => 'file', 'id'=>'file'));
$this->Js->get('#file')->event(
'update',
$this->Js->request(
array('controller' => 'ControllerForm','action' => 'actionForm'),
array(
'async' => true,
'method' => 'post',
'dataExpression'=>true,
'data'=> $this->Js->serializeForm(array(
'isForm' => false,
'inline' => true,
))
)
));
echo $this->Js->writeBuffer();
echo $this->Form->end();
?>
In my controller:
public function actionForm(){
debugger::dump($this->data);
}
But debugger::dump output empty array.
Man as I know you cannot send file using ajax (include xhrRequestObject2 in Chrome). Firstly in server side you check post data instanted debug($_FILES), but that as I wrote is empty. Use old good iframe to send data to server.

Resources