Copied to clipboard

Flag this post as spam?

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


  • Pedro Tavares 10 posts 90 karma points c-trib
    Mar 04, 2016 @ 11:47
    Pedro Tavares
    0

    Capture and Fulfill

    Hello,

    I'm trying to capture funds and fullfil an order but I'm having some issues.

    I've build a custom payment with both PaymentGateway Method and Provider.

    When the customer finishes the order, PerformAuthorizePayment is called and creates a new reference for payment. When the customer completes the payment, I try to capture the payment on PerformCapturePayment with:

        protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args)
        {
            var appliedPayments = GatewayProviderService.GetAppliedPaymentsByPaymentKey(payment.Key);
            var applied = appliedPayments.Sum(x => x.Amount);
    
            payment.Collected = (amount + applied) == payment.Amount;
            payment.Authorized = true;
    
            GatewayProviderService.Save(payment);
            GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Multibanco", amount);
    
            return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, CalculateTotalOwed(invoice).CompareTo(amount) <= 0);
        }
    

    The payment is captured. So far so good.

    After this I have two problems:

    • There is no record of the payment on the Sale History.
    • I have no fullfil button to complete the order.

    Can someone tell me what I am doing wrong?

    Thanks, Pedro

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Mar 09, 2016 @ 18:00
    Rusty Swayne
    0

    Hey Pedro,

    Sorry for the delayed response. I just got back from out of town.

    When you step through, does

      payment.Collected = (amount + applied) == payment.Amount;
    

    create a value of true

    Also, the last parameter in the payment result CalculateTotalOwed(.. should be true to "ApproveOrderCreation" (which will generate an order to be fulfilled). To debug, you could add a LogHelper.Debug entry above this line to log the result so you can check the values in the back office.

Please Sign in or register to post replies

Write your reply to:

Draft