When I invoke this method. after that not statement executes.
$this->load->spark('ci-merchant/2.1.1'); # We always specify the full path from the spark folder
$this->load->library('merchant');
$this->merchant->load('merchant_paypal_express');
$settings = $this->merchant->default_settings();
$settings = array(
'username' => 'xxxxxxx',
'password' => 'xxx',
'signature' => 'xxxxxx',
'test_mode' => true);
$this->merchant->initialize($settings);
// GETING AMOUNT REMAINING.
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => 'hbs.local/checkout/payment_return',
'cancel_url' => 'hbs.local/checkout/place_order');
$response = $this->merchant->purchase($params);
$message = $response->message();
Due to invalid account credientials I was getting the error. I was setting live account API credentials in $settings. using sandbox account setting solve my issue.
Related
I'm trying to update my theme via Updates API in WordPress and can't get it to work.
Here's the transient value:
(object) array(
'last_checked' => 1675756430,
'checked' => array(
'chipmunk-lite' => '1.0',
'chipmunk-theme' => '1.17.1',
),
'response' => array(
'chipmunk-theme' => array(
'theme' => 'chipmunk-theme',
'new_version' => '1.18.0',
'url' => 'https://chipmunktheme.com',
'package' => 'https://app.lemonsqueezy.com/download/unique_id',
'requires' => NULL,
'requires_php' => NULL,
'sections' => array(
'description' => '<p>Makes it ridiculously easy to make a content curation website for marketing, authority or just for fun. No coding skills required.</p>',
'changelog' => '1.18.0',
),
),
),
'no_update' => array(),
'translations' => array(),
)
The update alert does not show up. Is there anything wrong with it?
I'm following this guide: https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/
When I send rest request to the wp-rest by:
$response = wp_remote_post( $url, array(
'method' => 'POST',
// 'headers' => $headers,
'httpversion' => '1.0',
'sslverify' => false,
'body' => json_encode( array(
'data' => $field,
))
));
Unfortunately, I get 403 error:
{"code":"rest_cookie_invalid_nonce","message":"Kodem jednorazowy z ciasteczka jest nieprawid\u0142owy","data":{"status":403}}
Maybe someone knows how to resolve this issue?
When you use wp_remote_... your cookies are not included. WordPress REST API uses the _wpnonce value to validate your session against the wp_rest keyword and your cookie values. To fix this, your options are to either switch to an AJAX browser call to the endpoint from the same browsing session, or you can stick with the remote REST API request and include your cookies in it like this:
$cookies = [];
foreach( $_COOKIE as $name => $value ) {
$cookies[] = new WP_Http_Cookie(
[ 'name' => $name, 'value' => $value ]
);
}
$args = [
'body' => [],
'cookies' => $cookies,
'headers' => [ 'Content-type' => 'application/json' ],
];
$url = get_rest_url() . 'endpoint/v1/endpoint/';
$response = wp_remote_get( $url, $args );
When I use the Security component in Cake3 I always get the error message: "The request has been black-holed" in my controller tests. It works as expected because the request is really black-holed in that case but I need a possibility to test my code anyway.
I found the following post about the same issue but in Cake2. Unfortunately I was not able to transfer it to Cake3 and maybe it's not possible to use the same approach here.
This is how my test case looks:
$data = [
'first_name' => 'Test First Name',
'last_name' => 'Test Last Name',
'gender' => Gender::MALE,
'role_id' => Role::ADMIN,
'email' => 'test#test.com',
'password' => '',
'status' => Status::ACTIVE,
'birthday' => '2015-01-01',
];
$this->post(['prefix' => 'admin', 'controller' => 'users', 'action' => 'edit', 1], $data);
Same problem occurs also for Csrf component but the solution should be quite similar so I will figure this out afterwards.
Your test must to extend IntegrationTestCase and before doing the post you could use:
$this->enableCsrfToken();
$this->enableSecurityToken();
I am developing an app in Silex with Symfony Security component. Anonymous users should be able to access every point of app except admin section (^/admin).
What am I doing wrong? Anonymous can still access admin section. I have followed some other answers on SO to get to this points but now I am stuck.
$app['security.firewalls'] = array
(
'general' => array
(
'pattern' => '^/',
'anonymous' => true,
'form' => array
(
'login_path' => '/login',
'check_path' => '/admin/login_check',
'default_target_path' => '/admin',
'always_use_default_target_path' => true,
),
'logout' => array
(
'logout_path' => '/admin/logout',
'target_url' => '/'
),
'users' => $app->share(function() use ($app) {
return new UserProvider($app['db']);
})
)
);
// #todo - find out why anonymous can see admin panel
$app['security.access_control'] = array
(
array('path' => '^/login', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'),
array('path' => '^/admin', 'role' => 'ROLE_USER'),
);
$app['security.role_hierarchy'] = array
(
'ROLE_ADMIN' => array('ROLE_USER'),
);
look at the docs
http://symfony.com/doc/current/book/security.html#basic-example-http-authentication
'access_control' => array(
array('path' => '^/admin/', 'role' => 'ROLE_ADMIN'),
// Include the following line to also secure the /admin path itself
// array('path' => '^/admin$', 'role' => 'ROLE_ADMIN'),
),
its either ^/admin/ or ^/admin$ not ^/admin
I have changed the security.access_control (which seemed ignored now) to security.access_rules (which threw error of "access_rules" being unknown property previously) and now it seems to work:
$app['security.access_rules'] = array
(
array('^/admin', 'ROLE_USER'),
);
$table_name = 'tbl_users';
$data = array('datetime'=>'NOW()',
'ipadress' => $ipaddress,
'name' => $name,
'dob' => $dob,
'nationality' => $nationality,
'address' => $address,
'city' => $city,
'state' => $state,
'pincode' => $pincode,
'phone' => $phone,
'email' => $email,
'mobile' => $mobile,
'weight' => $weight,
'height'=> $height,
'marital' => $marital,
'degree' => $degree,
'institute' => $institute,
'special' => $special,
'yearofpaas' => $yearofpaas,
'grade' => $grade,
'emplyment_history' => $emplyment_history,
'merits' => $merits,
'major_achivements' => $major_achivements,
'interview_attended' => $interview_attended,
'details' => $details,
'minctc_position' => $minctc_position,
'cv_file' => $cv_file,
'declaration' => $declaration);
echo "<pre>";
print_r($data);
drupal_write_record($table_name, $data);
I have this insert query but somehow records are not going in to the table..can anyone please help me...whats the problem in the query ?????
You're passing in NOW() as a string, which won't work. Try instead:
$data = array('timestamp' => date("Y-m-d H:i:s"),
drupal_write_record only works if table schema is present in my_module.install file.
From here: drupal_write_record saves (inserts or updates) a record to the database based upon the schema.
So, make sure that schema of tbl_users table is present.
Also, as mentioned by Dan U. use date("Y-m-d H:i:s") instead of 'Now()'.
The dblog can give you a good idea about the problem in your query. The path is admin/reports/dblog.