Request Parameters
Specific payment method ID to retrieve. If not provided, returns list of all payment methods.
Filter by payment method types:
credit_card
- Credit and debit cardsbank_account
- Bank account/ACH transfersdigital_wallet
- Digital wallets (PayPal, Apple Pay, Google Pay)cryptocurrency
- Cryptocurrency paymentswire_transfer
- Wire transferspurchase_order
- Purchase order billing
Filter by payment method status:
active
- Active and available for useexpired
- Expired payment methodsdisabled
- Manually disabled methodsfailed
- Methods with recent failurespending_verification
- Awaiting verification
Include usage statistics for each payment method
Include security and verification information
Response
Array of payment method objects
Show Payment Method Object
Show Payment Method Object
Unique payment method identifier
Payment method type
Current status of the payment method
Whether this is the default payment method
Human-readable display name
Payment method specific details
ID of the current default payment method
Payment method types supported for this account
Example
Copy
curl -X GET "https://api.tensorone.ai/v2/billing/payment-methods" \
-H "Authorization: Bearer YOUR_API_KEY" \
-G \
-d "includeUsageStats=true" \
-d "includeSecurityInfo=true"
Copy
{
"paymentMethods": [
{
"methodId": "pm_card_1234567890",
"type": "credit_card",
"status": "active",
"isDefault": true,
"displayName": "Visa ****4242",
"details": {
"maskedNumber": "****-****-****-4242",
"brand": "Visa",
"expiryDate": "12/26",
"country": "US",
"currency": "USD"
},
"verification": {
"verified": true,
"verificationMethod": "address_verification",
"verifiedAt": "2024-01-15T10:30:00Z",
"riskScore": "low"
},
"usage": {
"totalTransactions": 24,
"totalAmount": 12847.56,
"lastUsed": "2024-01-16T14:20:00Z",
"successRate": 100.0,
"averageAmount": 535.31
},
"limits": {
"dailyLimit": 5000.00,
"monthlyLimit": 50000.00,
"transactionLimit": 10000.00,
"remainingDaily": 3200.00,
"remainingMonthly": 45680.00
},
"metadata": {
"addedAt": "2024-01-15T10:30:00Z",
"addedBy": "admin@company.com",
"tags": ["primary", "corporate"],
"notes": "Primary corporate card"
}
},
{
"methodId": "pm_bank_0987654321",
"type": "bank_account",
"status": "active",
"isDefault": false,
"displayName": "Bank Account ****1234",
"details": {
"maskedNumber": "****-****-1234",
"brand": "Chase Bank",
"expiryDate": null,
"country": "US",
"currency": "USD"
},
"verification": {
"verified": true,
"verificationMethod": "micro_deposits",
"verifiedAt": "2024-01-10T16:45:00Z",
"riskScore": "low"
},
"usage": {
"totalTransactions": 6,
"totalAmount": 8950.00,
"lastUsed": "2024-01-12T09:15:00Z",
"successRate": 83.3,
"averageAmount": 1491.67
},
"limits": {
"dailyLimit": 25000.00,
"monthlyLimit": 100000.00,
"transactionLimit": 25000.00,
"remainingDaily": 25000.00,
"remainingMonthly": 91050.00
},
"metadata": {
"addedAt": "2024-01-08T14:20:00Z",
"addedBy": "finance@company.com",
"tags": ["backup", "large-payments"],
"notes": "For large invoice payments"
}
},
{
"methodId": "pm_crypto_btc_001",
"type": "cryptocurrency",
"status": "active",
"isDefault": false,
"displayName": "Bitcoin Wallet",
"details": {
"maskedNumber": "bc1q...xyz123",
"brand": "Bitcoin",
"expiryDate": null,
"country": null,
"currency": "BTC"
},
"verification": {
"verified": true,
"verificationMethod": "wallet_signature",
"verifiedAt": "2024-01-20T11:00:00Z",
"riskScore": "medium"
},
"usage": {
"totalTransactions": 2,
"totalAmount": 3200.00,
"lastUsed": "2024-01-22T08:30:00Z",
"successRate": 100.0,
"averageAmount": 1600.00
},
"limits": {
"dailyLimit": 10000.00,
"monthlyLimit": 50000.00,
"transactionLimit": 10000.00,
"remainingDaily": 10000.00,
"remainingMonthly": 46800.00
},
"metadata": {
"addedAt": "2024-01-20T11:00:00Z",
"addedBy": "admin@company.com",
"tags": ["crypto", "experimental"],
"notes": "Testing cryptocurrency payments"
}
}
],
"defaultMethod": "pm_card_1234567890",
"supportedTypes": [
"credit_card",
"bank_account",
"digital_wallet",
"cryptocurrency",
"wire_transfer"
],
"securityFeatures": {
"twoFactorRequired": true,
"fraudDetection": true,
"spendingLimits": true,
"approvalWorkflow": true
}
}
Payment Method Operations
Add New Payment Methods
Python
Copy
def add_bank_account(account_details):
"""Add a new bank account for ACH payments"""
bank_data = {
"type": "bank_account",
"accountHolderName": account_details["account_holder"],
"accountNumber": account_details["account_number"],
"routingNumber": account_details["routing_number"],
"accountType": account_details.get("account_type", "checking"), # checking or savings
"bankName": account_details.get("bank_name"),
"billingAddress": account_details["billing_address"],
"verificationMethod": "micro_deposits", # or instant_verification
"setAsDefault": account_details.get("set_default", False)
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/payment-methods",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=bank_data
)
return response.json()
def add_digital_wallet(wallet_details):
"""Add digital wallet (PayPal, Apple Pay, etc.)"""
wallet_data = {
"type": "digital_wallet",
"walletType": wallet_details["wallet_type"], # paypal, apple_pay, google_pay
"walletId": wallet_details["wallet_id"],
"displayName": wallet_details.get("display_name"),
"setAsDefault": wallet_details.get("set_default", False)
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/payment-methods",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=wallet_data
)
return response.json()
def add_cryptocurrency_wallet(crypto_details):
"""Add cryptocurrency payment method"""
crypto_data = {
"type": "cryptocurrency",
"cryptocurrency": crypto_details["currency"], # BTC, ETH, USDC, etc.
"walletAddress": crypto_details["wallet_address"],
"network": crypto_details.get("network", "mainnet"),
"displayName": crypto_details.get("display_name"),
"verificationMethod": "wallet_signature",
"setAsDefault": crypto_details.get("set_default", False)
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/payment-methods",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=crypto_data
)
return response.json()
# Example: Add bank account
bank_account_details = {
"account_holder": "Acme Corporation",
"account_number": "1234567890",
"routing_number": "021000021",
"account_type": "checking",
"bank_name": "Chase Bank",
"billing_address": {
"street": "123 Business Ave",
"city": "San Francisco",
"state": "CA",
"postalCode": "94105",
"country": "US"
},
"set_default": False
}
# bank_result = add_bank_account(bank_account_details)
# print(f"Bank account added: {bank_result.get('methodId', 'Failed')}")
# Example: Add cryptocurrency wallet
crypto_details = {
"currency": "BTC",
"wallet_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"network": "mainnet",
"display_name": "Bitcoin Corporate Wallet"
}
# crypto_result = add_cryptocurrency_wallet(crypto_details)
# print(f"Crypto wallet added: {crypto_result.get('methodId', 'Failed')}")
Payment Method Verification
Python
Copy
def verify_bank_account_micro_deposits(method_id, deposit_amounts):
"""Verify bank account using micro deposit amounts"""
verification_data = {
"verificationMethod": "micro_deposits",
"depositAmounts": deposit_amounts # [0.32, 0.45] - amounts in dollars
}
response = requests.post(
f"https://api.tensorone.ai/v2/billing/payment-methods/{method_id}/verify",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=verification_data
)
return response.json()
def verify_cryptocurrency_wallet(method_id, signature):
"""Verify cryptocurrency wallet using signature"""
verification_data = {
"verificationMethod": "wallet_signature",
"signature": signature,
"message": "TensorOne Wallet Verification"
}
response = requests.post(
f"https://api.tensorone.ai/v2/billing/payment-methods/{method_id}/verify",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=verification_data
)
return response.json()
def get_verification_status(method_id):
"""Check verification status of a payment method"""
response = requests.get(
f"https://api.tensorone.ai/v2/billing/payment-methods/{method_id}/verification",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
return response.json()
# Example verification workflow
def payment_method_verification_workflow():
"""Handle payment method verification workflow"""
unverified_methods = []
payment_data = get_payment_methods(include_security=True)
for method in payment_data['paymentMethods']:
verification = method.get('verification', {})
if not verification.get('verified', False):
unverified_methods.append(method)
if unverified_methods:
print("🔍 Unverified Payment Methods:")
print("-" * 32)
for method in unverified_methods:
method_id = method['methodId']
method_type = method['type']
display_name = method['displayName']
print(f"Method: {display_name}")
print(f"Type: {method_type}")
print(f"ID: {method_id}")
if method_type == "bank_account":
print("Action: Verify using micro deposits")
print("1. Check bank statement for two small deposits")
print("2. Call verify_bank_account_micro_deposits() with amounts")
elif method_type == "cryptocurrency":
print("Action: Verify using wallet signature")
print("1. Sign verification message with wallet")
print("2. Call verify_cryptocurrency_wallet() with signature")
print()
else:
print("✅ All payment methods are verified")
payment_method_verification_workflow()
Payment Method Security Management
Python
Copy
def enable_two_factor_auth():
"""Enable two-factor authentication for payment methods"""
response = requests.post(
"https://api.tensorone.ai/v2/billing/security/enable-2fa",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"enable": True,
"methods": ["sms", "email", "authenticator"],
"requireForActions": ["add_payment_method", "set_default", "large_transactions"]
}
)
return response.json()
def set_fraud_detection_rules():
"""Configure fraud detection rules"""
rules_config = {
"enableRealTimeMonitoring": True,
"maxTransactionAmount": 10000.00,
"maxDailyAmount": 25000.00,
"unusualLocationAlert": True,
"velocityChecks": True,
"ipWhitelist": ["192.168.1.0/24"], # Office IP range
"timeRestrictions": {
"allowedHours": "06:00-22:00",
"timezone": "America/New_York",
"allowWeekends": True
},
"deviceFingerprinting": True
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/security/fraud-detection",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=rules_config
)
return response.json()
def configure_approval_workflow():
"""Set up approval workflow for large transactions"""
workflow_config = {
"enabled": True,
"thresholds": {
"requireApprovalAbove": 5000.00,
"autoApproveBelow": 1000.00
},
"approvers": [
{
"email": "cfo@company.com",
"role": "primary",
"maxAmount": 50000.00
},
{
"email": "finance-director@company.com",
"role": "secondary",
"maxAmount": 25000.00
}
],
"approvalTimeout": "24h",
"notificationChannels": ["email", "slack"],
"escalationRules": {
"escalateAfter": "12h",
"escalateTo": "ceo@company.com"
}
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/security/approval-workflow",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=workflow_config
)
return response.json()
# Configure security features
def setup_payment_security():
"""Set up comprehensive payment security"""
print("🔒 Configuring Payment Security")
print("=" * 32)
# Enable 2FA
tfa_result = enable_two_factor_auth()
print(f"Two-Factor Auth: {'✅' if tfa_result.get('success') else '❌'}")
# Set fraud detection
fraud_result = set_fraud_detection_rules()
print(f"Fraud Detection: {'✅' if fraud_result.get('success') else '❌'}")
# Configure approval workflow
approval_result = configure_approval_workflow()
print(f"Approval Workflow: {'✅' if approval_result.get('success') else '❌'}")
print("\n🛡️ Security configuration complete")
# setup_payment_security()
Payment Method Analytics
Python
Copy
def get_payment_method_analytics(time_range="last_6_months"):
"""Get analytics for payment method usage"""
response = requests.get(
"https://api.tensorone.ai/v2/billing/payment-methods/analytics",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={
"timeRange": time_range,
"includeFailureAnalysis": True,
"includeCostAnalysis": True
}
)
return response.json()
def analyze_payment_performance():
"""Analyze payment method performance and reliability"""
analytics = get_payment_method_analytics()
print("📊 Payment Method Performance Analysis")
print("=" * 42)
methods = analytics.get('methodAnalytics', [])
# Success rate analysis
print("\n✅ Success Rates:")
print("-" * 16)
success_rates = [(m['displayName'], m['successRate']) for m in methods]
success_rates.sort(key=lambda x: x[1], reverse=True)
for name, rate in success_rates:
rate_icon = "🟢" if rate >= 95 else "🟡" if rate >= 90 else "🔴"
print(f"{rate_icon} {name}: {rate:.1f}%")
# Transaction volume analysis
print(f"\n💰 Transaction Volumes:")
print("-" * 22)
volume_data = [(m['displayName'], m['totalAmount'], m['transactionCount'])
for m in methods]
volume_data.sort(key=lambda x: x[1], reverse=True)
for name, amount, count in volume_data:
avg_transaction = amount / count if count > 0 else 0
print(f"{name}:")
print(f" Total: ${amount:,.2f} ({count} transactions)")
print(f" Average: ${avg_transaction:,.2f}")
print()
# Failure analysis
if analytics.get('failureAnalysis'):
print("❌ Failure Analysis:")
print("-" * 18)
failures = analytics['failureAnalysis']
for failure_type, data in failures.items():
count = data['count']
percentage = data['percentage']
print(f" {failure_type.replace('_', ' ').title()}: {count} ({percentage:.1f}%)")
# Cost analysis
if analytics.get('costAnalysis'):
print("\n💸 Processing Costs:")
print("-" * 18)
costs = analytics['costAnalysis']
for method_name, cost_data in costs.items():
total_fees = cost_data['totalFees']
fee_rate = cost_data['averageFeeRate']
print(f" {method_name}: ${total_fees:.2f} (avg {fee_rate:.2f}%)")
# Recommendations
if analytics.get('recommendations'):
print(f"\n💡 Recommendations:")
print("-" * 17)
for rec in analytics['recommendations']:
impact_icon = {"high": "🔴", "medium": "🟡", "low": "🟢"}.get(rec['impact'], "⚪")
print(f"{impact_icon} {rec['title']}")
print(f" {rec['description']}")
print(f" Potential savings: {rec.get('potentialSavings', 'N/A')}")
print()
analyze_payment_performance()
Advanced Payment Features
Multi-Currency Support
Python
Copy
def add_multi_currency_card(card_details, supported_currencies):
"""Add a card that supports multiple currencies"""
card_data = {
"type": "credit_card",
"cardNumber": card_details["card_number"],
"expiryMonth": card_details["expiry_month"],
"expiryYear": card_details["expiry_year"],
"cvv": card_details["cvv"],
"cardholderName": card_details["cardholder_name"],
"billingAddress": card_details["billing_address"],
"supportedCurrencies": supported_currencies, # ["USD", "EUR", "GBP"]
"defaultCurrency": "USD",
"dynamicCurrencyConversion": True
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/payment-methods",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=card_data
)
return response.json()
def get_currency_exchange_rates():
"""Get current exchange rates for supported currencies"""
response = requests.get(
"https://api.tensorone.ai/v2/billing/exchange-rates",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
return response.json()
# Add international payment methods
international_card = {
"card_number": "4000000000000002", # Test card
"expiry_month": "12",
"expiry_year": "26",
"cvv": "123",
"cardholder_name": "International Corp",
"billing_address": {
"street": "123 International St",
"city": "London",
"state": "",
"postalCode": "SW1A 1AA",
"country": "GB"
}
}
# multi_currency_result = add_multi_currency_card(
# international_card,
# ["USD", "EUR", "GBP", "JPY"]
# )
Payment Method Automation
Python
Copy
def setup_payment_automation():
"""Configure automatic payment method selection and failover"""
automation_config = {
"enableSmartRouting": True,
"routingRules": [
{
"condition": "amount > 5000",
"preferredMethod": "bank_account",
"reason": "Lower fees for large amounts"
},
{
"condition": "currency != USD",
"preferredMethod": "multi_currency_card",
"reason": "Better exchange rates"
},
{
"condition": "recurring_payment == true",
"preferredMethod": "credit_card",
"reason": "Higher reliability for recurring charges"
}
],
"failoverChain": [
"primary_credit_card",
"backup_credit_card",
"bank_account",
"digital_wallet"
],
"retryPolicy": {
"maxRetries": 3,
"retryDelay": "1h",
"exponentialBackoff": True
},
"notifications": {
"onFailure": True,
"onSuccess": False,
"onFailover": True,
"channels": ["email", "webhook"]
}
}
response = requests.post(
"https://api.tensorone.ai/v2/billing/payment-automation",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json=automation_config
)
return response.json()
# Configure payment automation
automation_result = setup_payment_automation()
print(f"Payment automation configured: {automation_result.get('success', False)}")
Best Practices
Security Best Practices
- Regular Audits: Perform monthly security audits of payment methods
- Strong Authentication: Enable 2FA for all payment method changes
- Fraud Monitoring: Set up real-time fraud detection and alerts
- Access Controls: Limit who can add or modify payment methods
Payment Method Management
- Diversification: Maintain multiple payment methods for redundancy
- Expiration Tracking: Monitor and update expiring payment methods
- Cost Optimization: Use appropriate payment methods based on transaction size
- Verification: Always verify new payment methods before use
Compliance and Documentation
- PCI Compliance: Ensure all card data handling meets PCI DSS standards
- Audit Trails: Maintain detailed logs of all payment method changes
- Data Retention: Follow data retention policies for payment information
- Regular Updates: Keep payment method information current
Payment method data is encrypted at rest and in transit. Card numbers are tokenized and never stored in plain text. All payment operations are logged for security and compliance.
Set up automated alerts for expiring cards and failed payments. Use smart routing to automatically select the best payment method based on transaction characteristics and minimize processing fees.