Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2014
    Location
    western Pennsylvania
    Posts
    10
    Plugin Contributions
    0

    Default How to detect if an order has been paid?

    I am selling some software that will include a 30-day free trial. I keep track of the user's first install date and after 30 days, it forces them to activate the product.

    I installed Zencart and I added a Product Activation Key field to the orders_products table. I updated the orders class so that it generates the PAK and adds it to the table. I've created a PHP-based gateway for my software to check that field and confirm the PAK.

    Once the order has been paid, I want my gateway to allow the customer to activate the product. I'm struggling a bit with how to tell if the order has been paid. I want to allow cash, paypal and credit card payments. What fields/tables should I check to confirm that an order has been paid, for each of these payment types?

    When I take in a cash payment, it looks like I just want to go the Zencart admin screen, go to Customers->Orders and update the status drop-down. This sets the orders_status field in the orders_products table, which my software can check. Is my approach for cash correct?

    Thanks!!!

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: How to detect if an order has been paid?

    Quote Originally Posted by chuckles_net View Post
    I am selling some software that will include a 30-day free trial. I keep track of the user's first install date and after 30 days, it forces them to activate the product.

    I installed Zencart and I added a Product Activation Key field to the orders_products table. I updated the orders class so that it generates the PAK and adds it to the table. I've created a PHP-based gateway for my software to check that field and confirm the PAK.

    Once the order has been paid, I want my gateway to allow the customer to activate the product. I'm struggling a bit with how to tell if the order has been paid. I want to allow cash, paypal and credit card payments. What fields/tables should I check to confirm that an order has been paid, for each of these payment types?

    When I take in a cash payment, it looks like I just want to go the Zencart admin screen, go to Customers->Orders and update the status drop-down. This sets the orders_status field in the orders_products table, which my software can check. Is my approach for cash correct?

    Thanks!!!
    Your common field for all orders is orders_id

    Transactions are recorded in the table orders_status_history and it includes the orders_status_id

    Depending on what your orders_status_id is set to for a completed payment, you will need to test for that id.

    Eg, my description of a fully paid and shipped order is 'Shipped / Completed' which in my case has id=3.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: How to detect if an order has been paid?

    Out-of-the-box, Zen Cart ONLY stores orders which have been approved by the payment module selected at order-time. So, if that payment module actually collects payment, then the order is paid.

    However, if you've altered the code to do differently, or have configured your payment module to NOT actually take any payment, then ALL your subsequent handling of orders (including your manual collection of payment externally) must be done yourself. In that case there's no "built-in" way to magically "know" that you've collected payment externally.
    So, as suggested above, you can simply use whatever order-status you want to denote that you've manually collected payment, and update those orders by hand.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: How to detect if an order has been paid?

    So, with DrByte's explanation

    Quote Originally Posted by DrByte View Post
    Out-of-the-box, Zen Cart ONLY stores orders which have been approved by the payment module selected at order-time. So, if that payment module actually collects payment, then the order is paid.

    However, if you've altered the code to do differently, or have configured your payment module to NOT actually take any payment, then ALL your subsequent handling of orders (including your manual collection of payment externally) must be done yourself. In that case there's no "built-in" way to magically "know" that you've collected payment externally.
    So, as suggested above, you can simply use whatever order-status you want to denote that you've manually collected payment, and update those orders by hand.
    let's look at this scenario:

    1. customer downloads your software and installs it. After 30 days your trial software stops working and your customer is prompted to return to your site to pay $xx.xx

    2. the customer pays with any payment option they can choose from and an order with unique order_id is created.

    a. the order is paid via PayPal and PayPal automatically sets the order status to 'Processing'. You can configure the PP module to set the order status to 'completed' (say the id is '3')

    b. customer creates an order and makes a direct bank deposit. You check that the money is in your account and manually set the order status to '3'

    c. etc

    3. After completion of a transaction the customer is prompted to enter the order id into your software (remember the order id is unique). Your software now queries your store database and checks if order id so-and-so has order status = '3'. If true the software is validated and continues to work. If false then you need to prompt the customer again with whatever you want to tell them.

    4. To do all of this you could create a script on your site which does the validation AND at the same time sets another value order_software_validated (true or false) in a newly created column in the table order_status_history to ensure that your customer does not give the order id to a friend who may want to cheat and use your software for free. So, in point 3. above the default value for order_software_validated is 'false' and is set to 'true' as validation is being executed. If a friend wants to use your software for free and enters the order id the software checks for payment status AND for order_software_validated = true / false. If 'true' is found then the friend can't use the software.

  5. #5
    Join Date
    Apr 2014
    Location
    western Pennsylvania
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to detect if an order has been paid?

    First off, thanks to everyone for the feedback! I think you are confirming what I was expecting, but let me clarify to be sure.

    > The reason I'm going into such detail here is that I haven't yet set up Credit Card or PayPal processing. I need to start coding, but I can't really test this stuff until I set up those payment options.

    > I haven't made any changes that affect the payment modules.

    > As DrZen says: "I won't get a Credit Card/PayPal order if the payment transaction to those entities hasn't transpired."

    > As Frank18 says: "Depending on what your orders_status_id is set to for a completed payment, you will need to test for that id." I haven't done anything to change what that value should be.

    > Looking at this statement, "the order is paid via PayPal and PayPal automatically sets the order status to 'Processing'", I read that as (for CC/PP payments), the orders_status field is set to "2" after the payment has been processed, correct?



    So, here's the scenario I envision...
    > Customer downloads and installs my software on their PC. (Note: I don't support Macs or Androids.) My software keeps track of the 30-day expiration date and stops working after that, unless they pay.

    > They make the purchase on my Zencart. My custom code generates a unique Product Activation Key (PAK) and keeps it in the orders_products table.
    A. If they pay by cash, the orders_products record is created with a value of "1" in the orders_status field. When I receive payment, I bump the orders_status field to a "2" and I email the PAK to the customer.
    B. If they pay by CC/PP, the orders_products record is created with a value of "2" in the orders_status field and the PAK is sent to the customer as part of their order confirmation.
    So from my point of view, I am using "Actiavte" where Zencart calls it "Delivered". I don't think there's any conflict there.

    > The customer uses screens in my software to activate their order. This changes the orders_status field to a "3" (via my gateway process). During that processing, it also collects the MAC address of the Network Interface Card (NIC)on the customer's computer and keeps that in the orders_products table. As I read on other websites, this seems to be the only unique property of a PC I can reliably get ahold of.

    > My software on the customer's computer sets up some things that tells it it is OK. But, it does check my gateway each time my software is invoked.
    A. If the internet or my website is unavailable, it believes the settings on the comupter.
    B. If the website is available, it double-checks the status against the NIC. If it sees their Email and PAK on a different NIC, it will suspend the software by setting the orders_status field to a new value I added, called "5".

    > To allow the customer to move my software to another computer, I have screens that allow them to "Unactivate" their copy. Doing so sets the orders_status to "4". It can then be activated on a different machine using the same email/PAK.


    I am re-using the value of "4" on the orders_status field, which originally meant "Update". Should I have done this? What does the generic "Update" status really mean to Zencart. Maybe I should have made this a "6"?

    The other thing to keep in mind is that my software is very special purpose, so I'm not worried about Joe Public hacking it. If he does, then I haven't really lost any revenue. My clients are, in general, not very computer-savy. If I was selling to "the world", I would probably want more security, but for now this approach should work for me.


    Any thoughts? Thanks again!

  6. #6
    Join Date
    Apr 2014
    Location
    western Pennsylvania
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to detect if an order has been paid?

    Rats! I just looked again at the table layouts. The orders_status field is in the orders table, not in orders_products. If a customer buys 2 or more copies at one time, then I would get one record in orders and 2 records in orders_products, correct? If so, I think I need a status field in orders_products, so that each copy is tracked separately?

    The plot thickens...

  7. #7
    Join Date
    Apr 2014
    Location
    western Pennsylvania
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to detect if an order has been paid?

    Quote Originally Posted by chuckles_net View Post
    Rats! I just looked again at the table layouts. The orders_status field is in the orders table, not in orders_products. If a customer buys 2 or more copies at one time, then I would get one record in orders and 2 records in orders_products, correct? If so, I think I need a status field in orders_products, so that each copy is tracked separately?

    The plot thickens...

    No, I get one orders_products record, with a quantity count of 2. Unless I want to limit the number that can be ordered per session. That shouldn't be a big problem for my customers. Hhhmmm...

  8. #8
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: How to detect if an order has been paid?

    Quote Originally Posted by chuckles_net View Post
    Looking at this statement, "the order is paid via PayPal and PayPal automatically sets the order status to 'Processing'", I read that as (for CC/PP payments), the orders_status field is set to "2" after the payment has been processed, correct?
    Correct - but you can set this in admin to another value

    Quote Originally Posted by chuckles_net View Post
    So from my point of view, I am using "Actiavte" where Zencart calls it "Delivered". I don't think there's any conflict there.
    You can set this to whatever you like

    Quote Originally Posted by chuckles_net View Post
    I am re-using the value of "4" on the orders_status field, which originally meant "Update". Should I have done this? What does the generic "Update" status really mean to Zencart. Maybe I should have made this a "6"?
    By default 'Pending' is '1' - Processing is '2' etc etc - you can change these to your liking in Admin > Localization > Orders Status. They then show up as options in the configuration pages of payment modules.

    The generic "Update" status IMHO is really useless, I never use it. If I need to send an update email to the customer eg notify them of a delay in delivery then I still leave the orders status at '2' which is 'Processing'. You just need to set yourself some rules what an orders status should be set to when a certain scenario has occurred.

  9. #9
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: How to detect if an order has been paid?

    Quote Originally Posted by frank18 View Post
    The generic "Update" status IMHO is really useless, I never use it. If I need to send an update email to the customer eg notify them of a delay in delivery then I still leave the orders status at '2' which is 'Processing'. You just need to set yourself some rules what an orders status should be set to when a certain scenario has occurred.
    The "Update" status is actually more specific than generic. Its primary purpose was to update the status of any expired downloadable files attached to the order. Using it for any other purpose is, as you say, relatively moot.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: How to detect if an order has been paid?

    Quote Originally Posted by DrByte View Post
    ....Its primary purpose was to update the status of any expired downloadable files attached to the order....
    Thanks - wasn't aware of this. Learned something again!

 

 

Similar Threads

  1. Replies: 3
    Last Post: 25 Sep 2013, 10:11 PM
  2. Replies: 2
    Last Post: 3 Sep 2012, 10:11 AM
  3. NEED HELP! how to change totall after order has been made?
    By lightmuch in forum General Questions
    Replies: 5
    Last Post: 28 Jan 2010, 05:14 PM
  4. How to manually tell ZenCart that an order has been paid with PayPal IPN WebStandard?
    By etilyeti in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 1 Nov 2009, 11:41 PM
  5. Remove item from order after order has been placed?
    By mes7000 in forum Managing Customers and Orders
    Replies: 2
    Last Post: 27 Aug 2008, 11:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR