joelbhansen / MerchelloQuickPayProvider

QuickPay Payment Provider for Merchello
MIT License
2 stars 0 forks source link

I get issue at quickpay #2

Open gitbaltech opened 9 years ago

gitbaltech commented 9 years ago

Hello

we get this error when when use quickpay can you advice how we fix that issue

Value cannot be null. Parameter name: task

joelbhansen commented 9 years ago

Hello gitbaltech

Thank you for your message. I'd like to help, but I need a little more information.

Which version of Merchello are you running? Could you post the stacktrace? At what point do you get the error? (e.g. Is it while installing the plugin, setting it up or attempting to process a payment?)

gitbaltech commented 9 years ago

Thanks Joel

i get this issue when process payment

i am using Merchello_1.13.0 and demo shop Merchello.Bazaar.StoreOnly_1.13.0

Joel you have any umbraco setup with Merchello and quickpay example working ?

gitbaltech commented 9 years ago

Value cannot be null.pdf

here are error page we get

joelbhansen commented 9 years ago

Yes, I have made a webshop for a client based on Umbraco 7.2.x and Merchello 1.9.x using this QuickPay payment provider. I didn't base it on the Bazaar demo store though.

Thank you for providing the detailed error message. I will look into it.

gitbaltech commented 9 years ago

Joel you have any demo simple code for that ?

gitbaltech commented 9 years ago

can you give me step for setup quick payment also let me know if need to do any custome chnges

joelbhansen commented 9 years ago

Yes, below is the relevant code from the working webshop.

In the checkout controller action, I have this which is run on "confirm purchase". (I have left out any code lines not strictly necessary, such as handling taxes, discounts and shipping)

var invoice = CurrentCustomer.Basket().SalePreparation().PrepareInvoice();
MerchelloContext.Current.Services.InvoiceService.Save(invoice);

var invoiceNumber = invoice.InvoiceNumber.ToString("F0").PadLeft(4, '0');
var paymentCurrency = "DKK";
var paymentAmount = (invoice.Total * 100).ToString("F0");
var continueUrl = GetSuccessUrl(invoiceNumber);
var paymentChecksum = GetChecksum(invoiceNumber, paymentAmount, paymentCurrency, continueUrl);

var returnValues = new PaymentValues() {
  success = true,
  invoiceNumber = invoiceNumber,
  paymentAmount = paymentAmount,
  paymentChecksum = paymentChecksum,
  paymentContinueUrl = continueUrl,
  paymentCancelUrl = CancelUrl,
  paymentCallbackUrl = CallbackUrl,
  paymentCurrency = paymentCurrency
};

return Json(returnValues);

You can find the GetChecksum method at https://github.com/joelbhansen/MerchelloQuickPayProvider

That link will also show you the form you need on your checkout page, to submit (POST) the right data to the QuickPay payment window.

Does it make sense, or am I writing gibberish?

gitbaltech commented 9 years ago

img1

please check screen shot i see payment mathod value null

gitbaltech commented 9 years ago

Joel

can you ask how can i get Merchello 1.9.x this version source code ?

joelbhansen commented 9 years ago

All right, that screenshot is a great help.

The payment provider doesn't provide the expected information - so the value is null. I didn't use it the way you do, so I never experienced the need.

I don't think using Merchello 1.9.x will help you. I'm building a new webshop using the very same payment provider on a new Merchello 1.13.0 webshop - with my way of using it, it works fine.

I will fix it when I get a chance to.

gitbaltech commented 9 years ago

Hello Joel

https://github.com/Merchello/Samples/tree/master/Samples/How-To-Articles/Checkout

can you check this simple can i use this ?

you have any simple project like this ?

gitbaltech commented 9 years ago

img2

Hello please check i get issue at here img3

gitbaltech commented 9 years ago

Hello Joel

is it possible can you send your checkout controller code ?

or also if your shop code provide if possible . i am try to create a shop using quickpay payment gateway

joelbhansen commented 9 years ago

Hello gitbaltech

All that is needed from the checkout controller, was provided in an earlier comment on this thread.

The QuickPay Payment Provider works differently from the other payment providers. Thus the implementation has some different requirements. I will improve the provider when I get a chance to do so.

In the meantime, what you need in the checkout controller is this:

public JsonResult PlaceOrder()
    var invoice = CurrentCustomer.Basket().SalePreparation().PrepareInvoice();
    MerchelloContext.Current.Services.InvoiceService.Save(invoice);

    var invoiceNumber = invoice.InvoiceNumber.ToString("F0").PadLeft(4, '0');
    var paymentCurrency = "DKK";
    var paymentAmount = (invoice.Total * 100).ToString("F0");
    var continueUrl = GetSuccessUrl(invoiceNumber);
    var paymentChecksum = GetChecksum(invoiceNumber, paymentAmount, paymentCurrency, continueUrl);

    var returnValues = new PaymentValues() {
      success = true,
      invoiceNumber = invoiceNumber,
      paymentAmount = paymentAmount,
      paymentChecksum = paymentChecksum,
      paymentContinueUrl = continueUrl,
      paymentCancelUrl = CancelUrl,
      paymentCallbackUrl = CallbackUrl,
      paymentCurrency = paymentCurrency
    };

    return Json(returnValues);
}

The error you're seeing, is triggered by the call to AuthorizePayment(). It won't be a problem as soon as you implement the code as outlined above and at https://github.com/joelbhansen/MerchelloQuickPayProvider.

gitbaltech commented 9 years ago

current i have this fuction for savepayment can you ask me where i need to update your code

[HttpPost] public ActionResult SavePayment(PaymentInformationModel model) { // has error occurred bool error = false;

        // do we raise events
        bool raiseEvents = false;

        // payment attempt result information
        IPaymentResult attempt = null;

        // get payment method
        var paymentMethod = Payment.GetPaymentGatewayMethodByKey(model.PaymentMethodKey).PaymentMethod;

        // get customer, items
        var preparation = base.Basket.SalePreparation();

        // Save the payment method selection
        preparation.SavePaymentMethod(paymentMethod);

        // make sure there is a billing address - it can be empty - it just has to exist
        if (!preparation.IsReadyToInvoice()) return RedirectToUmbracoPage(BasketPageId);

        // AuthorizePayment will save the invoice with an Invoice Number.
        attempt = preparation.AuthorizePayment(paymentMethod.Key);

        // if payment isn't successful, grab some information
        if (!attempt.Payment.Success)
        {
            error = true;

            // TBD - Not in Merchello yet
            // Notification.Trigger("OrderConfirmationFailure", attempt, new[] { preparation.GetBillToAddress().Email });

            _log.CreateAuditLogWithKey("Checkout failed - attempt payment failure", preparation.Customer.ExtendedData);
        }
        else
        {
            // trigger the order notification confirmation
            Notification.Trigger("OrderConfirmation", attempt, new[] { preparation.GetBillToAddress().Email });
        }

        // grab final content page
        var receipt = Umbraco.TypedContent(ReceiptId);

        // redirect so that url has invoice number (encrypted) in address bar
        // this feels clunky and unsafe but illustrative all the same
        return
            Redirect(string.Format("{0}?inv={1}", receipt.Url,
                                   attempt.Invoice.Key.ToString().EncryptWithMachineKey()));
    }
gitbaltech commented 8 years ago

Joel Hansen

Is there have any simple umbraco code there working quickpay payment mathod?