Copied to clipboard

Flag this post as spam?

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


  • Tobias Lopez 64 posts 210 karma points
    Sep 14, 2015 @ 07:58
    Tobias Lopez
    0

    Merchello and SaferPay

    Hi.

    I need some help for the saferpay payment provider. The process should look like:

    1. Add Items, add address, choose shipping/payment
    2. Click "confirm Order" - redirect to saferpay
    3. pay on saferpay.com
    4. postback to the api controller
    5. confirm the invoice/order

    Is there an example for this postback process?

    I dont know how the PaymentGatewayProvider and gatewaymethod should look like and how i redirect to the saferpay.

    Thanks for your help.

  • Eidos 44 posts 66 karma points
    Sep 14, 2015 @ 09:50
    Eidos
    0

    The SaferPay workflow seems to be similar to the payPal workflow.
    You can view the paypal plugin code at: https://github.com/Merchello/Merchello/tree/merchello-dev/Plugin/Payments/PayPal/src/Merchello.Plugin.Payments.PayPal

  • Tobias Lopez 64 posts 210 karma points
    Sep 14, 2015 @ 09:54
    Tobias Lopez
    0

    Okay if so:

    • Where happens the redirect to the Saferpay(Paypal)?
    • Where is the Invoice created?
    • Where is the postback handled?

    thanks for your help!

  • Eidos 44 posts 66 karma points
    Sep 14, 2015 @ 12:28
    Eidos
    1

    This is my confirmation method:

        var invoiceService = MerchelloContext.Current.Services.InvoiceService;
        var customerContext = new CustomerContext(UmbracoContext.Current);
        var basket = customerContext.CurrentCustomer.Basket();
        var preparation = basket.SalePreparation();
        var invoice = preparation.PrepareInvoice();
        invoiceService.Save(invoice);
        IPaymentMethod paymentMethod=preparation .GetPaymentMethod();
        var paymentResult = invoice.AuthorizePayment(paymentMethod.Key);
        if (paymentResult.Payment.Result.ExtendedData != null && paymentResult.Payment.Result.ExtendedData.ContainsKey("RedirectUrl"))
        {               
           string orderConfirmUrl = paymentResult.Payment.Result.ExtendedData.GetValue("RedirectUrl");
           //here redirect to orderConfirmUrl 
        }
    

    If you want to send the confirmation notification you can write:

    IEnumerable<string> emailS = new[] { preparation.GetBillToAddress().Email };
    Notification.Trigger("OrderConfirmation", attempt, emailS);
    

    Payment plugin implementation depends of SaferPay rules.
    For example in payPal, when you request a new payment, you have to add a "returnUrl" param for success or not success payment. You can listen the payment notification creating an UmbracoApiController like this:

    [PluginController("MerchelloPayPal")]
        public class PayPalApiController : UmbracoApiController
        {
            [HttpGet]
            public HttpResponseMessage SuccessPayment(Guid invoiceKey, Guid paymentKey, string token, string payerId)
            {
                //your implementation
            }
    
    
           [HttpGet]
            public HttpResponseMessage AbortPayment(Guid invoiceKey, Guid paymentKey, string token, string payerId = null)
            {
                //your implementation
            }
        }
    
  • Tobias Lopez 64 posts 210 karma points
    Sep 15, 2015 @ 08:32
    Tobias Lopez
    100

    Hi!

    I came a lot furthur with your help!

    I still have some issues. I cannot figure out how to change the payment status from unpaid to paid...

    i've uploaded my code to github.

    Thanks again!

    EDIT: I have now a working solution.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies