Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › WP eStore ability to connect to API
- This topic has 5 replies, 2 voices, and was last updated 5 years, 2 months ago by GeorgeK.
-
AuthorPosts
-
August 30, 2019 at 5:28 pm #15539GeorgeKMember
Hello all – hope you’re well.
We currently sell some WordPress plugins via JVZoo.
After someone buys, JVZoo sends an API call to our licensing server. An email record is added to the licensing server for product with id “12345”.
Customer downloads the plugin. They enter their Paypal email in the activation screen. The plugin verifies their purchase, and then they can use it.
We want to sell some WordPress plugins, using WP eStore – not just one by one, but also allow customers to put several plugins in their cart and pay via Paypal.
I understand WP eStore can connect to a 3rd-party application and send the IPN.
But I was wondering if there’s anything “else” WP eStore can communicate, so our app will know specifically for which plugins to create licenses for.
Our app would need to “read” the call and then decide which plugins to activate.
Maybe there’s a script we need to develop on our end?
Thanks!
George
August 30, 2019 at 6:47 pm #79875GeorgeKMemberOne (early) question from one of our developers:
“Does WP eStore fire order completion event which we could handle?
If yes, are there any developer docs on customizing the plugin with external event handlers?”
Thanks!
George
September 1, 2019 at 3:29 am #79876adminKeymasterThe following action hook is a good one to use if you want to create your own custom little plugin that will do all the custom things on your end after a transaction has been processed by eStore:
eStore_product_database_updated_after_payment
It will pass the full IPN data and the cart items (from the transaction).
Take a look at the following free addon’s code. It should give you some good idea in terms of how you can use that above mentioned hook and create your own little custom plugin:
https://www.tipsandtricks-hq.com/ecommerce/wp-estore-post-payment-actions-addon-1691
September 4, 2019 at 9:10 am #79877GeorgeKMemberThanks for the reply, Keith!
A couple of technical questions, (if you don’t mind)…
1) Could you perhaps provide data structure and examples for the $cart_items parameter of the eStore_product_database_updated_after_payment filter?
Mainly, we are looking for the “Reference Text” field of each item – as that will be a sales item ID which we will pass to our own anti-piracy app.
2) What would happen if we fire HTTP error from the eStore_product_database_updated_after_payment filter? Will this cause PayPal to resend IPN later? Just trying to find the best way to handle any failed attempts to add a record to our app.
Thanks again and sorry for the technical questions – I love the WP eStore plugin.
George
September 5, 2019 at 2:05 am #79878adminKeymaster1) The $cart_items array will contain minimal important info like the product ID, name, quantity ordered etc. The best way is to use the Product ID and then do a query to the product’s database to retrieve the full details of that product.
Write to a log file so you can see all the data that is getting passed to that function then you will have a good idea. But below is a little code sample that maybe helpful:
foreach ($cart_items as $current_item) {
$product_id = $item;
//Use this product ID to retrieve the full product data from the database.
$product_data = $wpdb->get_row(“SELECT * FROM $products_table_name WHERE id = ‘$product_id'”, OBJECT);
$name = $product_data->name;//
//TODO – do something
}
2) Action hooks don’t have a return value.
September 7, 2019 at 10:20 am #79879GeorgeKMemberKeith, I really appreciate your answer – very helpful!
Thanks,
George
-
AuthorPosts
- You must be logged in to reply to this topic.