You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
import json
|
|
import stripe
|
|
from typing import List, Dict, Union, Any
|
|
from datetime import datetime
|
|
from app import create_app, db
|
|
from models import Payments, PaymentBatch, SinglePayments, PaymentPlans
|
|
from splynx import Splynx, SPLYNX_URL, SPLYNX_KEY, SPLYNX_SECRET
|
|
from services import log_activity
|
|
from config import Config
|
|
|
|
|
|
splynx = Splynx(url=SPLYNX_URL, key=SPLYNX_KEY, secret=SPLYNX_SECRET)
|
|
|
|
|
|
#api_key = Config.STRIPE_LIVE_API_KEY
|
|
api_key = Config.STRIPE_TEST_API_KEY
|
|
|
|
stripe.api_key = api_key
|
|
|
|
def attach_becs_payment_to_customer():
|
|
payment_method = stripe.PaymentMethod.create(
|
|
type='au_becs_debit',
|
|
au_becs_debit={
|
|
'bsb_number': '000000', # 6-digit BSB
|
|
'account_number': '333333335' # Account number
|
|
},
|
|
billing_details={
|
|
'name': 'AU BECS Decline',
|
|
'email': 'customer@example.com'
|
|
}
|
|
)
|
|
|
|
# Attach to customer
|
|
stripe.PaymentMethod.attach(
|
|
payment_method.id,
|
|
customer='cus_SoMVPWxdYstYbr'
|
|
)
|
|
|
|
print(f"Payment method {payment_method.id} attached to customer")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
#splynx_id = 1218789
|
|
#result = splynx.get(url=f"/api/2.0/admin/finance/invoices?main_attributes[customer_id]={splynx_id}&main_attributes[status]=not_paid&main_attributes[status]=pending")
|
|
#
|
|
#print(json.dumps(result,indent=2))
|
|
|
|
#pi = stripe.PaymentIntent.list(customer="cus_SoQiDcSrNRxbPF", limit=1)
|
|
#
|
|
#print(json.dumps(pi,indent=2))
|
|
|
|
print(datetime.now())
|
|
splynx_date = datetime.now().strftime("%Y-%m-%d")
|
|
print(splynx_date)
|
|
print(type(splynx_date))
|