Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
balanced-python/examples/examples.py at master · MauScheff/balanced-python · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
MauScheff
/
balanced-python
Public
forked from
balanced/balanced-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
balanced-python
/
examples
/
examples.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
118 lines (92 loc) · 3.43 KB
master
Breadcrumbs
balanced-python
/
examples
/
examples.py
Copy path
Top
File metadata and controls
Code
Blame
118 lines (92 loc) · 3.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from
__future__
import
unicode_literals
import
os
import
balanced
host
=
os
.
environ
.
get
(
'BALANCED_HOST'
)
options
=
{}
if
host
:
options
[
'scheme'
]
=
'http'
options
[
'host'
]
=
host
options
[
'port'
]
=
5000
balanced
.
configure
(
options
)
print
"create our new api key"
api_key
=
balanced
.
APIKey
().
save
()
print
"Our secret is: "
,
api_key
.
secret
print
"configure with our secret "
+
api_key
.
secret
balanced
.
configure
(
api_key
.
secret
)
print
"create our marketplace"
marketplace
=
balanced
.
Marketplace
().
save
()
if
not
balanced
.
Merchant
.
me
:
raise
Exception
(
"Merchant.me should not be nil"
)
print
"what's my merchant?, easy: Merchant.me: "
,
balanced
.
Merchant
.
me
# what's my marketplace?
if
not
balanced
.
Marketplace
.
my_marketplace
:
raise
Exception
(
"Marketplace.my_marketplace should not be nil"
)
print
"what's my marketplace?, easy: Marketplace.my_marketplace: {}"
.
format
(
balanced
.
Marketplace
.
my_marketplace
)
print
"My marketplace's name is: {}"
.
format
(
marketplace
.
name
)
print
"Changing it to TestFooey"
marketplace
.
name
=
"TestFooey"
marketplace
.
save
()
print
"My marketplace name is now: {}"
.
format
(
marketplace
.
name
)
if
marketplace
.
name
!=
'TestFooey'
:
raise
Exception
(
"Marketplace name is NOT TestFooey!"
)
print
"cool! let's create a new card."
card
=
balanced
.
Card
(
card_number
=
"5105105105105100"
,
expiration_month
=
"12"
,
expiration_year
=
"2015"
,
).
save
()
print
"Our card uri: "
+
card
.
uri
print
"create our **buyer** account"
buyer
=
marketplace
.
create_buyer
(
"buyer@example.org"
,
card
.
uri
)
print
"our buyer account: "
+
buyer
.
uri
print
"hold some amount of funds on the buyer, lets say 15$"
the_hold
=
buyer
.
hold
(
1500
)
print
"ok, no more holds! lets just capture it (for the full amount)"
debit
=
the_hold
.
capture
()
print
"hmm, how much money do i have in escrow? should equal the debit amount"
balanced
.
bust_cache
()
marketplace
=
balanced
.
Marketplace
.
my_marketplace
if
marketplace
.
in_escrow
!=
1500
:
raise
Exception
(
"1500 is not in escrow! this is wrong"
)
print
"i have {} in escrow!"
.
format
(
marketplace
.
in_escrow
)
print
"cool. now let me refund the full amount"
refund
=
debit
.
refund
()
# the full amount!
print
(
"ok, we have a merchant that's signing up, let's create an account for "
"them first, lets create their bank account."
)
bank_account
=
balanced
.
BankAccount
(
account_number
=
"1234567890"
,
bank_code
=
"12"
,
name
=
"Jack Q Merchant"
,
).
save
()
merchant
=
marketplace
.
create_merchant
(
"merchant@example.org"
,
{
'type'
:
"person"
,
'name'
:
"Billy Jones"
,
'street_address'
:
"801 High St."
,
'postal_code'
:
"94301"
,
'country'
:
"USA"
,
'dob'
:
"1842-01"
,
'phone_number'
:
"+16505551234"
,
},
bank_account
.
uri
,
"Jack Q Merchant"
,
)
print
"oh our buyer is interested in buying something for 130.00$"
another_debit
=
buyer
.
debit
(
13000
,
"MARKETPLACE.COM"
)
print
"lets credit our merchant 110.00$"
credit
=
merchant
.
credit
(
11000
,
"Buyer purchased something on MARKETPLACE.COM"
)
print
"lets assume the marketplace charges 15%, so it earned $20"
mp_credit
=
marketplace
.
owner_account
.
credit
(
2000
,
"Our commission from MARKETPLACE"
".COM"
)
print
"ok lets invalid a card"
card
.
is_valid
=
False
card
.
save
()
if
card
.
is_valid
:
raise
Exception
(
"This card is INCORRECTLY VALID"
)
print
"invalidating a bank account"
bank_account
.
delete
()
print
"and there you have it :)"
You can’t perform that action at this time.