getting ci-merchant working please? - php

I am trying to use the CI-Merchant library for codeigniter. I have installed this via a spark, as recommended. The documentation example that is on the ci-merchant.org website does not specifically show the spark being loaded, and therefor I am uncertain that I am using the system correctly. Can anyone look at the code below and see if they can spot what is going on. I wish to use "sagepay server" as my merchant in case that is helpful.
Regards and thanks in antipation
$this->load->spark('ci-merchant-2.1.1');
$this->load->library('merchant');
$this->merchant->load('sagepay_servber');
$settings = array(
'vendor' => 'fluidbrandinglt',
'test_mode' => TRUE,
'simulator_mode' => FALSE
);
$this->merchant->initialize($settings);
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout'
);
$response = $this->merchant->purchase($params);
When I run the above code, I just get a blank screen with zero feedback about what is going on. I know that I have an encryption password which Sagepay provided me, but again I cannot see where this is configured or even if its relevant.

You should change
$this->merchant->load('sagepay_servber');
with.
$this->merchant->load('sagepay_server');
There is a 'b' in your load statement. Small detail but it does give headaches.

Related

How to add a company logo to paypals SDK V2

I'am trying to add a company-logo by using the PayPal SDK environment in PHP.
I have seen that this is possible, but there is no documentation.
I tried the following without success:
'application_context' =>
[
'return_url' => "https://example.com/return",
'cancel_url' => "https://example.com/cancel",
'image_url' => "https://xyz.de/test/paypal_logo.jpg",
'logo_image' and LOGOIMG do not works also
],
Thanks for any hint in advance.
This depends a bit on the products you use, but generally you can create a Payment Experience Web Profile. See a sample here. After creating it, you will get a Profile ID.
When you initialize your payment, you can pass the Profile ID with the method setExperienceProfileId

Is it possible to insert a Horizontal Rule with Google Docs API?

I've been working on a project that needs to insert both text and other types of elements into a Google Docs Document, using PHP. I'm able to insert text using the following code:
$requests = [];
```
$requests[] = new \Google_Service_Docs_Request(
['insertText' => ['text' => 'Text to insert',
'location' => ['index' => $insertionIndex],
],
]);
```
$batchUpdateRequest = new \Google_Service_Docs_BatchUpdateDocumentRequest(['requests' => $requests]);
$docsService->documents->batchUpdate($documentID, $batchUpdateRequest);
I can also insert a page break with a similar call:
$requests = [];
```
$requests[] = new \Google_Service_Docs_Request(
['insertPageBreak' => ['location' => ['index' => $insertionIndex],
],
]);
```
$batchUpdateRequest = new \Google_Service_Docs_BatchUpdateDocumentRequest(['requests' => $requests]);
$docsService->documents->batchUpdate($documentID, $batchUpdateRequest);
Both of the above work fine (and as per Google's recommendations when I am carrying out multiple insertions I am working backwards). What I need to be able to do is add a horizontal rule to the document. I know Google Docs allows the manual insertion of them and Apps Script supports insertHorizontalRule but the Docs API doesn't seem to have an equivalent. I have searched here, Google, and the API documentation and can't find any reference to it. Could someone tell me if it is possible? If it is possible, what is the correct request type?
It's seems additionally strange that there isn't a documented way of inserting them, and yet you can query the contents of an existing document and any that are in the document are reported back to you as part of its structure.
For clarity of purpose, I am trying to append the contents of one Google Doc to the another. If anyone knows of a better way to do this than consuming the source document element by element and creating a request to add those elements to the destination document, that would bypass the need to handle inserting a horizontal rule.
You want to insert the horizontal rule to Google Document using Docs API.
You want to achieve this using php.
You have already been able to get and put the values for Google Document using Docs API.
I could understand like above. Unfortunately, in the current stage, it seems that there are no methods for adding the horizontal rule in Google Docs API yet, while "horizontalRule" can be retrieved by documents.get. Docs API is growing now. So this might be added in the future update.
So in the current stage, it is required to use the workaround for this.
Pattern 1:
In this pattern, the horizontal rule is added to Google Document using Web Apps created by Google Apps Script as an API.
Usage:
1. Set Web Apps Script:
Please copy and paste the following script to the script editor for Google Apps Script.
function doGet(e) {
DocumentApp.openById(e.parameter.id).getBody().insertHorizontalRule(Number(e.parameter.index) - 1);
return ContentService.createTextOutput("Done");
}
2. Deploy Web Apps:
On the script editor, Open a dialog box by "Publish" -> "Deploy as web app".
Select "Me" for "Execute the app as:".
Select "Anyone, even anonymous" for "Who has access to the app:".
This setting is for a test situation.
You can also access with the access token by setting "Only myself" instead of "Anyone, even anonymous".
Click "Deploy" button as new "Project version".
Automatically open a dialog box of "Authorization required".
Click "Review Permissions".
Select own account.
Click "Advanced" at "This app isn't verified".
Click "Go to ### project name ###(unsafe)"
Click "Allow" button.
Click "OK".
Copy the URL of Web Apps. It's like https://script.google.com/macros/s/###/exec.
When you modified the Google Apps Script, please redeploy as new version. By this, the modified script is reflected to Web Apps. Please be careful this.
3. Use Web Apps as an API:
The following script is for PHP. Please set the query parameter of id and index. id is the Google Document ID. When index=1 is set, the horizontal rule is inserted to the top of body in Document. In this case, index means each row in the Google Document.
$url = 'https://script.google.com/macros/s/###/exec?id=###&index=1';
$curl = curl_init();
$option = [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_FOLLOWLOCATION => true,
];
curl_setopt_array($curl, $option);
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
Pattern 2:
I think that your proposal of I'm also going to look at possible inserting a thin table with a top border line as a replacement for a horizontal rule. can be also used as the workaround. For achieving this, the script is as follows.
When this script is run, new table that has the line of only top is created to the top of document. Before you run the script, please set $documentId. In this case, please set Google_Service_Docs::DOCUMENTS to the scopes.
Sample script:
$documentId = '###';
$index = 1;
$style = [
'width' => ['magnitude' => 0, 'unit' => 'PT'],
'dashStyle' => 'SOLID',
'color' => ['color' => ['rgbColor' => ['blue' => 1, 'green' => 1, 'red' => 1]]]
];
$requests = [
new Google_Service_Docs_Request([
'insertTable' => [
'location' => ['index' => $index],
'columns' => 1,
'rows' => 1
]
]),
new Google_Service_Docs_Request([
'updateTableCellStyle' => [
'tableCellStyle' => [
'borderBottom' => $style,
'borderLeft' => $style,
'borderRight' => $style,
],
'tableStartLocation' => ['index' => $index + 1],
'fields' => 'borderBottom,borderLeft,borderRight'
]
])
];
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest([
'requests' => $requests
]);
$result = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
References:
Web Apps
insertHorizontalRule()
Method: documents.batchUpdate

Build APP using specific keys via Phonegap Build API?

I'm trying to use Phonegap Build API.
I am using this open source PHP library to connect to the Phonegap plugin.
https://github.com/mradionov/phonegap-build-api
Everything works fine as it should.
I can add keys, upload apps and all other general tasks.
However, the issue that I currently have is that I need to be able to upload the app and build it using a specific key for each platform.
To upload the app I use this method:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip', array(
'title' => 'The APP title',
// see docs for all options
));
This uploads it correctly and as it should.
Now, i tried to upload the app using the same method but select a specific key to build it with like so:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip',
'title' => 'The APP title',
'keys' => 1435671
// see docs for all options
));
But this fails to do anything and I dont see any errors either!
Based on the Phonegap API documentation, we can send the following to the API:
keys":{"ios":123,"android":567,"winphone":72}
the numbers used are the keys/certficates that already uploaded onto the Phonegap system.
Could someone please advice on this issue?
Thanks in advance.
finally found it.
Basically I need to pass the values as an array like so:
'keys' => array("ios" => XXXXXXX, "android" => XXXXXXXX),
So the code looks like this:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip',
'title' => 'The APP title',
'keys' => array("ios" => XXXXXXX, "android" => XXXXXXXX),
// see docs for all options
));
And this works just fine...
Hoep this helps others.

Woocommerce rest api - Create product via ajax in wordpress

Well, the problem is here. I created a local project to create a product in Woocommerce mounted in wordpress on a remote server. My local project code is this one
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
function creaProd(){
$precio = $_POST['Total'];
$imagen = $_POST['Imagen'];
$descrip = $_POST['Descripcion'];
$tipo = $_POST['Tipo'];
$woocommerce = new Client(
'http://example.com',
'ck_sdfsdfsdfsfdxxx',
'cs_sdfsdfsfsdfaxxx',
[
'wp_api' => true,
'version' => 'wc/v1',
]
);
$data = [
'name' => $tipo,
'type' => 'simple',
'regular_price' => $precio,
'description' => $descrip,
'short_description' => $descrip,
'categories' => [
[
'id' => 9
],
[
'id' => 14
]
],
'images' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
'position' => 0
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
'position' => 1
]
]
];
print_r($woocommerce->post('products', $data));
}
creaProd();
And evertything works fine, the problem is, that I have tried a bunch of things, but I just don't get to create the product working in the wordpress project.
I put it in the wp-includes folder and the wp-content, but didn't work.
I tried to call an ajax to example.com/wp-includes/myFile.php but I can't reach it, I can reach files like example.com/wp-includes/option.php and all the files already there, but if I upload that one, I just can't, and I don't know where to put the vendor folder either.
Which is the right way to integrate this project to my real site in Wordpress?
Hope someone knows how to do this. Thanks.
I think the best way to integrate third party libraries into Wordpress is creating your own plugins (This for me is the best option, cause you can use other API Wordpress even security stuff like if a user is login or have the right permissions). they are simple to create and they can be enabled through the Wordpress dashboard admin.
Here is some post about it:
How to create plugin - Wordpress Documentation
in this article you can find how to write a plugin in Wordpress from the official documentation
[Note to reviewer I am the same person as user 8256950. When I tried to create a login for 8256950 it create a new login 8262086 instead. Don't know why but I do destroy all cookies daily.]
Your project is a REST client which is usually run from a different server. It is not part of the WordPress server and I would put its files in its own directory. It is not a plugin. It is also not AJAX. (No JavaScript is used in the REST client to REST server communication but of course the client can be invoked by Javascript.)
Concerning your specific problem reaching files it would be helpful if you provided the Network log from your browser. On Chrome 'More tools' -> 'Developer tools' -> 'Network'. Look for the request for you file and see if there is an error message.

ALL GCM parameters?

i´ve written a "pushserver" for my app via PHP.
The push notifications i´ve sent via PHP are all received on the device, so far.
But, i can just send/set the "message" and "title", see:
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
'message' => $message,
'title' => 'My App',
'vibrate' => 1,
'sound' => 1,
'icon' => "http://example.com/image.jpg",
"style" => "inbox"
),
);
"icon" and "style" are not working (vibrate and sound not tested, yet).
Every link for the parameters i´ve found is broken or kind of "you need to do object.setSomething() in JAVA.
Is there a list anywhere where i can see ALL parameters, which i can send to GCM? No matter, what language i use?
Cheers,
Chris
couple of things need to keep in mind while all the data which you sending from server end
Is there a list anywhere where i can see ALL parameters,
exp :- you can send as many parameters as you want but offcourse there is limitation but not key specific just like you can use "textmessage" instead of "message" but make sure to retrieve the value from same key which you are assigning from server end
1) please make sure that you are getting all the data in gcmintentservice class try to print the log of all intent data.
please remember that this is just a string data it is not going to download the image for you. you have to download using volley library or any suitable library

Categories