Payment Plugin for Payfort

4 years ago
Hello,

I want to implement a payment plugin for my website.

I've gone through the docs and need help in implementing the Payfort API ( https://testfort.payfort.com/api/)

Another resource I found is the git repository (https://github.com/payfort/start.net)

I think it is much similar to the Paypal Standard plugin.

Please help me to start with the development.

Regards.
4 years ago
I have not seen full documentation. By far I am seeing I think you can start Authorize.net plugin and customize according to your requirement. :)
4 years ago
Hi,

Another resource is the nuget package for the Payfort API client:

http://www.nuget.org/packages/Start.Net/

It's basically the source code that you can see on Github.

Just take into consideration that the client has Newtonson.Json 7.0.1 as a dependency, so it will work fine for nopCommerce 3.70, but for earlier versions of nopCommerce you will have to either:

                 1) branch the source code from github, and build the client with the correct version of NewtonsonJson
                 or 2) add the Newtonson.Json 7.0.1 DLL in the plugin's folder - however, I think the safest is to go with 1, if you target older versions of nopCommerce.


Also, an article which I gound usefull when I started developing payment plugins:

http://docs.nopcommerce.com/display/nc/How+to+code+my+own+payment+method

Best regards
4 years ago
anik1991 wrote:
I have not seen full documentation. By far I am seeing I think you can start Authorize.net plugin and customize according to your requirement. :)


Thanks Anik for your response.

I'll try.
4 years ago
nop-payments.com wrote:
Hi,

Another resource is the nuget package for the Payfort API client:

http://www.nuget.org/packages/Start.Net/

It's basically the source code that you can see on Github.

Just take into consideration that the client has Newtonson.Json 7.0.1 as a dependency, so it will work fine for nopCommerce 3.70, but for earlier versions of nopCommerce you will have to either:

                 1) branch the source code from github, and build the client with the correct version of NewtonsonJson
                 or 2) add the Newtonson.Json 7.0.1 DLL in the plugin's folder - however, I think the safest is to go with 1, if you target older versions of nopCommerce.


Also, an article which I gound usefull when I started developing payment plugins:

http://docs.nopcommerce.com/display/nc/How+to+code+my+own+payment+method

Best regards


Thanks for your response.
Your WorldPay Plugin is similar to Payfort. I'll try using that.
4 years ago
Hello!

Thanks for the support you've provided me so far.

I'm almost there to complete the payment plugin.

I just want to know more about the below code snippet:

merchantId = _PayuPaymentSettings.MerchantId.ToString();
orderId = form["txnid"];
Amount = form["amount"];
productinfo = form["productinfo"];
firstname = form["firstname"];
email = form["email"];
hash = form["hash"];
status = form["status"];

I want to get the merchant ID from the database. I know how to retrieve the information which is stored in database. But I don't know how to get the data which is not yet stored in the database like the order ID which will be stored in database after the successful placement of order.

I've checked many payment plugins and almost every payment plugin is using the syntax mentioned below:

variable = form["variablenname"];

Like in the above mentioned code snippet order = form["txnid"];

I want to know what is this "txnid" where is this defined in the source code or the form...???
Similarly "amount", "productinfo","firstname","email","hash" and "status" where is this defined..???

Please enlighten me on this.

Regards.

Pramil Gawande
4 years ago
Hello,

In the ProcessPayment method you cannot get the orderId, because at that point the order is not yet inserted in the database.

However, you can use the property OrderGuid, which is set at that point.

The orderId is available in the PostPrococessPament method, but you only use that if you are implementing a redirect-type plugin, which I don't think you are.

Good luck
4 years ago
[email protected] wrote:
Hello!

Thanks for the support you've provided me so far.

I'm almost there to complete the payment plugin.

I just want to know more about the below code snippet:

merchantId = _PayuPaymentSettings.MerchantId.ToString();
orderId = form["txnid"];
Amount = form["amount"];
productinfo = form["productinfo"];
firstname = form["firstname"];
email = form["email"];
hash = form["hash"];
status = form["status"];

I want to get the merchant ID from the database. I know how to retrieve the information which is stored in database. But I don't know how to get the data which is not yet stored in the database like the order ID which will be stored in database after the successful placement of order.

I've checked many payment plugins and almost every payment plugin is using the syntax mentioned below:

variable = form["variablenname"];

Like in the above mentioned code snippet order = form["txnid"];

I want to know what is this "txnid" where is this defined in the source code or the form...???
Similarly "amount", "productinfo","firstname","email","hash" and "status" where is this defined..???

Please enlighten me on this.

Regards.

Pramil Gawande


Also, the form variables come from the UI (PaymentInfo.cshtml)... The string you use for the "variablename" is the Name attribute from the INPUT element
4 years ago
nop-payments.com wrote:
Hello,

In the ProcessPayment method you cannot get the orderId, because at that point the order is not yet inserted in the database.

However, you can use the property OrderGuid, which is set at that point.

The orderId is available in the PostPrococessPament method, but you only use that if you are implementing a redirect-type plugin, which I don't think you are.

Good luck


Sorry I forgot to mention that I'm creating a Redirect type plugin.

I'm referencing the CC Avenue plugin https://www.nopcommerce.com/p/962/ccavenue-payment-module.aspx

They're using the params in the controller.

Can you please check and enlighten me..???

Regards.
4 years ago
nop-payments.com wrote:
Hello,

In the ProcessPayment method you cannot get the orderId, because at that point the order is not yet inserted in the database.

However, you can use the property OrderGuid, which is set at that point.

The orderId is available in the PostPrococessPament method, but you only use that if you are implementing a redirect-type plugin, which I don't think you are.

Good luck


I've checked the PostProcessPayment method in the payment processor file of the plugin and it actually solved most of my problem. Thanks for the hint.

In the controller the Return Method has the following code snippet:

NameValueCollection Params = new NameValueCollection();
            string[] segments = encResponse.Split('&');
            foreach (string seg in segments)
            {
                string[] parts = seg.Split('=');
                if (parts.Length > 0)
                {
                    string Key = parts[0].Trim();
                    string Value = parts[1].Trim();
                    Params.Add(Key, Value);
                }
            }

            for (int i = 0; i < Params.Count; i++)
            {
                Response.Write(Params.Keys[i] + " = " + Params[i] + "<br>");
            }

            /*
            merchantId = form["Merchant_Id"];
            orderId = form["Order_Id"];
            Amount = form["Amount"];
            AuthDesc = form["AuthDesc"];
            checksum = form["Checksum"];
            */

            merchantId = Params["Merchant_Id"];
            orderId = Params["Order_Id"];
            Amount = Params["Amount"];
            AuthDesc = Params["order_status"];


Is this code collecting the response after successful/unsuccessful capture of the transaction..??? Because the order_status parameter is in the response header of the API.

Regards.