Maria Gonzalez 0 Posted November 15, 2017 Posted November 15, 2017 Hi, I need to execute a php code once the payment has been received, until now I had only 1 payment method so I wrote in on the confirmation hook of that payment method, but now I'll add more payment methods...so I'll like to know if there is a common place to put that code, instead of each payment confirmation for each different method. So I have to write it once! Thanks Share this post Link to post Share on other sites
bellini13 1,290 Posted November 15, 2017 Posted November 15, 2017 that depends. is it upon order creation, or is it upon payment received (those could be different things depending on the type of payment and payment module used) Share this post Link to post Share on other sites
irder 17 Posted November 15, 2017 Posted November 15, 2017 of course ,you should add content of all hookOrderConfirmation hook Share this post Link to post Share on other sites
Maria Gonzalez 0 Posted November 15, 2017 Posted November 15, 2017 8 minutes ago, VicOffers said: of course ,you should add content of all hookOrderConfirmation hook For all payment methods I have enabled? So..there is no single point? Share this post Link to post Share on other sites
irder 17 Posted November 15, 2017 Posted November 15, 2017 it will only execute the hook function of the payment selected, Share this post Link to post Share on other sites
bellini13 1,290 Posted November 16, 2017 Posted November 16, 2017 22 hours ago, Maria Gonzalez said: For all payment methods I have enabled? So..there is no single point? Not all payments are received when the order is created. So again I ask, is it upon order creation, or is it upon payment received (those could be different things depending on the type of payment and payment module used) If you accept orders using COD, check or bankwire, the payment is NOT received when an order is created. If you use a module that accepts credit cards, then is payment received when the order is created? Or is payment received when the payment provider settles the transaction at night and the money moves into your account the following day. You need to start thinking about this before asking your questions. Share this post Link to post Share on other sites
Maria Gonzalez 0 Posted November 16, 2017 Posted November 16, 2017 I'll use only payments that are processed so the payment is really confirmed! (paypal, credit cards, etc..) Share this post Link to post Share on other sites
bellini13 1,290 Posted November 17, 2017 Posted November 17, 2017 orderconfirmation hook is used to display information to the customer on the front end order confirmation page. Since you said you need to execute PHP code, then I assume this is the wrong hook to use First you would create your own module that registers one of the following hooks. You can use actionValidateOrder hook, which is called anytime a new order is created. Then you can check the order status to confirm the payment status, and then execute your code Or you can use the actionPaymentConfirmation hook, which would be called anytime an orders order status changes to 'payment accepted'. This is probably the most appropriate hook to use, but it assumes the payment modules you use to accept payments treat this order status properly Share this post Link to post Share on other sites
Maria Gonzalez 0 Posted November 18, 2017 Posted November 18, 2017 On 17/11/2017 at 1:52 PM, bellini13 said: Or you can use the actionPaymentConfirmation hook, which would be called anytime an orders order status changes to 'payment accepted'. This is probably the most appropriate hook to use, but it assumes the payment modules you use to accept payments treat this order status properly That is what I need! Another question, sometimes my code will "fail" (i.e. if not enough stock). Is anyway to automatically relauch that script (that own module, so recheck if enough stock and continue without failing), for example every 10 minutes..... Share this post Link to post Share on other sites
bellini13 1,290 Posted November 18, 2017 Posted November 18, 2017 There is nothing in Prestashop that will execute your code every 10 minutes. What exactly does your code do? Share this post Link to post Share on other sites
Maria Gonzalez 0 Posted November 18, 2017 Posted November 18, 2017 Is a virtual product, It send an email to the customer and marks the product as delivered Share this post Link to post Share on other sites
bellini13 1,290 Posted November 19, 2017 Posted November 19, 2017 If its a virtual product, why would there be stock? Share this post Link to post Share on other sites
Maria Gonzalez 0 Posted November 19, 2017 Posted November 19, 2017 is virtual but not unlimited...have stock (or not) Share this post Link to post Share on other sites
bellini13 1,290 Posted November 19, 2017 Posted November 19, 2017 Ok, then why allow the product to be sold if there is no stock? Share this post Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now