Now I understand more of the status message that comes back after an attempted authorization at Amazon
parent
5162cd8f72
commit
86ed171cf3
|
@ -4,9 +4,13 @@ https://github.com/agiliq/merchant/blob/master/example/app/integrations/fps_inte
|
||||||
|
|
||||||
from billing.integrations.amazon_fps_integration import AmazonFpsIntegration as Integration
|
from billing.integrations.amazon_fps_integration import AmazonFpsIntegration as Integration
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FpsIntegration(Integration):
|
class FpsIntegration(Integration):
|
||||||
def transaction(self, request):
|
def transaction(self, request):
|
||||||
"""Ideally at this method, you will check the
|
"""Ideally at this method, you will check the
|
||||||
|
@ -19,7 +23,28 @@ class FpsIntegration(Integration):
|
||||||
request_url = request.build_absolute_uri()
|
request_url = request.build_absolute_uri()
|
||||||
parsed_url = urlparse.urlparse(request_url)
|
parsed_url = urlparse.urlparse(request_url)
|
||||||
query = parsed_url.query
|
query = parsed_url.query
|
||||||
|
|
||||||
dd = dict(map(lambda x: x.split("="), query.split("&")))
|
dd = dict(map(lambda x: x.split("="), query.split("&")))
|
||||||
resp = self.purchase(100, dd)
|
|
||||||
return HttpResponseRedirect("%s?status=%s" %(reverse("app_offsite_amazon_fps"),
|
logger.info("dd: {0}".format(dd))
|
||||||
resp["status"]))
|
|
||||||
|
# dd: {'status': 'SC', 'signatureVersion': '2',
|
||||||
|
# 'tokenID': 'CLDITXQAX2DM82CT184S5CDNKYDXEPXETZ5QJFKB8AX4V9ZD34BGGJ6IDNFZDSUU',
|
||||||
|
# 'certificateUrl': 'https%3A%2F%2Ffps.sandbox.amazonaws.com%2Fcerts%2F090911%2FPKICert.pem%3FrequestId%3Dbjzj0zgbg2uf2j46a1iq123b9rwzl694mvpstlw1p5il426x7ap',
|
||||||
|
# 'expiry': '10%2F2017', 'signatureMethod': 'RSA-SHA1', 'callerReference': '5e0f7b0d-5cc5-4a55-a646-c6e420dd0f11',
|
||||||
|
# 'signature': 'Cc64A8DP7VclFBrhFEDXr2yhP8LaJpaLC6n%2F5oXiAhhD%2BnjJH9jQRhwPgB%2BuRvdcObMmZTD9we9G%0AvmEAkd5NkVULESdipsW%2B4i62mtD0DseuAtotMzjqObEeekzkaz4Vo0X9xcdlytLR04aEb4xqsLtg%0AJU%2Fysy7KStRivTqKzug%3D'}
|
||||||
|
|
||||||
|
# need to act based on status
|
||||||
|
# getting status=SC, which doesn't seem to be in the documentation -- the docs say "SR":
|
||||||
|
# http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/CBUIapiMerchant.html
|
||||||
|
# status = SC/SR, A, CE, NP, NM
|
||||||
|
|
||||||
|
if dd.get('status') in ['SC', 'SR']:
|
||||||
|
resp = self.purchase(100, dd)
|
||||||
|
return HttpResponseRedirect("%s?status=%s" %(reverse("testfps"),
|
||||||
|
resp["status"]))
|
||||||
|
elif dd.get('status') == 'A':
|
||||||
|
return HttpResponse('You canceled the transaction')
|
||||||
|
else:
|
||||||
|
return HttpResponse('An unexpected status code: {0}'.format(dd.get('status')))
|
||||||
|
|
|
@ -29,7 +29,7 @@ if not settings.IS_PREVIEW:
|
||||||
)
|
)
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
(r'^fps/', include(amazon_fps_obj.urls)),
|
(r'^fps/', include(amazon_fps_obj.urls)),
|
||||||
url(r'^testfps/$', 'regluit.payment.views.testfps', name='app_offsite_amazon_fps'),
|
url(r'^testfps/$', 'regluit.payment.views.testfps', name='testfps'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue