How do i check Instamojo payment confirmation? - instamojo

After successful payment, Webhook url is called which contains information such as payment id and other details. If two or more persons simultaneously did payment. And each one using different payment links. Whether the post information returning will get to the corresponding person? Or whether there is a chance to misplace the post information to any other person?
How can i confirm that the return payment info get to the same person who made payment? Is there any way to attach some value to the payment link from the seller site to identify the person who made payment??

POST request sent to Webhook URL will contain the data entered by the user during the payment including their name, email, phone.
If you're using same Webhook URL for different payment links then also you can identify which Payment link was used to make this payment. The POST request contains fields like offer_slug and offer_title which can be used to identify the Payment link used.
If that is not enough then you can define custom fields for your links and pass some custom data with them. Check Instamojo's integration documentation for more details.

Respected,
Few Days back i was working with integration of instamojo in my web app,
Webhook will provide you title,payment_id,buyer_email,buyer_name,buyer_phone,status,offer_slug,amount,mac and few more params.
With the above provided you can determine which user chosen link to pay.
Solution : Before simply redirecting to the link for payment,
Just assemble request specified in Documentation adding Email,name and phone as params and make it read only so that it can't be changed while proceeding to payment.
Adding hmac-sha1 verify will also tighten the integrity check.
I would suggest you to go through the documentation twice for more understanding and clarification.

You have to pass X-Api-Key and 'X-Auth-Tokenand after transaction you will get 2 valuespayment_request_idandpayment_id` pass this 2 you will get transaction details:
$requestid = Input::get('payment_request_id');
$paymentid = Input::get('payment_id');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/'.$requestid.'/'.$paymentid.'/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("X-Api-Key:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"X-Auth-Token:bbbbbbbbbbbbbbbbbbbbbbbbbbb"));
$payload = Array(
'purpose' => 'FIFA 16',
'amount' => '2500',
'phone' => '9999999999',
'buyer_name' => 'John Doe',
'redirect_url' => 'http://www.example.com/redirect/',
'send_email' => true,
'webhook' => 'http://www.example.com/webhook/',
'send_sms' => true,
'email' => 'foo#example.com',
'allow_repeated_payments' => false
);
$response = curl_exec($ch);
curl_close($ch);
$transactiondata = json_decode($response , true);

Related

MailChimp API Get Subscribers ammount

I have been looking at the mailchimp api, and am wondering how to display the live ammount of subscribers to a list, is this possible? And is it possible to have this counter LIVE? I.e as users join, the number increases in real time?
EDIT:
I have been getting used to the API slightly...
after using Drewm's mailchimp php wrapper its starting to make more sense...
I have so far
// This is to tell WordPress our file requires Drewm/MailChimp.php.
require_once( 'src/Drewm/MailChimp.php' );
// This is for namespacing since Drew used that.
use \Drewm;
// Your Mailchimp API Key
$api = 'APIKEY';
$id = 'LISTID';
// Initializing the $MailChimp object
$MailChimp = new \Drewm\MailChimp($api);
$member_info = $MailChimp->call('lists/members', array(
'apikey' => $api,
'id' => $id // your mailchimp list id here
)
);
But not sure how to display these values, it's currently just saying 'array' when I echo $member_info, this maybe completly because of my ignorance in PHP. Any advice to s
I know this may be old, but maybe this will help someone else looking for this. Latest versions of API and PHP Files.
use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp($api_key);
$data = $MailChimp->get('lists');
print_r($data);// view output
$total_members = $data['lists'][0]['stats']['member_count'];
$list_id = $data['lists'][0]['id'];
$data['lists'][0] = First list. If you have more, then it would be like $data['lists'][1] ect...
And to get a list of members from a list:
$data = $MailChimp->get("lists/$list_id/members");
print_r($data['members']);// view output
foreach($data['members'] as $member){
$email = $member['email_address'];
$added = date('Y/m/d',strtotime($member['timestamp_opt']));
// I use reverse dates for sorting in a *datatable* so it properly sorts by date
}
You can view the print_r output to get what you want to get.

How to get invoice details using PayPal API?

I must say, I can't remember the last time I've spent so much time figuring out an API. I loathe working with PayPal. That said...
I'm developing a seemingly simple script to download transactions into shipping software. I've got the script working to pull transactions in NVP and SOAP. But when a payment is on an invoice, the items purchased aren't included in the payment transaction info. So I'm assuming what I need is in the invoicing API.
I have API credentials that work just fine with TransactionSearch. I saw that for the Invoicing API, I also need an App Id, so I created an App, twice. Apparently there are two PayPal developer sites?? So I have a REST app created at developer.paypal.com and I guess a classic app "conditionally approved" at apps.paypal.com.
I guess after venting about the ridiculously unorganized developer structure and the sad excuse for documentation... !##$ ... I'd like to find out if anyone can get me on the right track.
All I need to be able to do is see what invoices have come in (start-end date, etc) and get the details so it can be exported to our shipping software. Transactions work just fine, I'm not sure why invoices are so different or why there's so much more involved in getting that data?
Just as a reference, here's how we're pulling in our transactions:
$client = new SoapClient( 'https://www.paypal.com/wsdl/PayPalSvc.wsdl',
array(
'location' => 'https://api-3t.paypal.com/2.0/',
'soap_version' => SOAP_1_1
));
$cred = array( 'Username' => $username,
'Password' => $password,
'Signature' => $signature
);
$Credentials = new stdClass();
$Credentials->Credentials = new SoapVar( $cred, SOAP_ENC_OBJECT, 'Credentials' );
$headers = new SoapVar( $Credentials,
SOAP_ENC_OBJECT,
'CustomSecurityHeaderType',
'urn:ebay:apis:eBLBaseComponents' );
$client->__setSoapHeaders( new SoapHeader( 'urn:ebay:api:PayPalAPI',
'RequesterCredentials',
$headers ));
$args = array(
'Version' => '94.0',
'StartDate' => '2014-03-25T00:00:00Z'
);
$TransactionSearchRequest = new stdClass();
$TransactionSearchRequest->TransactionSearchRequest = new SoapVar( $args,
SOAP_ENC_OBJECT,
'TransactionSearchRequestType',
'urn:ebay:api:PayPalAPI');
$params = new SoapVar($TransactionSearchRequest, SOAP_ENC_OBJECT, 'TransactionSearchRequest');
$result = $client->TransactionSearch($params);
print_r($result);
First, if you want to simplify your development with PayPal API's I'd recommend taking a look at my PHP class library for PayPal. It makes things much easier.
As for obtaining invoice details, you're correct that the Invoicing API is actually built on PayPal's Adaptive Payments platform which includes the App ID. I guess I'm a little confused on if you got that done or not..??
Once you have the APP ID, though, you can make the GetInvoiceDetails call to retrieve the invoice details.

how to grab product lists from cj, clickbank and linkshare, ebay using api?

Hello i want to get the product lists from cj, clickbank and linkshare via API's to display the whole lists on my site , if this is possible or its a nightmare , where am i standing please generous reply is needed, tell me how to grab the product list using their respective API's , i have found alot of blogs and posts regarding this but none is enough to solve my prob, thats y i said a nightmare.
this is what i got for clickbank
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.3/products/list");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:DEV-7979307A05A8A50B6535A5AD5DCD8EDB060B:API-4D297E18498B51B70EA986DC7422B1BCE488"));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
the apikey and dev key is the real one of my affiliate account i created , i am giving the real info because i need it to be done, it is throwing the same error , site parameter is missing,
same is what i want for the other two.
much thanks in advance . cheers.
okey the second was linkshare product grabing from linkshare , which is a bit different than other affiliate channels, in a sence that here first you will create relation on the linkshare advertisers , and you can the products of those who will allow you to be his advertiser or affiliate:
here is the code:
$ch = curl_init();
$cv = curl_version();
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_URL, "http://productsearch.linksynergy.com/productsearch?token=YOUR-LINKSHARE-TOKEN-ID-A-VERY-LONG-STRING&keyword=%22YOUR-KEYWORD%22&MaxResults=20&pagenumber=1&mid=MID-THE-ID-OF-THE-ADVERTIZER-WHO-HAS-ALLOWED-YOU&sort=retailprice&sorttype=asc&sort=productname&sorttype=asc");
$xml_data = curl_exec($ch);
curl_close($ch);
$object = simplexml_load_string($xml_data);
foreach($object->item as $signprod)
{}
under the foreach loop you can do what ever you want, just print_r($signprod) and you will get the details , put the keyword matching against your allowed advertiser's product, by helping you more say i have a relation with some cookies site, who's MID is xxxxx , then i write cookies in the keyword and it get results for me, do accordingly.
its simple and yeah it will take a long time on net if someone is new like me, which i was before more than a month ago.
Okey , that question i posted was somewhat one and half month before , i know answers are present all around the web but scattered and i want them to be gathered so if some one need it can use it.
first of all i am giving you for CJ, Comission Junction:
1) Creat a page e.g cjcall.php and put the following code on that page.
// CJ Product Grabing cjcall.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://product-search.api.cj.com/v2/product-search?website-id=YOUR-SITE-ID&keywords=KEYWORD&records-per-page=30&serviceable-area=US");
curl_setopt($ch, CURLOPT_HEADER,false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:YOUR-CJ-DEVELOPER-ID"));
$result = curl_exec($ch);
THIS will give you responce of products against your keyword if it is matching products.
you can get you result the way you want i figured it this way that i created a new page called cjcronjob.php and put the following code on that page and run it , there you can use the product details, i.e may be save in the database.
//cjcronjob.php
$homepage = file_get_contents('ABSOLUTE-PATH-TO-THE-FIRST-CJCALL.PHP-FILE/cjcall.php');
$object = simplexml_load_string($homepage);
foreach($object->products->product as $cjres)
{
}
nOW each product is in your control use it in here inside the foreach loop which will run twenty times here as specified in the curl call.
clickbank is still a mystery , may be they dont allow you to perform more against their API

How to create configurable product using magento api?

How can I create a configurable product using the Magento api?
Your question of creating a configurable product using the API - the answer is: You can't. It doesn't support it (yet at least.)
This is possible with the magento-improve-api plugin. If you need to control which attributes your configurable product is configurable across, you'll need one of the forks of that plugin in
goodscloud/magento-improve-api
jdurand/magento-improve-api
dexteradeus/magento-improve-api
Here's a really good tutorial that walks you through patching the API, so you can use the API directly to create the configurable product, and assign simple products to it as well.
Good luck
Copy/pasted from http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product#example_2._product_createviewupdatedelete
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
// default attribute set in my install is 4
$attribute_set_id = 4;
// configurable product to create
$product_sku = 123456789012;
$newProductData = array(
'name' => 'name of product',
// websites - Array of website ids to which you want to assign a new product
'websites' => array(1), // array(1,2,3,...)
'short_description' => 'short description',
'description' => 'description',
'price' => 12.05
);
$proxy->call($sessionId, 'product.create', array(
'configurable',
$attribute_set_id,
$product_sku,
$newProductData
));
The hard part is assigning simple products to your configurables (not supported via the api). Here's a method for assigning simples to configurables directly

Update specific field on SOLR index

I want to using solr for search on articles
I have 3 table:
Group (id , group name)
ArticleBase (id, groupId, some other field)
Article(id, articleBaseId, title, date, ...)
in solr schema.xml file i just define all article field that mixed with ArticleBase table (for use one index on solr) like this: (id, articleBaseId, groupId, ...)
problem: Admin want to change group (ArticleBase), therefore i must update (or replace) all indexed article in solr. right ? can i update groupId only in solr index ?
have any solution ?
Note:Article table contains more than 200 million article, and i using solr for index only (not store any field data except article id)
Solr does not support updating individual fields yet, but there is a JIRA issue about this (almost 3 years old as of this writing).
Until this is implemented, you have to update the whole document.
UPDATE: as of Solr 4+ this is implemented, here's the documentation.
Please refer to this document about the "Partial Documents Update" Feature in Solr 4.0
Solr 4.0 is now final and production-ready.
This feature makes it possible to update fields and even adding values to multiValued fields.
Mauricio was right with his answer back in 2010, but this is the way things are today.
SolrPHP doesn't provide any method to update a specific field in Solr.
However, you can make a Curl call in PHP to update a specific field:
<?php
// Update array
$update = array(
'id' => $docId,
$solrFieldName => array(
'set' => $solrFieldValue
)
);
$update = json_encode(array($update));
// Create curl resource and URL
$ch = curl_init('http://'.SOLR_HOSTNAME.':'.SOLR_PORT.'/'.SOLR_COLLECTION.'/update?commit=true');
// Set Login/Password auth (if required)
curl_setopt($ch, CURLOPT_USERPWD, SOLR_LOGIN.':'.SOLR_PASSWORD);
// Set POST fields
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $update);
// Return transfert
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set type of data sent
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
// Get response result
$output = json_decode(curl_exec($ch));
// Get response code
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close Curl resource
curl_close($ch);
if ($responseCode == 200)
{
echo 'SOLR: Updated successfully field '.$solrFieldName.' for id:'.$docId.' (query time: '.$output->responseHeader->QTime.'ms).';
}
else
{
echo ('SOLR: Can\'t update field '.$solrFieldName.' for id:'.$docId.', response ('.$responseCode.') is: '.print_r($output,true));
}
I use this code to update in JSON, you can also provide data in XML.
My Solution was something as below:
$client = new SolrClient($options);
$query = new SolrQuery();
// Find old Document
$query->setQuery('id:5458');
$query->setStart(0);
$query->setRows(1);
$query_response = $client->query($query);
// I had to set the parsemode to PARSE_SOLR_DOC
$query_response->setParseMode(SolrQueryResponse::PARSE_SOLR_DOC);
$response = $query_response->getResponse();
$doc = new SolrInputDocument();
// used the getInputDocument() to get the old document from the query
$doc = $response->response->docs[0]->getInputDocument();
if ($response->response->numFound) {
$second_doc = new SolrInputDocument();
$second_doc->addField('cat', "category123");
// Notice I removed the second parameter from the merge()
$second_doc->merge($doc);
$updateResponse = $client->addDocument($second_doc);
$client->commit();
}
You can refer to this documentation for Partial Updates. You can make an update either by replacing it or adding more values to that particular field although (like a list), it's not required in your case
Solr supports different types of Update Operations.
The set of update operations supported by Solr.
'add' - add a new value or values to an existing Solr document field, or add a new field and value(s).
'set' - change the value or values in an existing Solr document field.
'remove' - remove all occurrences of the value or values from an existing Solr document field.
Here is an example of how to do a partial update via Solr’s Java client, SolrJ
// create the SolrJ client
HttpSolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr");
// for clould there is CloudSolrClient api
// create the document
SolrInputDocument solrDocument = new SolrInputDocument();
solrDocument.addField("id","12345");
Map<String,Object> solrUpdates = new HashMap<>(1);
solrUpdates.put("address","Pune");
solrDocument.addField("cat", solrUpdates);
solrClient.add( solrDocument );
solrClient.close();