Creating a new payment method

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hi,
i trying to make a new payment method for nopcommerece. i have lookad around on the
samples and then tried to make it in same structure.

i have int the templates made a dir named Payson as the provider i want to integrate to.
in this dir i have made 3 files.
-PaymentModule.ascx
-PaymentModule.ascx.cs
-PaymentModule.ascx.designer.cs
all these three are copied from the twocheckout. but i have changed the name  so it have Payson insted of twocheckout.

i have also success ful made the admin pages so i can save and made changes to the module.

my problem is when i have compiled a dll or even run it in debug it never hit my payment module class.

so in debug and i click in to checkout and click throu the steps the store halt and throw an error in

line 48 in checkoutpaymentmethod.ascx.cs
decimal paymentMethodAdditionalFee = PaymentManager.GetAdditionalHandlingFee(paymentMethod.PaymentMethodId);

and say the paymentmethod additionalfee cannot be null.

this is the class name i have made in the DB'
NopSolutions.NopCommerce.Payment.Methods.Payson.PaysonPaymentProcessor, Nop.Payment.Payson

user template path
~\Templates\Payment\Payson\PaymentModule.ascx

at the moment i have not put in the code for the payment processor because i want to fix this error before.
so below you can find the source of the dll

using System;
using System.Collections.Generic;
using System.Text;
using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Orders;
using NopSolutions.NopCommerce.BusinessLogic.CustomerManagement;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Payment;


namespace NopSolutions.NopCommerce.Payment.Methods.Payson
{
    public class PaysonPaymentProcessor : IPaymentMethod
    {
        #region IPaymentMethod Members

        bool IPaymentMethod.CanCapture
        {
            get { throw new NotImplementedException(); }
        }

        bool IPaymentMethod.CanRefund
        {
            get { throw new NotImplementedException(); }
        }

        bool IPaymentMethod.CanVoid
        {
            get { throw new NotImplementedException(); }
        }

        void IPaymentMethod.CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            throw new NotImplementedException();
        }

        void IPaymentMethod.Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            throw new NotImplementedException();
        }

        decimal IPaymentMethod.GetAdditionalHandlingFee()
        {
            return decimal.Zero;
        }

        PaymentMethodTypeEnum IPaymentMethod.PaymentMethodType
        {
            get { throw new NotImplementedException(); }
        }

        string IPaymentMethod.PostProcessPayment(Order order)
        {
            throw new NotImplementedException();
        }

        void IPaymentMethod.ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
        {
            throw new NotImplementedException();
        }

        void IPaymentMethod.ProcessRecurringPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
        {
            throw new NotImplementedException();
        }

        void IPaymentMethod.Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            throw new NotImplementedException();
        }

        RecurringPaymentTypeEnum IPaymentMethod.SupportRecurringPayments
        {
            get { throw new NotImplementedException(); }
        }

        void IPaymentMethod.Void(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}

Hope someone have time to help me i will be very grateful for that.
I have torn my hair for 3 days now.
13 years ago
I Solved it by my self. the problem right in front of me all the time.
it always the simple problems that are hard to find.
13 years ago
[email protected] wrote:
I Solved it by my self. the problem right in front of me all the time.
it always the simple problems that are hard to find.


nice to hear that man
13 years ago
.. be even nicer if he shared the fix :-)
13 years ago
[email protected] wrote:
I Solved it by my self. the problem right in front of me all the time.
it always the simple problems that are hard to find.


be nicer if he share the fix. :)
13 years ago
Hello sir
At first sorry for bad english.
I downloaded nopcommerce 1.6 .For get more experience I installed its locally.
I downloaded FirstData payment from nopcommerce website for payment. I copied any folder and files in their place like other payments.Now when I create a new payment in Class Name field what I should to enter.
Please Help Me If You Can
13 years ago
Hi,
and sorry to not reply on the questions earlier.
below i have make a short description of make a gateway.

To make a payment module i recomend you to first add a new class library to
your nopCommerce project
("Right click on Solution in solution explorer" -> " New Project" -> "Class library")

Give the Class library the name "Nop.Payment.YOURGATEWAY" and click ok.

now you have a Class library in you nop project named Nop.Payment.YourGateway.
rename Class1.cs in you Class library to YOURPAYMENTprocessor.cs

add these files to your reference in your class.

nop.businesslogic.dll (found in bin folder of shop)
nop.common.dll (found in bin folder of shop)

you should add these usings in youpaymentprocessor.cs

using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Orders;
using NopSolutions.NopCommerce.BusinessLogic.CustomerManagement;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Payment;

make a public function named

public  YourgatewayPaymentProcessor()
Here you  can read in settings from database for your gateway.

now connect your class to IPaymentMethod

change  "public class YourPaymentProcessor"
to "public class TestPaymentProcessor :  IPaymentMethod

right click on IPaymentMethod and click "Implement Interface" -> "Implement Interface"
now visual studio make all functions neaded to make a payment method.

in  CanCapture set
get
            {
                return false;
            }


and in GetAdditionalHandlingFee()

set you handling fee or set it to
return decimal.Zero;
to avoid errors.

in PaymentMethodType set
get
            {
                return PaymentMethodTypeEnum.Standard;
            }


and in PostProcessPayment(Order order) here you set the code to make a post to your
gateway with the information.


in ProcessPayment you set
processPaymentResult.PaymentStatus = PaymentStatusEnum.Pending;


Now you should have a working payment module.
now add this class to the reference of your shop.

Make a nice page to edit settings for your gateway.
(you can use any other paygateway file in admin/payment as guide)

Make a return page to set the payment to OK and show message to
customer.

Also add your gateway to the payment in adminpages

Click add new and
Give the payment method a
Name,Visible name,Description,the path of config pages,user tamplate.
in classname you add
NopSolutions.NopCommerce.Payment.Methods.Yourpaymentgateway.PaymentgatewayProcessor, Nop.Payment.Yourgateway

-give it a System keyword
-check Active
-set a display order

-Save
12 years ago
Why, in the administration de payment form not recognize the class, I followed step to step by always I have this:

Supports capture: Unknown
Supports refund: Unknown
Supports partial refund: Unknown
Supports void: Unknown
Supports recurring payments: Unknown

Thanks for your answer.
12 years ago
I forget say that PaymentMethodType always has Uknown.

I believe that is the poblem, but I don´t know how to solve.

.
12 years ago
I have the same error
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.