0

Magento faithfully logs the transaction detail when I manually capture an invoice within the Magento store interface. I assume that Magento would likewise generate the same transaction detail entry when I programmatically capture an invoice through the Magento REST API. Unfortunately, this is not the case, as my automated script does not trigger whatever Magento process logs a successful credit card transaction.

I believe my Authorize.net account is set up properly. After I receive an order I can see that the customer's credit card has been auth checked. I can then use the Magento online interface to create an invoice and manually capture the credit card payment. This creates a beautiful transaction log entry within the order.

My goal has been to automate this process using the Magento 2 REST API. My automation uses the following REST endpoints:

  1. use order to create invoice
    • POST /rest/v1/order/{order_id}/invoice
    • RETURNS integer {invoice_id}
  2. use invoice to capture payment
    • POST /rest/v1/invoices/{invoice_id}/capture
    • RETURNS string true

I receive a string value response of true from the invoice capture, and I can log into my Authorize.net account and see that the credit card transaction has been settled. Unfortunately, this transaction detail is not logged in Magento against the order. The capture transaction entry is simply missing. I would rather not have to log into my Authorize.net account to verify the successful settlement of each transaction. I would rather that information be visible within Magento itself.

Is there another step I need to take to force the transaction capture entry to appear in the Magento order transaction history?

1

It looks like the problem is with my assumption that the REST API endpoint would automatically handle any notes or comments. It seems I need to add a hook into my script that will create that note for me. I used the following REST API endpoint to create my order entry note:

  • POST /rest/v1/orders/{orderId}/comments
  • HEADERS Content-Type: application/json Authorization: Bearer {token}
  • DATA { "statusHistory" : { "comment":"successful credit card capture", "is_customer_notified":0, "is_visible_on_front":0, "parent_id":{order_id}, "status":"approved" } }
  • RESPONSE string true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.