Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anton 135 posts 186 karma points
    Aug 24, 2015 @ 21:42
    Anton
    0

    How I can finalize order?

    I have payment method that have only form, maybe I need finalize url that will redirect to after order will paid. How I can do this?

    <form method="post" action="testurl" id="form" name="form">
    
                        <input type="hidden" name="PSPID" value="test">
                        <input type="hidden" name="ORDERID" value="@orderCartNumber">
                        <input type="hidden" name="AMOUNT" value="@totalPrice">
                        <input type="hidden" name="CURRENCY" value="SAR">
                        <input type="hidden" name="LANGUAGE" value="en-US">
                        <input type="hidden" name="SHASIGN" value="@resultSHA1String">
    
    
                         <input type="submit" value="Accept and pay" id="submit" class="btn btn-success" name="SUBMIT">
    
  • Anders Burla 2560 posts 8256 karma points
    Aug 25, 2015 @ 09:54
    Anders Burla
    0

    Could you use the invoice payment provider. That just approves the order - properly what you want to do.

    Kind regards

    Anders

  • Anton 135 posts 186 karma points
    Aug 25, 2015 @ 12:39
    Anton
    0

    Yes, I set such payment provider, but I dont understand how it finalize order? because now it doesnt work. My form send request to payfort payment system, than customer submit his credit card info and if all correct it redirect to site and backet isnt empty and we doesnt have order in the list in teacommerce

  • Anders Burla 2560 posts 8256 karma points
    Aug 25, 2015 @ 12:57
    Anders Burla
    1

    If you use Payfort you need to make a new payment provider for Tea Commerce to get it work. See this open source project: https://github.com/TeaCommerce/Payment-providers

  • Anton 135 posts 186 karma points
    Aug 25, 2015 @ 13:07
    Anton
    0

    Ok, Thank you! I will try

  • Anton 135 posts 186 karma points
    Aug 25, 2015 @ 21:14
    Anton
    0

    Does anybody have example with payfort payment provider?

  • Anders Burla 2560 posts 8256 karma points
    Aug 26, 2015 @ 06:20
    Anders Burla
    0

    Hi Anton

    The first part you should do is to make the GeneratePaymentForm method work. When that works and it redirects to Payfort - next is to figure out how Payfort makes a callback. If it doesnt make that - then override FinalizeAtContinueUrl and then Tea Commerce will execute the callback method when the continue url is hit.

    Kind regards

    Anders

  • Anton 135 posts 186 karma points
    Aug 26, 2015 @ 20:12
    Anton
    0

    Thank you, I will try

  • Anton 135 posts 186 karma points
    Aug 31, 2015 @ 11:28
    Anton
    0

    I got teaCommerceContinueUrl value from method GenerateHtmlForm and in tea commerve I got message "Thank you for your order" and now backet is empty, but in backend this order is not Authorized and Payment state is Initialized.

    How I can set it like Authorized?

    <form action="http://www.kahve.sa/base/TC/PaymentCallback/1/Payfort29/d1c0d5ed-fa85-4a0c-b7ac-cbee36e2b260/b1a2a33ecac116b02add12cc20595faf33de53cbd730ab44e3f4168b5819c973.aspx" method="post"><input type="submit" class="btn btn-success" value="Accept and pay"></input></form>
    
  • Anders Burla 2560 posts 8256 karma points
    Aug 31, 2015 @ 11:40
    Anders Burla
    0

    The backet is moved to "finalized" in the frontend because a callback can be several minutes to get from a server to server. Then you need to use the continue url as the callback url OR if the gateway support a true callback that is the way to go. What is the case with the gateway you use?

  • Anton 135 posts 186 karma points
    Aug 31, 2015 @ 12:27
    Anton
    0

    What do you mean about gateway? I added new class to TeaCommerce.PaymentProviders

     [PaymentProvider("Payfort29")]
    public class Payfort : APaymentProvider
    {
        public override bool FinalizeAtContinueUrl { get { return true; } }
    
        public override IDictionary<string, string> DefaultSettings
        {
            get
            {
                Dictionary<string, string> defaultSettings = new Dictionary<string, string>();
                defaultSettings["PSPID"] = "blatesrt";
                defaultSettings["ORDERID"] = string.Empty;
                defaultSettings["AMOUNT"] = string.Empty;
                defaultSettings["CURRENCY"] = "SAR";
                defaultSettings["LANGUAGE"] = "en-US";
                defaultSettings["SHASIGN"] = string.Empty;
                defaultSettings["continue_url"] = string.Empty;
                return defaultSettings;
            }
        }
    
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
    
            string orderCartNumber = order.CartNumber;
            string totalPrice = order.TotalPrice.Value.FormattedWithoutSymbol.Replace(".", string.Empty);
    
            string salt = "bla";
            string inputString = "AMOUNT=" + totalPrice + salt + "CURRENCY=SAR" + salt + "LANGUAGE=en-US" + salt + "ORDERID=" + orderCartNumber + salt + "PSPID=kahvetest" + salt;
    
            var hash = (new System.Security.Cryptography.SHA1Managed()).ComputeHash(System.Text.Encoding.UTF8.GetBytes(inputString));
            string resultSHA1String = string.Join("", hash.Select(b => b.ToString("x2")).ToArray());
    
            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = "https://secure.payfort.com/ncol/test/orderstandard.asp"
            };
    
            htmlForm.InputFields["PSPID"] = settings["PSPID"];
    
            htmlForm.InputFields["ORDERID"] = order.CartNumber;
    
            htmlForm.InputFields["AMOUNT"] = order.TotalPrice.Value.FormattedWithoutSymbol.Replace(".", string.Empty);
    
            htmlForm.InputFields["CURRENCY"] = settings["CURRENCY"];
    
            htmlForm.InputFields["LANGUAGE"] = settings["LANGUAGE"];
    
            htmlForm.InputFields["SHASIGN"] = resultSHA1String;
    
            htmlForm.InputFields["continue_url"] = teaCommerceContinueUrl;
    
            htmlForm.InputFields["cancelurl"] = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;
    
            return htmlForm;
        }
    
        public override string GetContinueUrl(Order order, IDictionary<string, string> settings)
        {
            settings.MustNotBeNull("settings");
            settings.MustContainKey("continue_url", "settings");
    
            return settings["continue_url"];
        }
    
        public override string GetCancelUrl(Order order, IDictionary<string, string> settings)
        {
            return "";
        }
    
        public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary<string, string> settings)
        {
            CallbackInfo callbackInfo = null;
    
            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("SHASIGN", "settings");
    
                string transaction = order.CartNumber;
                string strAmount = order.TotalPrice.Value.FormattedWithoutSymbol.Replace(".", string.Empty);
    
                decimal totalAmount = decimal.Parse(strAmount, CultureInfo.InvariantCulture);
                callbackInfo = new CallbackInfo(totalAmount, transaction, PaymentState.Authorized);
    
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Log(exp, "Payfort(" + order.CartNumber + ") - Process callback");
            }
    
            return callbackInfo;
        }
    
        public override string GetLocalizedSettingsKey(string settingsKey, CultureInfo culture)
        {
            switch (settingsKey)
            {
                case "continue_url":
                    return settingsKey + "<br/><small>e.g. /continue/</small>"; 
                default:
                    return base.GetLocalizedSettingsKey(settingsKey, culture);
            }
        }
    
    }
    
  • Anton 135 posts 186 karma points
    Aug 31, 2015 @ 12:30
    Anton
    0

    Can you write example of this? "Then you need to use the continue url as the callback url"

  • Anders Burla 2560 posts 8256 karma points
    Aug 31, 2015 @ 12:31
  • Anton 135 posts 186 karma points
    Aug 31, 2015 @ 12:35
    Anton
    0

    I have public override bool FinalizeAtContinueUrl { get { return true; } }

  • Anton 135 posts 186 karma points
    Aug 31, 2015 @ 12:36
    Anton
    0

    How should I use ContinueUrl like path in browser or like action in form? or it doesnt matter, but if so I dont understand why it didn`t finalize order in backend

  • Anders Burla 2560 posts 8256 karma points
    Aug 31, 2015 @ 12:38
    Anders Burla
    0

    You have this line:

    htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

    So it looks like your provider supports true callback - then don't use FinalizeAtContinueUrl. Now you need to be sure your code is on a live domain so the payford gateway can make a server to server call. Then write some info to the disk in the callback to see things work and that they callback is executed.

    Kind regards

    Anders

  • Anton 135 posts 186 karma points
    Sep 01, 2015 @ 11:28
    Anton
    0

    Can you explain why do we need method ProcessCallback? maybe here I have something wrong and why It returned CallbackInfo? what should be correct CallbackInfo?

    public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary<string, string> settings)
        {
            CallbackInfo callbackInfo = null;
    
            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("SHASIGN", "settings");
    
                string transaction = order.CartNumber;
                string strAmount = order.TotalPrice.Value.FormattedWithoutSymbol.Replace(".", string.Empty);
    
                decimal totalAmount = decimal.Parse(strAmount, CultureInfo.InvariantCulture);
    
    
                callbackInfo = new CallbackInfo(Convert.ToDecimal(totalPrice), transaction, PaymentState.Authorized);
    
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Log(exp, "Payfort(" + order.CartNumber + ") - Process callback");
            }
    
            return callbackInfo;
        }
    
  • Anders Burla 2560 posts 8256 karma points
    Sep 02, 2015 @ 06:23
    Anders Burla
    0

    Process Callback is the one that makes sure the order is finalized. So return a CallbackInfo object with the right info and when the callback is executed the order will be finalized. You would also have security features in the callback with hashes to make sure that the info is from the right origin.

    Kind regards

    Anders

  • Anton 135 posts 186 karma points
    Sep 02, 2015 @ 21:46
    Anton
    0

    Do you know somebody who can help us with this? because it doesn`t want to finalize order only cart is empty, or what part of code I can show you?

  • Anders Burla 2560 posts 8256 karma points
    Sep 03, 2015 @ 06:32
    Anders Burla
    0

    Hi Anton I don't know anyone that can help with this except us at Tea Commerce. Properly other people that can help - I just don't have the contact to them and can force them to help on the forum :)

    Please read about our Confidence product which is what gives you the help you need for this I think: https://teacommerce.net/products/confidence/

    Kind regards

    Anders

  • Anton 135 posts 186 karma points
    Sep 03, 2015 @ 09:24
    Anton
    0

    Thank you, but I spent a lot time and I cannot fix this so I don`t want to use tea commerce any more

  • Anders Burla 2560 posts 8256 karma points
    Sep 03, 2015 @ 09:28
    Anders Burla
    0

    I'm sorry to hear that. Is your callback - NEVER called? Try add logging at the top of the callback method and check the umbraco log file. If the callback is never called then your site isnt available for the gateway on a live URL or the gateway never make the call. Tried to debug that?

    Kind regards

    Anders

Please Sign in or register to post replies

Write your reply to:

Draft