Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import razorpay
- import requests
- # Your API credentials
- api_key = "your_api_key"
- api_secret = "your_api_secret"
- # Initialize Razorpay client
- client = razorpay.Client(auth=(api_key, api_secret))
- # Beneficiary Account Details
- beneficiary = {
- "name": "John Doe",
- "account_number": "1234567890",
- "ifsc": "HDFC0001234",
- "type": "bank_account",
- "email": "johndoe@example.com",
- "contact": "+919999999999"
- }
- # Create a contact (a beneficiary)
- contact_response = client.contact.create({
- "name": beneficiary["name"],
- "email": beneficiary["email"],
- "contact": beneficiary["contact"],
- "type": "customer",
- "reference_id": "cust_001",
- "notes": {
- "note_key_1": "note_value_1"
- }
- })
- # Get the contact_id from the response
- contact_id = contact_response['id']
- # Create a fund account
- fund_account_response = client.fund_account.create({
- "contact_id": contact_id,
- "account_type": beneficiary["type"],
- "bank_account": {
- "name": beneficiary["name"],
- "ifsc": beneficiary["ifsc"],
- "account_number": beneficiary["account_number"]
- }
- })
- # Get the fund_account_id from the response
- fund_account_id = fund_account_response['id']
- # Create a payout
- payout_response = client.payout.create({
- "account_number": "your_razorpay_account_number", # Your Razorpay account number
- "fund_account_id": fund_account_id,
- "amount": 10000, # Amount in smallest currency unit (e.g., paise for INR)
- "currency": "INR",
- "mode": "IMPS", # Other modes can be NEFT, RTGS, UPI
- "purpose": "refund",
- "queue_if_low_balance": True,
- "reference_id": "payout_001",
- "narration": "Payout for Order #001",
- "notes": {
- "notes_key_1": "notes_value_1"
- }
- })
- # Print the payout status
- print("Payout Status:", payout_response['status'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement