Issues encountered in writing the order payment API

Source: Internet
Author: User

First of all, I have to follow the already existing payment API to write the order payment API, but because the two are different, so similar to exactly shown inevitably will be problematic, first I was to apply the model has been written, and then write the corresponding serializer, the realization of serialization began to write the view, The main function of the view layer is to add the order payment information in the database while generating the order, which is used for the subsequent order payment information callback.

It is not possible to post an order after the API has been written, and at first it was thought that the card was in the construction sequencer class, because the order number was constructed using a reference information, but in the database it was found that the information was nonexistent, and it was possible to use it to assign a constant value. But at the same time there is a problem that I can not through the API framework provided by the Post method to achieve the production order, only by filling out the order and then refresh the production order, and the order can not synchronize the order payment information, and then realize that the problem is in the view layer, the view layer queryset is normal, Because orders are already available to be traversed, because the order payment information is defined in the Perform_create () method, so the problem is definitely out of the way, the problem is not found by the elimination method is not the construction of the error, but a field in the model, Because there is a foreign key in the order payment, but at this time I am using one of the values by default, resulting in the generation of orders can not give the matching information to generate order payment data, so the Perform_create () method has been unable to achieve, nature will not be able to respond, So the server has been giving me 500 of errors.

After this service, found that the problem is still to be careful to check, in fact, most of my time is wasted in a number of repeated operations, some have confirmed the error I repeat to check, very affect efficiency, from the point of view of the problem has been resolved, I should have made the order by not post. The problem is found in perform_create (), because this is the same as the post operation, only the method is OK to generate the order, and then the scope is much smaller, because in this function is performed only one operation, is to use the order information to generate the order payment, which need to submit only a few parameters, as long as the troubleshooting can be found to be unable to generate the order number, and then solve the problem is still not directly post, so the problem is out of the rest of the parameters are not generated, this time can be found, There is a payment Method field is no value, but in fact this is a foreign key, itself is the need to select the value, if not to the value of the wrong is definitely more outrageous, so I need to use the payment method to give a default value is OK.

Hope to encounter problems in the future do not go to the wrong to check AH and so on, the quiet heart, where the problem is resolved where, so that their efficiency has been improved.

Issues encountered in writing the order payment API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.