Copied to clipboard

Flag this post as spam?

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


  • RM 33 posts 95 karma points
    Mar 11, 2022 @ 16:57
    RM
    0

    Capture Payment on order completion

    Hi Again,

    Have been looking through the documentation and I can't seem to find it. We are integrating Vendr with a 3 party fulfillment service. We know that we can defer payments when using the Stripe integration so that is great, but we would like to automate the process of processing the payment when we receive the fulfillment response (via a custom web hook) from the 3rd party.

    Does anyone know where i could find any documentation for that if its possible, even general purpose docs would do.

    Thanks,

    Rob

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Mar 14, 2022 @ 09:34
    Matt Brailsford
    0

    Hi Rob,

    This kind of depends what you mean by "processing the payment". Are you using the OOTB Stripe payment provider and you are "authorizing" the payment and you want to "capture" it in response to fulfilment updates? Or are you doing something custom with your payment processing?

    If the later, can you share some code on how you are doing this?

    Matt

  • RM 33 posts 95 karma points
    Mar 14, 2022 @ 16:01
    RM
    0

    Hi Matt,

    we are at the planning stage at the moment of this, currently we are using the OOTB provider to authorize but not take the payment. Once we know the order is fulfilled we then want to capture the payment.

    Essentially the process is:

    1. Order is taken and payment authorized
    2. Order details are sent to 3rd party fulfillment service
    3. 3rd party service will notify us (via a webhook) that the order is fulfilled
    4. At that point we want to capture the payment automatically

    Step 4 I believe is manual in the OOTB solution (please correct me if I am wrong) so we may have to attach some sort of Vendr event to achieve this if that is the case which is fine, but just wanted to make sure we are not re-inventing anything here.

    Does that make more sense?

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Mar 14, 2022 @ 16:04
    Matt Brailsford
    100

    Ok, cool, then in that case, this is the code you would need to "capture" the authorized payment from within your webhook

    var order = _vendrApi.GetOrder(orderId);
    
    var result = await _vendrApi.CaptureOrderPaymentAsync(order);
    if (result.Success)
    {
        using (var uow = _vendrApi.Uow.Create())
        {
            var writableOrder = order.AsWritable(uow)
                .ApplyPaymentChanges(result);
    
            _vendrApi.SaveOrder(writableOrder);
    
            uow.Complete();
        }
    }
    
  • Sean Dooley 288 posts 527 karma points
    Mar 24, 2022 @ 16:09
    Sean Dooley
    0

    We have implemented the logic as suggested in our local IIS development site yet the following is always false.

    var result = await _vendrApi.CaptureOrderPaymentAsync(order);
    if (result.Success)
    

    This is the case whether we are using Stripe CLI or ngrok tunnel. Not entirely sure what else to check at this point.

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Mar 24, 2022 @ 16:44
    Matt Brailsford
    0

    Then it would suggest the payment provider failed to capture the payment.

    You'll need to check the payment gateway to see if an attempt to capture was made and if there was any errors. Also, a capture can only take place on an Authorized payment status so is the payment in this state?

  • Sean Dooley 288 posts 527 karma points
    Mar 24, 2022 @ 16:55
    Sean Dooley
    0

    Payment status is showing as Authorized on the Vendr orders dashboard and before the call to CaptureOrderPaymentAsync when debugging.

    Checking the subsequent PaymentResult I am seeing the following

    {
      "Success":false,
      "TransactionInfo":{
        "TransactionId":null,
        "PaymentStatus":0
      },
      "MetaData":null
    }
    
  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Mar 25, 2022 @ 08:47
    Matt Brailsford
    0

    Hi Sean,

    What does the payment method settings look like for your payment provider (Specifically the Features panel)? Have you allowed capturing payments?

    For capture to succeed it needs the payment to be authorized, but the payment provider needs to be both capable of capturing and you need to have allowed the option of capturing in the payment method settings.

    Matt

  • Sean Dooley 288 posts 527 karma points
    Mar 25, 2022 @ 10:29
    Sean Dooley
    0

    For capture to succeed it needs the payment to be authorized, but the payment provider needs to be both capable of capturing and you need to have allowed the option of capturing in the payment method settings.

    Spot on. Appreciate your help with this.

Please Sign in or register to post replies

Write your reply to:

Draft