Testing payments

Open a shell and run RabbitMQ with the following command:

rabbitmq-server

Open another shell and start the Celery worker from your project directory with the following command:

celery -A myshop worker -l info

Open one more shell and start the development server with this command:

python manage.py runserver

Open http://127.0.0.1:8000/ in your browser, add some products to the shopping cart, and fill in the checkout form. When you click the PLACE ORDER button, the order will be persisted to the database, the order ID will be saved in the current session, and you will be redirected to the payment process page.

The payment process page retrieves the order from the session and renders the Hosted Fields form in an iframe, as follows:

You can take a look at the HTML source code to see the generated HTML.

Braintree provides a list of successful and unsuccessful credit cards so that you can test all possible scenarios. You can find a list of credit cards for testing at https://developers.braintreepayments.com/guides/credit-cards/testing-go-live/python. We are going to use the VISA test card 4111 1111 1111 1111, which returns a successful purchase. We are going to use CVV 123 and any future expiration date, such as 12/24. Enter the credit card details as follows:

Click on the Pay button. You will see the following page:

The transaction has been successfully processed. Now you can log in to your account at https://sandbox.braintreegateway.com/login. Under Transactions, you will be able to see the transaction like this:

Now, open http://127.0.0.1:8000/admin/orders/order/ in your browser. The order should now be marked as paid and contain the related Braintree transaction ID:

Congratulations! You have implemented a payment gateway to process credit cards.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.94.153