Results 1 to 5 of 5

Thread: Payment Gatway - PayFast

  1. #1
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Payment Gatway - PayFast

    I'm developing a payment gateway for the South African payment processor PayFast. I've got it all up and running, but I'm running into a snag when it comes to the order in which things are done in Isotope.

    1. Payment Gateway configured to "pending"
    2. Checkout/Review
    3. => Payment gateway
    4. Payment Gateway initiates ITN (postpayment process, set's order to complete).
    5. Payment Gateway returns to Checkout/Complete, which sets order back to "pending" (from 1)

    Even the other way around doesn't work either, if configured to "complete" payment gateway tries to set invalid payments to "on_hold" and then the checkout/complete sets it back to "complete" again.

    The postsaleProcess() is called async by the payment gateway, so you can't know when it will complete. I think the only way is to use the writeOrder hook, which happens AFTER the order has been initialised with the default payment gateway's status. Anyone know what base class to make it? or possibly any other ideas?

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Payment Gatway - PayFast

    Perhaps I understand this the wrong way, but isn't that field a order status rather then a payment status? I mean that you are using it in a way the staus was not intended for. What happens when the payment is unsuccessful? I assume the status is not changed?

    Also see here (and especially look at my third post): https://github.com/isotope/core/issues/612. I eventually asked to make an elaborate order history. It would allow to add payment states with a timestamp and have a chronological list that also will log that for example the customer went to the gateway but never returned, or returned successfully much later. Just whatever your module makes of it...

  3. #3
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Payment Gatway - PayFast

    Yes. OK. That's true, but if for some reason the redirect back from PayFast is interrupted, then the transaction is not marked as complete (when you reach /checkout/complete), so no order is generated, however the payment could have been successful and the ITN which is called from the payment gateway to the isotope postsale(). The ITN is the ONLY way to really determine if the payment was successful, however if I never land on the checkout/complete, then the payment being complete, cannot change the order status.

    Then I completely misunderstand the way payment gateways in isotope work. Since there is no dev documentation that I know of, I've had to puzzle it out from the other payment gateways.

    So, basically I screwed myself here by saying yes to the client. Ugh. :roll:

  4. #4
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Payment Gatway - PayFast

    To be honest I still haven't figured the entire process out. In many stores I am able to complete an order and from the client portal open any order to go to the payment gateway. That is something you would need, right? In that case you would always have your module report success, but set payment status to not complete. You would have to add an option to retry the payment for logged in clients. Not sure what else you need to look at (e-mails and all that are sent on completed orders)

    More elaborate documentation would be nice...

  5. #5
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Payment Gatway - PayFast

    I just set the payment gateway return url to point to step/complete to flag the order as complete. Then while busy making the payment, the ITN runs from the gateway – usually way before the checkout it complete, because is called immediately after payment and the gateway adds a few seconds before redirecting. Then I set the date_payed (old spelling error on older version) to the date, and I add another payment value of "status"=VALID. This can only be set by the payment gateway ITN script (which calls postsale.php&mod=xx&id=xx).

    When I return to the checkout step complete. all the payment gateway does it flags the order as complete and the order e-mail is sent out. Then I have a writeOrder HOOK to run just before the order e-mail is sent. Getting this to automatically send out the voucher if the payment is valid, the order is complete and the date_payed is set.

    Now I'm busy setting up a manual process for the voucher, just in case something went wrong, then the BE user can also send the voucher.

    THIS is where I'm having lots of problems. To setup that e-mail info in the BE from an order is pretty nasty. The payment gateway (e.g. $objOrder->Payment ) doesn't use the order information in it's variable retrieval, it uses the Cart? Ugh. All I wanted to do was to render the same cart_html that the order e-mail uses, but I guess I'll have to skip that. just give a breakdown of the products and leave it like that (otherwise the surcharges are empty).

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
  •