thelabnyc / django-oscar-api-checkout Goto Github PK
View Code? Open in Web Editor NEWAutomated mirror of https://gitlab.com/thelabnyc/django-oscar-api-checkout
License: ISC License
Automated mirror of https://gitlab.com/thelabnyc/django-oscar-api-checkout
License: ISC License
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" }
The payment method selection during checkout get stored in session during checkout, the subsequent request to /api/checkout/payment-states// is no longer have session attached to it as the UI is served from different Host and the django service is hosted in different domain. which result in 404 response as it couldn't find the session information. Relevant peace of code..
//views.py class PaymentStatesView(generics.GenericAPIView): def get(self, request, pk=None): if pk and int(pk) != request.session.get(CHECKOUT_ORDER_ID): return Response(status=status.HTTP_404_NOT_FOUND)
Am i Missing something? Thanks :)
Can you help?
I just get "{"detail":"Not found."}".
my api call:
async function getStatuses() {
await axios
.get(
"http://127.0.0.1:8000/api/oscarapicheckout/checkout/payment-states/",
{
headers: {
Authorization: Bearer ${access_token}
,
},
}
)
.then((response) => {
console.log(JSON.stringify(response.data.results));
})
.catch((error) => {
console.log();
});
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.