I want to make my website payments via sagepay. The problem is I am not able to locate all the things in the PHPKit they provide. The version of the kit is 3.0 and I want to configure iframe integration but when I open the test method there is this piece of code
$view = new HelperView('server/low_profile');
$view->setData(array(
'env' => $this->sagepayConfig->getEnv(),
'vendorName' => $this->sagepayConfig->getVendorName(),
'integrationType' => $this->integrationType,
'request' => HelperCommon::getStore('txData'),
));
$view->render();
I want to locate those keys 'env', 'vendorName', 'integrationType', 'requests' and see how to put them to use in my system. I see this syntax in a lo of places
public function setSagepayConfig(SagepaySettings $sagepayConfig)
{
$this->sagepayConfig = $sagepayConfig;
}
But I don't know what SagepaySettings means and how to trace it. Can you tell me where can I find SagepaySettings, or what does this mean. Is it a class or method or attribute, because I cannot find it in all the files as any of those.
It's a class in \lib\classes\settings.php
Related
I suppose I am a noob with PHP so apologies if I sound dumb, but, I do have a troubling dilemma, I have spent the last six hours plus scouring Google for any hints and found none so here I am on the SO forum looking for some 'pointers' in the right direction.
I have an issue with returning 3DAA's from a function in a class to other parts of my code and no matter what I try I'm getting a null value back, according to the error log anyway, but when I run this code separately from the framework, in a single file using the same declarations it miraculously starts working and echos the specified part of the array to the screen wahey, but I don't know why it suddenly works nor why it won't work in the framework and supplies a null value.
I was wondering if anyone out there has experienced such weird errors with returning 3DAA's and if so, how they got around it. If you want to see the code ask and I'll post it.
<?php
class Core {
public function GetConfiguration() {
$configuration = array(
"cobalt" => array(
"name" => 'Cobalt',
"version" => '1.0.7',
"directory" => array(
"root" => 'application',
"modules" => 'application/modules',
"html" => 'application/html'
)
),
"application" => array(
"name" => 'Cardinal Technologies',
"version" => '1.0.2',
"server" => 'http://localhost',
"seo" => array(
"copyright" => 'Ida Boustead',
"description" => 'Welcome to Cardinal Technologies, here at Cardinal Technologies we pride ourselves in providing the best possible customer service whether you need a repair or upgrade for a computer, android phone or tablet, even alarms and CCTV',
"keywords" => 'computer repair,computer upgrade,computer upgrades,android phone repair,phone repair,android tablet repair,tablet repair,alarms,cctv,network installation,network install',
"robots" => 'index,follow'
)
)
);
return $configuration;
}
public function LoadModule($module) {
require_once 'application/modules/' . $module . '.class.php';
}
}
?>
Hope this helps.
I'm calling it like this.
require_once 'application/Core.class.php';
$core = new Core();
$configuration = $core->GetConfiguration();
and getting an array value like this.
$dir = $configuration['cobalt']['directory']['html'];
the prior is a snippet from a larger file but this is what relates to that function.
I get PHP Notice: Undefined variable: dir in the log which is what led me to believe the function was the problem.
If I echo $dir it echos application/html which is what it's supposed to, but it is not usable for anything other than echo which is pointless to me as I need that value to make other parts of the framework work.
Right it was me being a dumb dumb, I put the declarations in the wrong place, outside of the class and it did not like it.
I moved them to inside of each function that stalled the code and it fixed that issue. Thanks anyway.
I am trying to install the CodeIgniter RESTClient and RESTServer libraries for my solution. (philsturgeon-codeigniter-restclient and chriskacerguis-codeigniter-restserver ).
I managed to get the rest server up and running, but I am encountering issues with the rest client.
These are the steps I did to come where I am now:
Copy the Rest.php file (downloaded from GitHub) and put it in the libraries folder
Download the Curl library and put it in libraries
Modified the code in Rest.php to uncomment $this->_ci->load->library('curl'); (if I hover over the usages of the curl library in this file I get the following message):
Field 'curl' not found in CI_Controller
I create a new controller called "Restclient" to test my API. In this controller I created the following method:
function rest_client_example($id)
{
$this->load->library('rest', array(
'server' => 'localhost/codeigniter/api/users/'
));
$user = $this->rest->get('volunteer', array('id' => $id), 'json');
var_dump($user);
}
Browsing to http://localhost/codeigniter/api/restclient/rest_client_example/25 then gives me
D:\wamp\www\codeigniter\application\controllers\api\Restclient.php:36:null
When executing the following code instead of the above, I do get a correct result:
$this->load->library('curl');
$t = $this->curl->simple_get('api/users/volunteer', array('id'=>$id));
var_dump($t);
So I do know that the curl is working.
My guess is that I am doing something wrong with the loading of the curl library?
I know your question is specific to the Libraries mentioned here. Have you tried anything else? I've had really good success with guzzle http
https://github.com/guzzle/guzzle
I have created a custom Drupal 8 module that works as is with a custom block and block form to collect some info.
This is all good.
I also have a twig template that I want to render a twitter feed using a php feed class I bought. I just don't know how it integrate this into the module.
This is the setup for the class: http://austinbrunkhorst.com/demos/twitter-class/#setup
It contains two files:
ultimate.twitter.feed.php
and
tmhOAuth.php
Which is currently a require_once 'tmhOAuth.php'; in the head of ultimate.twitter.feed.php
According to the instruction I should be creating a php file that has this:
$options = array(
'screen_name' => 'FeedTestUser',
'consumer_key' => '...',
'consumer_secret' => '...',
'user_token' => '...',
'user_secret' => '...',
);
$twitter = new Twitter($options);
$twitter->PrintFeed();
Which I'm guessing is also a hurdle as twig files are not php
Any help with this is very much appreciated.
C
I would setup the class as a Service in your module. Your block will then implement that service and do the handling. You don't really want to use require_once() if you can avoid it, rather use Drupal constructs (in part so that if you reorganize things later Drupal will help find the files in their new location).
Place the class in your module's src directory, and add a namespace to the start of the file (assuming there isn't one there already). Then in your block's class file you should be able to add a use statement that references that name space (even better would be to use a dependency injection, but the details on that would get in your way here).
In your block class's build() method you then instantiate the class as described in your question, but instead of just letting the module print HTML, you can want to capture that HTML and place it into your block as markup. If the class allows you to do that without using a buffer, you should (but I didn't see anything in the docs to support that), and then attempt to theme the structured data. If not, you can use PHP's output buffering to capture its attempt to print:
ob_start();
$twitter->PrintFeed();
$content= ob_get_contents();
ob_end_clean();
Then place the generated markup into a render array:
return [
'my_twitter_block' => [
'#markup' => $content,
],
];
Create a custom block and add the result of PrintFeed() to the render array. Just as with any usual custom block. In the render array you can specify a template which should be used (if needed). If you wanna output pure html without any template you could use the '#markup' key.
Small example:
Your block render array:
return array(
'#theme' => 'name_of_your_theme',
'#some_twig_variable' => $twitter->PrintFeed();
);
your your_module.module file (in the root of your module folder):
function your_module_theme() {
return array(
'name_of_your_theme' => array(
'variables' => array(
'some_twig_variable' => some-default-value,
),
),
);
}
your name-of-your-theme.html.twig template (should be under your_module/templates):
{{ some_twig_variable }}
As far as using the class: I see no problem using a require_once for that matter (in your Block php file). Of course it's always better/nicer if you can require the library/package via the make file or composer and then use the autoloader, but if that's not possible just put it e.g. in your drupal root under /libraries/twitter or so and then require it. If you do it like that you have to check that library into your git repository obviously.
have you use ultimate.twitter.feed.php in your TwitterBlock.php file
If not then try adding this line before class block beginns:
require_once 'path/to/twitter_class/ultimate.twitter.feed.php';
I want to use the Respect/Validation library in PHP. I know how to use it but currently I'm using it in a project in German language and of course, I also want the error messages in German.
For language translation, there is a section in the documentation but I don't really get it and I did not found any answer yet.
They're talking about a translator that should handle the translation of the messages. As a second parameter they're giving "gettext" but I don't know what this should be and how this should handle the translation.
Can anybody explain me how this works?
Respect/Validation won't do the translation for you, you should use a different project, library or function to do that. It won't leave you empty handed though, as the documentation states.
First, you should try to understand how translation libraries work (such as gettext()) and then read PHP documentation on Callables. Then it is a matter of choosing a library, creating the translations and calling setParam('translator', 'callable') method on the exception instance.
A quick introduction to your problem:
Translations are done based on a source: it can be a file, a database or something else, depending on which library you use.
Respect/Validation exception messages use the same pattern: {{name}} is invalid.. Where {{name}} will be replaced by the input given or the name if setName() was called on that rule.
You can see all messages you need to translate under the Respect\Validation\Exceptions namespace.
Usually, every library provide a single function/method to translate a given string. This is the method/function you want to set on the $exception->setParam() call.
If you ever translate all exception messages, we would love to make them available to everyone else.
PS: You could also make this question on the repository page, more people would help and we could also improve the way translations are handled by the library in the future.
I just changed all Exception defaultTemplates property, it works for me.
class Localization
{
public function init()
{
$this->validation();
}
public function validation()
{
$prefix = '\\Respect\\Validation\\Exceptions\\';
$localize = [
'EmailException' => 'local message',
'NotEmptyException' => 'local message'
];
foreach($localize as $class => $message) {
($prefix.$class)::$defaultTemplates[
ValidationException::MODE_DEFAULT][ValidationException::STANDARD] = $message;
}
}
}
$localization = new Localization();
$localization->init();
I'm new with Taobao API and I'm not Chinese. I need to obtain category list and items from Taobao.com.
I'm using Yii and this extension: http://www.yiiframework.com/extension/topsdk4yii/
I have Api key and Api Secret, I'm trying to make a query and a receive this error:
object(stdClass)[16]
public 'code' => int 11
public 'msg' => string 'Insufficient isv permissions' (length=28)
public 'sub_code' => string 'isv.permission-api-package-empty' (length=32)
I make query in this way ( in SiteController.php -> function actionIndex() ):
Yii::import('application.extensions.taobao.request.*');
$request = new ShopGetRequest();
$request->setNick('my_username_from_taobao');
$request->setFields('sid,cid,title,nick,desc,bulletin,pic_path,created,modified');
$shop = Yii::app()->top->execute($request);
var_dump($shop);
I found some explanation here http://open.taobao.com/support/question_detail.htm?id=496 but I can't find how to fix this.
Please help me.
Thanks in advance.
You can't fix it from your application
you have to tell to the Api owner to white-list your server ip address if not done your application will not be able to make requests to taobao api.
The error means your application has not applied for the required permissions. You can do this from the application menu (providing an explanation of the application plus reason for applying in Chinese), after which they will handle your application within 3 working days.