Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default New payment module with javascript call

    Hi!

    We're building a new payment module that is a type that it brings the payment interface on the top of the site / webshop. So, in which point we need to make the call that we are not too early? We made it with the process button but then the customer pays but there is no action to make it marked paid.

    Another issue is how to call for the javascript in a way that we can pick the values like price from the payment module / system? and in which function in the payment module we should activate this call that is sending the payment details for the payment service provider?

    <script type="text/javascript" src="https://pay.paymentserverattheprovider.com/js?merchant=demo&amp;item=someitem&amp;price=$price_string&amp;sig=<?php echo md5("$item&$price_string&01234567890123456789");?>"></script>

    Payment provider gives a POST sig that we can evaluate that is the answer for the payment. On which function / payment module part this would be put that we can mark the order paid for ZC?

    So, the customer must first confirm the order like in any other payment module but in which page we stay then since this payment module doesn't bring the customer into any other site and back from there. The interface comes on the top of this ZC shop.

    What is actually the order of the processes that ZC does? The wiki documentation and API doesn't really give answers for these.
    I may be blond but at least I found Zen.

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: New payment module with javascript call

    Unfortunately your question is very difficult to understand, but I wonder if that's because there's some confusion behind it about how javascript works.

    You can't put a call in your php to a javascript routine (well that's not a 100% accurate, you can if your running a javascript server on your web server, but that would be unheard of for a Zen Cart installation).

    PHP runs on your web server, whereas javascript runs in your visitors' browsers. So you can insert a call to load javascript in your PHP (though Zen Cart has better ways to do this, documented in the docs folder that comes with the download), but you need an event in the visitors' browser to trigger its execution such as a page loading or a button being clicked.

    Also, since not everybody has javascript turned on, your payment module needs to function even without the javascript. The javascript should really be used only to improve the user experience, not to deliver it.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default Re: New payment module with javascript call

    Quote Originally Posted by kuroi View Post
    - -
    PHP runs on your web server, whereas javascript runs in your visitors' browsers. So you can insert a call to load javascript in your PHP (though Zen Cart has better ways to do this, documented in the docs folder that comes with the download), but you need an event in the visitors' browser to trigger its execution such as a page loading or a button being clicked.

    Also, since not everybody has javascript turned on, your payment module needs to function even without the javascript. The javascript should really be used only to improve the user experience, not to deliver it.
    Thanks Kuroi!

    Unfortunately the payment provider has built their system in a way that it does require the javascript in order to function. Of course most of people does have it enabled but I do agree with you although can't help it now.

    I found out that the javascript can be put to folder includes -> modules -> pages -> checkout_confirmation and so far looks promising. Now we just need to build the payment module again (we have several other tries for this module already earlier).

    How do we limit that the javascript won't load using all different payment methods. We realised that now it loads even if choosing "money order". So we need to get some if sentence that only when choosing this payment method it loads else not. How can I tell to the system this?
    I may be blond but at least I found Zen.

  4. #4
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default Re: New payment module with javascript call

    if we put in the javascript that is inside of includes -> modules -> pages -> checkout_confirmation
    $price_string, it doesn't find it even if it is defined in the selected payment module.

    Total price can be found if we put <?php number_format($order->info['total'], 2);?> but not if we use the one defined in the payment module as $price_string. So the ZC standard parameters can be picked. How do we pick our own ones from the folder includes -> modules -> payment to be used inside the javascript file of includes -> modules -> pages -> checkout_confirmation?
    We need also similar way other parameters picked up from the module for the same javascript call.
    I may be blond but at least I found Zen.

  5. #5
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default Re: New payment module with javascript call

    Quote Originally Posted by ellivir View Post
    if we put in the javascript that is inside of includes -> modules -> pages -> checkout_confirmation
    $price_string, it doesn't find it even if it is defined in the selected payment module.

    Total price can be found if we put <?php number_format($order->info['total'], 2);?> but not if we use the one defined in the payment module as $price_string. So the ZC standard parameters can be picked. How do we pick our own ones from the folder includes -> modules -> payment to be used inside the javascript file of includes -> modules -> pages -> checkout_confirmation?
    We need also similar way other parameters picked up from the module for the same javascript call.
    ok, there is a header_php.php file in this respective page folder "checkout_confirmation" and when we put the parameters there the system seems to find them.
    Now we can pay the products with the payment interface, the sum and other values are passed to the payment provider. From there it comes an answer as POST value of a signature that we need to compare in the server and if that is correct match, the payment was successful. In which function in the payment module this comparison should happen and how do we let the system to proceed when pushing the button "confirm" the order? We should somehow tell what to do when the POST value is correct (CHECKOUT SUCCESS) and when it is not correct to go back (CHECKOUT PAYMENT).
    I may be blond but at least I found Zen.

  6. #6
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default Re: New payment module with javascript call

    ok, now we added this

    $this->form_action_url = zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false); // Page to go

    and we started to get order confirmation emails but as a customer we are not yet leaving from the checkout confirmation page and for the customer it looks like the payment was not registered. The customer may click again the confirm button and then it comes another email.

    We have privately made a new payment module for a system of small payment provider. Now finally we got into the checkout confirmation page and the payment happens on the top of that page (without leaving the site) and even the order email arrives to a test customer.
    BUT the customer can't go from the checkout confirmation page to the success page. It is going back to the payment page and then when going further it makes another order confirmation by email but the customer doesn't see the success page and for him it looks like it didn't work.

    From the payment module:
    Is our function after_process like this ok (is this the right place for this?):

    function after_process() {
    if ($_POST[“sig”] == md5( $secret_key . “&” . $pricestring . “&” . $items )) {
    $_SESSION['cart']->reset(true);
    unset($_SESSION['cart']);
    $_SESSION['order_created'] = '';
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS));
    } else {
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT));
    }
    }

    Would anybody have any idea where to tell for the system that now the order is process and it was a success?
    I may be blond but at least I found Zen.

 

 

Similar Threads

  1. How to call specific images with javascript?
    By GodfatherAntiques in forum General Questions
    Replies: 0
    Last Post: 18 Jan 2011, 08:25 PM
  2. Problems with new payment module
    By Dayo in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 1 Feb 2008, 11:47 PM
  3. Checkout probelms with new payment module
    By Namheul in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 1 Mar 2007, 12:18 AM

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