Custom Payment Plugin capture Mobile Number at checkout

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 Jahre weitere
Hello everyone,

I have created a custom payment plugin, at this point I need to retrieve shopper mobile number for payment processing method. How do i get the mobile number from the form at checkout? Any help? Thanks.
3 Jahre weitere
You need to implement a "PaymentInfo" page.  See as an example \Plugins\Nop.Plugin.Payments.Manual
3 Jahre weitere
Thanks for the response. Yes, I have created the form with the textbox for the client to input mobile number. I want to be able to parse the mobile number into the ProcessPayment in the IPaymentMethod, also the orderId not the orderGuid.

Regards,
3 Jahre weitere
The data structure that is passed into ProcessPayment is ProcessPaymentRequest
There is field called CustomValues which could probably be used to carry the Phone number through to ProcessPayment

RE: orderId - When ProcessPayment routine is called then the order has not been created yet so there is no Order Number
PostProcessPayment routine is called after the order is created
3 Jahre weitere
Thanks Yidna,

I've been able to retrieve the form values through the GetPaymentInfo method  but I need those values in the ProcessPayment method, I'm unable to pull the form values there. Do I have to create session variables?
3 Jahre weitere
Yes you can use session variables
Look at Presentation\Nop.Web\Controllers\CheckoutController.cs
which Sets
                HttpContext.Session.Set<ProcessPaymentRequest>("OrderPaymentInfo", processPaymentRequest);
and Gets
                var processPaymentRequest = HttpContext.Session.Get<ProcessPaymentRequest>("OrderPaymentInfo");
the OrderPaymentInfo
3 Jahre weitere
I think the GetPaymentInfo method can put values in the "field called CustomValues" that Yidna mentioned.

   var paymentRequest = new ProcessPaymentRequest();
   paymentRequest.CustomValues.Add("...", ...);
3 Jahre weitere
Yidna wrote:
The data structure that is passed into ProcessPayment is ProcessPaymentRequest
There is field called CustomValues which could probably be used to carry the Phone number through to ProcessPayment

RE: orderId - When ProcessPayment routine is called then the order has not been created yet so there is no Order Number
PostProcessPayment routine is called after the order is created


Perhaps I wasn't very clear with my question. Here is my code below


public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new ProcessPaymentResult();

            var NewpaymentInfo = new ProcessPaymentRequest();
            Dictionary<string, object> customValues = new Dictionary<string, object>();
NewpaymentInfo.CustomValues.Add("MobileNumber",form["MobileNumber"]);

            return result;
        }


Hopefully with this you can point me in the right direction. I want to insert the mobile number from the form to be used in this ProcessPayment method.

Do i have to use another method instead?
3 Jahre weitere
RE: "....insert the mobile number from the form to be used in this ProcessPayment method."

You have it backwards.  As per my above, '.... GetPaymentInfo method can put values in the "field called CustomValues" ...'.   Then, in ProcessPayment you would reference the CustomValues.

(Also, I don't think you need to "new" the Dictionary.  An instance should already exist; just add the key/value)
3 Jahre weitere
Sorry New York, I don't quite get you.

I have instantiated and supplied the values into the custom values in the GetPaymentInfo. Pardon me but how do i reference them in the ProcessPayment method? (I'm new to MVC :( ) I have failed a number of times to achieve this, even attempted session variables.

Kindly refer my previous post, see where I'm getting it wrong
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.