active_merchant icon indicating copy to clipboard operation
active_merchant copied to clipboard

Mundipagg: Use `orders` endpoint for authorize and purchase

Open dsmcclain opened this issue 4 years ago • 0 comments

CE-1505

Currently, all requests to Mundipagg use the charges endpoint. However, we need to be able to send SubMerchant fields on all authorize and purchase calls, and the charges endpoint does not receive those fields.

This PR routes all authorize and purchase calls to the orders endpoint, and adds logic to handle the differences between the two. Requests to orders have different requirements than requests to charges:

  • instead of accepting a payment object, orders accepts a payments array containing one or more payment objects.
  • orders also requires an items object with three required subfields: amount, description, and quantity. These subfields cannot be blank.

The response returned from orders is structured differently than the response returned from charges. It essentially acts as a wrapper around the standard charges response, including one or more charges in a charges array, as well as an additional set of root-level fields. For this reason it is necessary to parse responses differently depending on which endpoint the request was hitting.

Rubocop: Running RuboCop... 699 files inspected, no offenses detected

Unit tests: 4707 tests, 73409 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

Remote tests: Loaded suite test/remote/gateways/remote_mundipagg_test 39 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

dsmcclain avatar Apr 30 '21 22:04 dsmcclain