SagePay: list of transactions - php

I'm just wondering if it's available to fetch list of all payments from SagePay. I'm currently able to get transaction details by providing transaction_id and send request to https://sagepay.com/api/v1/transactions/{$transaction_id}. I'm currently getting all payments by CSV export from SagePay dashboard, but I would like to automate it. Thank you in advance for help.

You can use the 'old' API to achieve this - just issue a getTransactionList command.
Documentation at: https://www.sagepay.co.uk/file/1186/download-document/reportingandapiprotocol102v0.5.pdf

You can do it easily, just give the required fields in the xml form and send request to respective url.
$crypt = MD5($string . '<password>' . $password . '</password>');
$xml = 'XML=<vspaccess>'.$string.'<signature>'.$crypt.'</signature>
</vspaccess>';
where $string is the whole xml before the password.
It will also help you making the signature field in xml syntax.
Read this pdf (page 85 for you) :-)

Related

XERO PHP SDK - Get Invoice PDF

I am using the Xero PHP SDK (This one https://developer.xero.com/code-samples/libraries/php/) and I am able to post an invoice with no problems.
However, I am having issues understanding how I can retrieve the posted invoice's PDF, as I need to manually email this to the customer.
I believe the standard invoice request should be formatted thusly, but this will return all invoices.
$XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array());
My Question, therefore, is using the above SDK and call format how would I…
Target a specific invoice by its ID
Retrieve a PDF of the said invoice.
Some code examples would really help me out. Thanks!
To get the PDF output use the following
<?php
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoice/'.$InvoiceID, 'core'), [], "", 'pdf');
if($XeroOAuth->response['code'] == 200){
$myFile = $invoices->Invoices[0]->Invoice->InvoiceID.".pdf";
file_put_contents($myFile, $XeroOAuth->response['response']);
}

Pushwoosh: Set Badge with PHP API

I'm using a paid Pushwoosh Account in order to send programmatically push-notifications to my users.
I've implemented the Pushwoosh PHP SDK and everything works great, but I'm not able to set a Notification-Badge on iOS devices as seen on the following image:
My code so far is:
$devicesArr[] = ...
$pushwoosh = Pushwoosh::create()
->setApplication('79XXX-9CXXX')
->setAuth('Wkf...2C8');
//Create the Message
$request = CreateMessageRequest::create()
->addNotification(Notification::create()
->setContent('A new workout is available!')
->setDevices($devicesArr));
//Call the REST Web Service
$response = $pushwoosh->createMessage($request);
I tried to use the ->setBadge(5) method according to this page but this also does not work:
$request = SetBadgeRequest::create()
->setBadge(1)
->setHwid('18D...1AF');
Do you know how I can achieve my goal?
I can't reproduce this on Cordova Sample (https://github.com/Pushwoosh/pushwoosh-phonegap-cordova-sample/tree/master/Phonegap-iOS-Android-WP), can you share a simple sample?
Are you sure the app is closed when you receive push with badge?
Per the docs, this is not the method you use to set the badge number on the device.
Important
This method IS NOT used to update the badge value on the device.
Instead please use /createMessage request with the "ios_badges" parameter.
http://docs.pushwoosh.com/docs/setbadge

Google DFA (DoubleClick for Advertisers) APIs v1.20

As in the subject, I'm working with the Google DFA (DoubleClick for Advertisers) APIs v1.20 and I'm trying to get the list of all my Advertisers.
I didn't found any client library for PHP and DFA APIs v1.20.
The connection is established by SOAP, as requested by Google API docs (https://developers.google.com/doubleclick-advertisers/docs/getting_started)
The authentication process seems to work correctly but the list request return the following error:
WSDoAllReceiver: security processing failed; nested exception is: org.apache.ws.security.WSSecurityException: General security error (WSSecurityEngine: Callback supplied no password for: MyUsername)
To build the header I'm using the following code
$advertiserService = new SoapClient($advertiserWsdl, $options);
// Set headers.
$headers = array(DfaHeadersUtil::createWsseHeader($username, $authToken),
DfaHeadersUtil::createRequestHeader($namespace, $applicationName));
Where the DfaHeadersUtil is a class into the file DfaHeadersUtil.php provided by Google as "header creator".
Is there anybody could help me with this?
Thank you in advance,
Mauro
SOLVED:
The problem was given by not sufficient permissions assigned by the admin to my user..
Easy solution that made me waste half week.. :(
What I learnt:
Occam's razor: "the simplest explanation is usually the correct one"..
Next time.. check the permissions :)
Thank you

Google Contacts API name and email

This is my first post on this site, so forgive me if I butcher it, but I'll try to be a clear and straight forwards as possible.
I'm trying to use the Google Contacts API to import the name and email address from an authenticated users gmail account. I am getting the email address fine using the generic code supplied by Google itself. I've tried to modify it to grab the contact names as well to no avail. Any help would be greatly appreciated. Below is the code I am currently using.
$xml = new SimpleXMLElement($val->getResponseBody());
$xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
$result = $xml->xpath('//gd:email');
$name_result = $xml->xpath('//title');
foreach ($result as $title) {
echo "<div>".$title->attributes()->address."</div>";
}
foreach ($name_result as $name) {
echo "<div class='contact_alt'>".$name."</div>";
}
OK, so I managed to find the answer elsewhere on this site. Didn't mean to post a question with an answer that already existed here. I really did try to look around first so I didn't do that.
PHP GMAIL Contacts XML Parsing with DOMDocument and cURL
An alternative solution I use is asking the Google API to reply with JSON, rather than XML. Parsing the XML with the gd: namespaces gets tricky. The JSON comes back with contact names and emails and it becomes a matter of using json_decode().
$url = 'https://www.google.com/m8/feeds/contacts/%s/full'
$url .= '&access_token=%s'
$url .= &alt=json;
Just add the &alt=json to the request URL.

I need more insight to how the eBay API works

I have looked at many examples in PHP codes within there site BUT they keep using different techniques each time and is not straightforward at all!. I've downloaded the ebaySession.php and keys.php files. I have successfully integrated the ebaysession class and have made contact with ebay. But how to use the sendHttpRequest() method confuses me. There is no explanation to how to get a user account information.
Many tutorials also show that the constructor for the eBaySession class has the request token as the last parameter whereas my file has User token as the first parameter. There are many inconsistencies with the API documentation from eBay. I have a test user account with a token in place...
What I also don't understand is why eBaySession constructor requires the UserToken & callname when in ebay's example (s) the call name and usertoken was included in an XML string...
A SIMPLE question that I cannot see a clear answer within the eBay docs, How do I make a simple call then retrive the results / response in a variable? I have achieved this with a simple search query, but can't seem to get it working when it requires user information and authentication... ALSO the search example that eBay had uses a URL type query e.g.
// Construct the findItemsByKeywords HTTP GET call
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findItemsByKeywords";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&keywords=$safequery";
Then another example uses:
///Build the request Xml string
$requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
$requestXmlBody .= '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$requestXmlBody .= "<SessionID>$theID</SessionID>";
$requestXmlBody .= '</FetchTokenRequest>';
That XML code was put in the sendHttpRequest() method. Why? there was another example that did the same which had a authToken inside the XML yet the authToken was defined within the class constructor...
Any general advice on using the eBay PHP API would be greatly appreciated.
GetUser Will returns the users data of single user .There is a good tutorial for this see below link
http://developer.ebay.com/devzone/xml/docs/reference/ebay/getuser.html
You ask so many questions that it's kind of hard to follow and answer all of them.
The best suggestion I have is to use the eBay SDK for PHP. You can find it here. It will make your life much, much easier, and it returns the entire response in a variable, just as you want.
You will make a call like this:
$service = new TradingServices\TradingService([
'credentials' => [
'devId' => 'YOUR_DEV_ID',
'appId' => 'YOUR_APP_ID',
'certId' => 'YOUR_CERT_ID',
],
'siteId' => YOUR_SITE_ID,
'sandbox' => false // or true,
'token' => YOUR_TOKEN
]);
$request = new TradingTypes\GetItemRequestType();
$request->ItemID = $your_itemid;
$response = $service->GetItem($request);
Then you have all the data you want in the $response var and you can get specific data by using
$title = $response->Item->Title;
$description = $response->Item->Description;
...
I have used this SDK to develop a platform from which I manage about 30k listings in 3 ebay shops, I make new listings, I monitor my sales in all the 3 shops, I send and receive the messages from all 3 shops, and so on.
It also has very good examples, and it will make it so much easier to understand the eBay documentation.
So trust me, it's and extremely powerful tool that will make your developing days much easier and will help you work so much faster.

Categories