add in receipt errors (bug error)
This commit is contained in:
Родитель
0df1d96d67
Коммит
c68c99bc0b
|
@ -11,6 +11,10 @@ import commonware.log
|
|||
log = commonware.log.getLogger('z.services')
|
||||
|
||||
|
||||
class SigningError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def sign(receipt):
|
||||
"""
|
||||
Send the receipt to the signing service.
|
||||
|
@ -37,17 +41,18 @@ def sign(receipt):
|
|||
# Will occur when a 3xx or greater code is returned
|
||||
log.error('Posting to signing failed: %s'
|
||||
% (error.code))
|
||||
return error.code
|
||||
raise SigningError
|
||||
except:
|
||||
# Will occur when some other error occurs.
|
||||
log.error('Posting to signing failed', exc_info=True)
|
||||
return
|
||||
raise SigningError
|
||||
|
||||
# The list of valid statuses are here:
|
||||
# https://wiki.mozilla.org/Apps/WebApplicationReceipt/SigningService
|
||||
if response.status_code not in [400, 401, 404, 409, 503, 404]:
|
||||
log.error('Posting to signing failed: %s'
|
||||
% (response.status_code))
|
||||
raise SigningError
|
||||
|
||||
return response.read()
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
|
||||
function revertButton($button) {
|
||||
// Cancelled install/purchase. Roll back button to its previous state.
|
||||
$button.html($button.data('old-text'))
|
||||
.removeClass('purchasing installing error');
|
||||
// The text has changed, so do another linefit.
|
||||
$button.css('font-size', $button.data('old-font-size')).linefit();
|
||||
$button.removeClass('purchasing installing error');
|
||||
if ($button.data('old-text')) {
|
||||
$button.html($button.data('old-text'))
|
||||
// The text has changed, so do another linefit.
|
||||
$button.css('font-size', $button.data('old-font-size')).linefit();
|
||||
}
|
||||
}
|
||||
|
||||
$(window).bind('app_purchase_start', function(e, product) {
|
||||
|
|
|
@ -47,6 +47,11 @@
|
|||
var data = {};
|
||||
$(window).trigger('app_install_start', product);
|
||||
$.post(product.recordUrl).success(function(response) {
|
||||
if (response.error) {
|
||||
$('#pay-error').show().find('div').text(response.error);
|
||||
installError(product);
|
||||
return;
|
||||
}
|
||||
if (response.receipt) {
|
||||
data['data'] = {'receipts': [response.receipt]};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import jingo
|
||||
from tower import ugettext as _
|
||||
|
||||
from django import http
|
||||
|
||||
|
@ -8,7 +9,7 @@ from addons.decorators import addon_view_factory
|
|||
from amo.decorators import json_view, login_required, post_required, write
|
||||
from amo.utils import memoize_get
|
||||
from lib.metrics import send_request
|
||||
from lib.crypto.receipt import cef
|
||||
from lib.crypto.receipt import cef, SigningError
|
||||
from mkt.webapps.models import create_receipt, Installed
|
||||
|
||||
addon_view = addon_view_factory(qs=Addon.objects.valid)
|
||||
|
@ -52,6 +53,9 @@ def record(request, addon):
|
|||
cef(request, addon, 'request', 'Receipt requested')
|
||||
if not receipt:
|
||||
cef(request, addon, 'sign', 'Receipt signing')
|
||||
receipt = create_receipt(installed.pk)
|
||||
try:
|
||||
receipt = create_receipt(installed.pk)
|
||||
except SigningError:
|
||||
error = _('There was a problem installing the app.')
|
||||
|
||||
return {'addon': addon.pk, 'receipt': receipt}
|
||||
return {'addon': addon.pk, 'receipt': receipt, 'error': error}
|
||||
|
|
Загрузка…
Ссылка в новой задаче