Nisha Patel
Problem
I am building a Django web application and I want to implement a payout functionality using the Stripe API(test mode). Here's what I need to achieve:
1. The user clicks on the "Withdraw" button.
2. User enters their account details (such as bank account number, routing number, etc.)
Then transfer the money to that account
I have already installed the Stripe Python library and set up my Stripe API key. How can I achieve this functionality in my Django application? Any guidance on the Django views, forms, and Stripe API integration would be highly appreciated.
Solution
So even though it's not mentioned, I'm assuming this is a Stripe Connect setup - you want your Connected Account users to be able to add an external account, and then payout funds from their available Stripe balance to this account?
This is how I'd suggest doing it:
2. User enters their account details (such as bank account number, routing number, etc.)
This would be custom fields*, which you then use the value of to form into a Stripe Token with the frontend function create token:
>https://stripe.com/docs/js/tokens/create_token?type=bank_account
You would then attach the bank account Token to your Connected Account's external_accounts:
>https://stripe.com/docs/api/accounts/update#update_account-external_account
3. Then transfer the money to that account
Finally, you can make a Payout of any available funds using this call [0]:
[0] >https://stripe.com/docs/api/payouts/create?lang=python
[1] >https://stripe.com/docs/connect/authentication#stripe-account-header
*Note that Stripe has some elements to render fields for specific bank account types (e.g. IBAN element):
>https://stripe.com/docs/js/element/other_element?type=iban
Answered by: >Lucky2501
Credit: >StackOverflow
Blog Links:
>How to manage the Text in the container in Django?
>Fix webapp stops working issue in Django- Python webapp
>Creating a form in Django to upload a picture from the website
>Sending Audio file from Django to Vue
>How to keep all query parameters intact when changing page in Django?
>Solved: TaskList View in Django
>Implement nested serializers in the Django rest framework
>How to filter events by month in Django?
>Sorting the restframework in Django
>Ways to access instances of models in view in order to save both forms at once in Django
>What makes index.html have such kind of name in Django?
>Fix Module Not Found during Deployment- Django
>Creating a Django with existing directories, files, etc.?
>How to Read a CSV file with PHP using cURL?