+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Payment gateway with redirect

Payment gateway with redirect

4 posts, 0 answered
  1. Robert
    Robert avatar
    70 posts
    Registered:
    05 Feb 2009
    30 Oct 2012
    Link to this post
    Hi, has anybody tried this? After looking at respective classes (Checkout, Preview) it seems I would lost CheckoutState in case of redirect. Perhaps it would be OK to store the CheckoutState in cookies or somewhere else between redirects. I would love to hear also Telerik's guidance on how to proceed in such case.
  2. Robert
    Robert avatar
    70 posts
    Registered:
    05 Feb 2009
    31 Oct 2012 in reply to Robert
    Link to this post
    Currenlty, I ended up with something like this. I modified the Confrimation step to do an automatic postback after 5 secs:

    <script type="text/javascript">
    $(function () {
    window.setTimeout(function() {
    __doPostBack('', 'paymentPostBack');
    }, 5000);
    });
    </script>

    Then I listen for a postback with special event argument in Confirmation code behind:

    if (Page.IsPostBack && Page.Request["__EVENTARGUMENT"] == "paymentPostBack")
    {
    var cookie = HttpContext.Current.Request.Cookies["shoppingCartId_payment"];

    var pr = new SporoPayPaymentRequest();
    pr.Vs = "0085416";
    pr.Ss = "1234567890";
    pr.Suma = (double)CheckoutState.Total;
    pr.Pu_predcislo = "000000";
    pr.Pu_cislo = "0013662162";
    pr.Param = "cartOrderId=" + cookie.Value;
    pr.Url = "http://localhost:60876/paymentresult";
    pr.UrlBase = "http://epaymentsimulator.monogram.sk/SLSP_SporoPay.aspx";

    if (pr.Validate())
    {
    pr.SignMessage("Z3qY08EpvLlAAoMZdnyUdQ==");
    Page.Response.Redirect(pr.PaymentRequestUrl);
    }
    }

    build the request and redirect to payment gateway (currently simulator). I also have to store order cart Id, because in confirmation, it is already reset, therefore I store it in separate cookie in Preview step:

    protected override void PlaceOrderButton_Click(object sender, EventArgs e)
    {
    var cookie = HttpContext.Current.Request.Cookies["shoppingCartId"];
    HttpContext.Current.Response.Cookies["shoppingCartId_payment"].Value = cookie.Value;

    base.PlaceOrderButton_Click(sender, e);
    }

    For capturing payment result I created new control (SimpleView) that I've placed on /paymentresult page:

    protected override void OnLoad(EventArgs e)
    {
    ISignedResponse paymentResponse = new SporoPayPaymentHttpResponse(Page.Request);
    if (((EPaymentMessage)paymentResponse).Validate())
    {
    paymentResponse.VerifySignature("Z3qY08EpvLlAAoMZdnyUdQ==");
    switch (paymentResponse.GetPaymentResponse())
    {
    case PaymentResponse.OK:
    var pms = Page.Request.QueryString["param"];
    var orderId = pms.Substring(pms.IndexOf("=") + 1);
    var manager = OrdersManager.GetManager();
    var order = manager.GetOrder(Guid.Parse(orderId));
    //set as paid
    order.OrderStatus = OrderStatus.Paid;
    manager.SaveChanges();

    break;
    }
    }
    }

    After it gets the response, it sets order as paid. The order Id is transferred back in response, I believe each gateway has this functionality. 

    This works for me, but it completely bypasses the payment system in SF.



  3. Patrick Dunn
    Patrick Dunn avatar
    237 posts
    Registered:
    03 Nov 2014
    02 Nov 2012
    Link to this post
    Hello Robert,

     Thanks for using Sitefinity.

    This feature is in planning for integration into the native eCommerce widgets however as of 5.2 we don't support it out of the box. Your method is just fine. If you want to look at additional solutions you can read through this forum post which outlines another implementation.

    Kind regards,
    Patrick Dunn
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    09 Dec 2016
    05 Nov 2012
    Link to this post
    Hello,


    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered