thelabnyc / django-oscar-api-checkout

Automated mirror of https://gitlab.com/thelabnyc/django-oscar-api-checkout

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add new payment method?

hackeraks opened this issue · comments

I am trying to add new payment method, I created new payment method, and required handling of payment authorization and validation from the Payment Gateway. But on submitting order with payment instrument selection by user, I am getting the below error.

Internal Server Error: /api/checkout/
Traceback (most recent call last):
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 52, in inner
return func(*args, **kwds)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/oscarapicheckout/views.py", line 107, in post
data=c_ser.validated_data['payment'])
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/oscarapicheckout/views.py", line 153, in _record_payments
new_states[key] = record(key, method_data)
File "/Users/as/myprojects/newproject/lib/python3.6/site-packages/oscarapicheckout/views.py", line 141, in record
order_balance[0] = order_balance[0] - state.amount
AttributeError: 'dict' object has no attribute 'amount'

My submitted data is following.
{ basket: "http://127.0.0.1:8080/api/baskets/14/" payment: {payme: { amount: "15000.00" enabled: true }} shipping_address: {id: 2, title: "Mr", first_name: "Eric", last_name: "S", line1: "Gp", …} shipping_charge: {currency: "USD", excl_tax: "0.0", tax: "0.0"} shipping_method_code: "free-shipping" total: "15000.00" }

Thanks I manage to fix it.