[FIX] payment_stripe: charge creation failed
To reproduce: - Buy a product costing 0.01 - Validate the cart, pay with Stripe - Enter the credit card info, validate Stripe cannot process the transaction (minimum charge is not met), but the user is not warned about it. The Stripe pop-up is closed and the error is recorded in the console silently. opw-765775
This commit is contained in:
@@ -40,11 +40,25 @@ msgstr ""
|
||||
msgid "Checkout Image URL"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#. openerp-web
|
||||
#: code:addons/payment_stripe/static/src/xml/stripe_templates.xml:15
|
||||
#, python-format
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#: model:ir.ui.view,arch_db:payment_stripe.stripe_s2s_form
|
||||
msgid "Confirm <span class=\"fa fa-long-arrow-right\"/>"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#. openerp-web
|
||||
#: code:addons/payment_stripe/static/src/xml/stripe_templates.xml:9
|
||||
#, python-format
|
||||
msgid "Error"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#: model:ir.ui.view,arch_db:payment_stripe.stripe_s2s_form
|
||||
msgid "Expiration Date"
|
||||
@@ -65,6 +79,13 @@ msgstr ""
|
||||
msgid "Payment Transaction"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#. openerp-web
|
||||
#: code:addons/payment_stripe/static/src/js/stripe.js:43
|
||||
#, python-format
|
||||
msgid "Payment error"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
#: model:ir.model.fields,field_description:payment_stripe.field_payment_acquirer_stripe_publishable_key
|
||||
msgid "Stripe publishable key"
|
||||
@@ -84,7 +105,7 @@ msgstr ""
|
||||
#. module: payment_stripe
|
||||
#: code:addons/payment_stripe/models/payment.py:111
|
||||
#, python-format
|
||||
msgid "Stripe: invalid reply received from provider, missing reference"
|
||||
msgid "Stripe: invalid reply received from provider, missing reference. Additional message: %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_stripe
|
||||
|
||||
@@ -116,10 +116,13 @@ class PaymentTransactionStripe(models.Model):
|
||||
def _stripe_form_get_tx_from_data(self, data):
|
||||
""" Given a data dict coming from stripe, verify it and find the related
|
||||
transaction record. """
|
||||
reference = data['metadata']['reference']
|
||||
reference = data.get('metadata', {}).get('reference')
|
||||
if not reference:
|
||||
error_msg = _('Stripe: invalid reply received from provider, missing reference')
|
||||
_logger.error(error_msg, data['metadata'])
|
||||
error_msg = _(
|
||||
'Stripe: invalid reply received from provider, missing reference. Additional message: %s'
|
||||
% data.get('error', {}).get('message', '')
|
||||
)
|
||||
_logger.error(error_msg)
|
||||
raise ValidationError(error_msg)
|
||||
tx = self.search([('reference', '=', reference)])
|
||||
if not tx:
|
||||
|
||||
@@ -2,6 +2,11 @@ odoo.define('payment_stripe.stripe', function(require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
var qweb = core.qweb;
|
||||
ajax.loadXML('/payment_stripe/static/src/xml/stripe_templates.xml', qweb);
|
||||
|
||||
// The following currencies are integer only, see
|
||||
// https://stripe.com/docs/currencies#zero-decimal
|
||||
var int_currencies = [
|
||||
@@ -33,6 +38,10 @@ odoo.define('payment_stripe.stripe', function(require) {
|
||||
}).done(function(data){
|
||||
handler.isTokenGenerate = false;
|
||||
window.location.href = data;
|
||||
}).fail(function(){
|
||||
var msg = arguments && arguments[1] && arguments[1].data && arguments[1].data.message;
|
||||
var wizard = $(qweb.render('stripe.error', {'msg': msg || _t('Payment error')}));
|
||||
wizard.appendTo($('body')).modal({'keyboard': true});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="stripe.error">
|
||||
<div class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
|
||||
<h4 class="modal-title">Error</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<t t-esc="msg"></t>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn btn-link btn-xs" data-dismiss="modal">Close</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user