Skip to content

Commit da54869

Browse files
committed
Add account credit API reference
1 parent 4bdb927 commit da54869

File tree

5 files changed

+75
-3
lines changed

5 files changed

+75
-3
lines changed

api/rev1/api/accounts.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,18 @@ Returns a list of all accounts for the specified ``Customer``.
6060

6161
.. container:: code-white
6262

63-
.. dcode:: scenario account_list_customer
63+
.. dcode:: scenario account_list_customer
64+
65+
66+
Credit an Account
67+
--------------------
68+
69+
Move funds to an account.
70+
71+
.. cssclass:: dl-horizontal dl-params
72+
73+
.. dcode:: form credits.create
74+
75+
.. container:: code-white
76+
77+
.. dcode:: scenario account_credit

api/rev1/api/credits.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ Send money to a bank account.
8484
.. dcode:: scenario credit_order
8585

8686

87+
Create a Credit to an Account
88+
------------------------------
89+
90+
Move funds to an account.
91+
92+
.. cssclass:: dl-horizontal dl-params
93+
94+
.. dcode:: form credits.create
95+
96+
.. container:: code-white
97+
98+
.. dcode:: scenario account_credit
99+
100+
87101
Fetch a Credit
88102
-----------------
89103

balanced.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9558,7 +9558,16 @@
95589558
"OPTIONS",
95599559
"GET"
95609560
]
9561-
},
9561+
},
9562+
{
9563+
"path": "/accounts/:account_id/credits",
9564+
"description": "",
9565+
"name": "credits.create",
9566+
"methods": [
9567+
"POST",
9568+
"OPTIONS"
9569+
]
9570+
},
95629571
{
95639572
"path": "/credits/:credit_id/reversals",
95649573
"description": "",
@@ -11963,7 +11972,7 @@
1196311972
"sortable": true,
1196411973
"description": "String fields.",
1196511974
"name": "type"
11966-
},
11975+
}
1196711976
],
1196811977
"name": "AccountsIndex"
1196911978
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%namespace file='/_main.mako' name='main'/>
2+
<% main.curl_create_template('credits.create', sel=['account_id']) %>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import requests
2+
3+
debit = json.loads(
4+
storage['debit_order']['response']
5+
)
6+
7+
order_href = debit['links']['debits.order'].replace('{debits.order}', debit['debits'][0]['links']['order'])
8+
9+
order = requests.get(ctx.storage['api_location'] + order_href,
10+
headers={'Accept-Type': ctx.storage.get('accept_type', '*/*')},
11+
auth=(ctx.storage['secret'], '')).json()
12+
13+
order_merchant_accounts_href = "/customers/" + order['orders'][0]['links']['merchant'] \
14+
+ "/accounts?type%5Bcontains%5D=payable"
15+
16+
accounts = requests.get(ctx.storage['api_location'] + order_merchant_accounts_href,
17+
headers={'Accept-Type': ctx.storage.get('accept_type', '*/*')},
18+
auth=(ctx.storage['secret'], '')).json()
19+
20+
account_credits_href = accounts['links']['accounts.credits'].replace('{accounts.id}', accounts['accounts'][0]['id'])
21+
22+
request = {
23+
'uri': account_credits_href,
24+
'payload': {
25+
'amount': 1000,
26+
'description': 'A simple credit',
27+
'appears_on_statement_as': 'ThingsCo',
28+
'order': order['orders'][0]['href'],
29+
"meta": {
30+
"rating": 8
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)