I'm trying to get list of invoices for specific customer from Stripe using PHP.
Following is the code I'm using.
\Stripe\Stripe::setApiKey('STRIPE_SECRET_KEY');
$response = \Stripe\Invoice::all(array('customer' => 'CUSTOMER_TOKEN'));
But this returns empty array.
Instead, CURL command returns result
curl https://api.stripe.com/v1/invoices?customer=CUSTOMER_TOKEN -u STRIPE_SECRET_KEY
Any idea?
I'm using Stripe PHP library available from Github.
https://github.com/stripe/stripe-php
$response = \Stripe\Invoice::all(array('customer' => 'cus_id'));
You need to add customer id for specific customer.
Related
I am struggling, literally, trying to figure out how to use th Ebay API in order to retrieve the orders received on a specific merchant account and then store some datas in an external DB.
I have registered to developer.ebay.it, I have built a key pair, both for production and sandbox, then I have tried the api (Browse/getItem)...and then...LOST.
I cannot use the Fullfillment, because I always get a response of Insufficient authorization, even if I create a token, even if I put a real order number... I don't get how to question the API.
Lastly, I am using PHP and I have downloaded the davidtsadler SDK from github. How do I configure an example of getOrder with that SDK? Do you have any link, suggestions, anything?
What I find on internet is not enough clear for my level of knowledge and almost nobody deals with the getOrder call.
Thank you for your help.
The ebay API documentation is fairly clear on how to perform a query:
If you wanted to get a specific Fullfillment policy, then you would need to perform a GET request to ebays Fullfillment API using the /order/{orderId} path - where {orderId} is a real order ID.
In PHP, that might go a little something like this:
/* Returns a JSON object containing an ebay order */
function getOrder($order_id, $auth_key){
$options = array(
'http' => array(
'method' => "GET",
'header' => "Authorization: Bearer ".$auth_key."\r\n" .
"Content-Type: application/json"
)
);
$context = stream_context_create($options);
$result = file_get_contents("https://api.ebay.com/sell/fulfillment/v1/order/".$order_id, false, $context);
return json_decode($result);
}
Then you could call the method above and retrieve an order using:
$order = getOrder("A REAL ORDER ID", "YOUR AUTH KEY");
The $order variable now holds a JSON object. You can print info from the object using: (This example prints the username associated with the order)
echo $order->buyer->username;
Finally, please note the direct quote from ebays documentation:
"eBay creates and displays an Application token. This token is valid for a limited time span. If you get an invalid token error when you make a call using this token, simply create a new token and use the new token in your call."
I am new to integrating bitcoin API to my PHP page, I have created a bitcoin account with luno, I have created API Key.
I have been given this url to get balance using my generated API Key:
$ curl -u keyid:keysecret https://api.mybitx.com/api/1/balance
Can anybody help with a proper example on how I can use my API with this given url to display my wallet balance on a PHP page?
The easiest way I know to convert curl commands to executable PHP code is to use this site: https://incarnate.github.io/curl-to-php/
Just add your curl command:
curl -u keyid:keysecret https://api.mybitx.com/api/1/balance
to the textbox that says "Paste curl here". Then take the PHP that is output and integrate it into your app.
You can use the PHP Requests library for an easy way to make HTTP Requests. Your curl command can be converted as follows:
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
// Use additional headers if necessary
$headers = array();
// Create authorization using key and secret.
$options = array('auth' => array('keyid', 'keysecret'));
// Create the GET request to the URL
$response = Requests::get('https://api.mybitx.com/api/1/balance', $headers, $options);
// The result is available in $response
?>
Here is my code to select order report from amazon using mws feed api.This is working fine,but now it returns all _GET_ORDERS_DATA_ type reports,but i only need to get the reports having status _DONE_.is it possible to do with PHP?
Here i found an option for ReportProcessingStatusList but i unable to set with this SDk,how to set this option?
$parameters = array (
'Merchant' => MERCHANT_ID,
'MaxCount' => 100
);
$request = new MarketplaceWebService_Model_GetReportRequestListRequest($parameters);
$TypeList = new MarketplaceWebService_Model_TypeList();
$TypeList->setType('_GET_ORDERS_DATA_');
$request->setReportTypeList($TypeList);
First, you are calling GetReportRequestList, which is part of the Reports API, not Feeds API. You can limit results to a specific report type by requesting the list like this:
$request = new MarketplaceWebService_Model_GetReportRequestListRequest(array(
"ReportProcessingStatusList.Status.1": "_DONE_"
));
By the way, besides the API reference documentation, the Scratchpad helps a lot finding and testing out parameters: https://mws.amazonservices.com/scratchpad/index.html (use the proper URL that matches your country/region)
I am getting an empty array response from authorize.net without any errors.
AuthorizeNetCIM_Response Object ( [xml] => [response] => )
I am using the new php sdk. Here is my code
//authorizenet configuration
define("AUTHORIZENET_API_LOGIN_ID",'');
define("AUTHORIZENET_TRANSACTION_KEY",'');
define("AUTHORIZENET_SANDBOX",true);
//Create new customer profile
$request = new AuthorizeNetCIM;
$customerProfile = new AuthorizeNetCustomer;
$customerProfile->description = "Bar Express Customer";
$customerProfile->email = "a97eehdhd#gmail.com";
$response =$request->createCustomerProfile($customerProfile);
if ($response->isOk()) {
$customerProfileId = $response->getCustomerProfileId();
}
echo print_r($response);
Authorize.net is doing some upgrades to their system. You need to go to the latest SDK of authorize.net on github here and download that. Inside the lib/ssl folder, copy the cert.pem file, and paste it in the sdk inside the same folder lib/ssl. Overwrite the existing certificate file. Thats it. It should start working :)
I think you are passing some missing values to create customer profile like :
merchantCustomerId, refId etc.
I think , you are not being connected to authorize.net properly . Please update authorize.net sdk .
I'm trying to list all the manufacturers names and ID in Magento through SOAP but I couldn't find a sample of code to do it. Can anyone help on how to achieve this using SOAP and PHP?
You should be able to do this using the Product Attributes API. Documentation link http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.info.html
The below code should get you an attribute and the values associated with it. You simply need to pass in the attribute code. Then pull out the options value from the response object which should contain an array of catalogAttributeOptionEntity which will be your options and values.
$client = new SoapClient('http://magentohost/api/soap/?wsdl');
// If somestuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'product_attribute.info', 'manufacturer');
var_dump ($result);
// If you don't need the session anymore
//$client->endSession($session);
I would advise you to take a llok to this article that shows hos to easily consume the Magento SOAP Web service https://www.wsdltophp.com/Blog/Use-WsdlToPhp-to-manage-your-Magento-website-with-its-SOAP-API