The original transaction that you wish to refund must have a status of Settled Successfully. - #You cannot issue refunds against unsettled, voided, declined or errored transactions.- return res - @http.route(['/payment/authorize/s2s/create'], type='http', auth='public') - def authorize_s2s_create(self, **post): - acquirer_id = int(post.get('acquirer_id')) - acquirer = request.env['payment.acquirer'].browse(acquirer_id) - acquirer.s2s_process(post) - return utils.redirect("/payment/process") + @http.route('/payment/authorize/payment', type='json', auth='public') + def authorize_payment(self, reference, partner_id, access_token, opaque_data): + """ Make a payment request and handle the response. + + :param str reference: The reference of the transaction + :param int partner_id: The partner making the transaction, as a `res.partner` id + :param str access_token: The access token used to verify the provided values + :param dict opaque_data: The payment details obfuscated by Authorize.Net + :return: None + """ + # Check that the transaction details have not been altered + if not payment_utils.check_access_token(access_token, reference, partner_id): + raise ValidationError("Authorize.Net: " + _("Received tampered payment request data.")) + + # Make the payment request to Authorize.Net + tx_sudo = request.env['payment.transaction'].sudo().search([('reference', '=', reference)]) + response_content = tx_sudo._authorize_create_transaction_request(opaque_data) + + # Handle the payment request response + _logger.info("make payment response:\n%s", pprint.pformat(response_content)) + # As the API has no redirection flow, we always know the reference of the transaction. + # Still, we prefer to simulate the matching of the transaction by crafting dummy feedback + # data in order to go through the centralized `_handle_feedback_data` method. + feedback_data = {'reference': tx_sudo.reference, 'response': response_content} + request.env['payment.transaction'].sudo()._handle_feedback_data( + 'authorize', feedback_data + ) diff --git a/addons/payment_authorize/data/payment_acquirer_data.xml b/addons/payment_authorize/data/payment_acquirer_data.xml index 3f465665f24..bb66a4704fb 100644 --- a/addons/payment_authorize/data/payment_acquirer_data.xml +++ b/addons/payment_authorize/data/payment_acquirer_data.xml @@ -1,15 +1,13 @@ -