Skip to content

Commit edc6f4f

Browse files
authored
Merge pull request killbill#612 from reshmabidikar/wallet-doc-corrections
Wallet doc corrections
2 parents 455a680 + d5109ab commit edc6f4f

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

userguide/aviate/aviate-custom-invoice-sequencing.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This section provides a step-by-step approach to get started with Aviate Custom
1010

1111
The Aviate plugin can be installed as documented in the https://docs.killbill.io/latest/how-to-install-the-aviate-plugin.html[How to Install the Aviate Plugin] doc.
1212

13-
== Enabling Aviate Custom Invoice Sequencing
13+
=== Enabling Aviate Custom Invoice Sequencing
1414

1515
To use the custom invoice sequencing feature provided by the Aviate plugin, ensure that KB is started with the following property:
1616

userguide/aviate/aviate-usage-ai-tutorial.adoc

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You will need:
2727

2828
We start by creating a tenant `usage-scenario`.
2929

30-
Use the standard Kill Bill API: https://killbill.github.io/slate/tenant.html#create-a-tenant
30+
Use the standard https://killbill.github.io/slate/tenant.html#create-a-tenant[Create Tenant] Kill Bill API:
3131

3232
[source,bash]
3333
-----
@@ -45,6 +45,8 @@ A BillingMeter defines how usage points are filtered and aggregated. Before crea
4545

4646
For reference, this uses the https://docs.killbill.io/latest/aviate-metering[aviate metering capabilities].
4747

48+
Use the https://killbill.github.io/slate/aviate-metering.html#create-billing-meter[Create Billing Meter] API.
49+
4850
[source,bash]
4951
-----
5052
curl -X POST \
@@ -94,7 +96,7 @@ For reference, this uses the https://docs.killbill.io/latest/aviate-catalog-plug
9496

9597
The full payload and API call can be seen below:
9698

97-
Use aviate API: https://killbill.github.io/slate/aviate-catalog.html#create-plan-product-pricelist
99+
Use the https://killbill.github.io/slate/aviate-catalog.html#create-plan-product-pricelist[Create Plan, Product, Pricelist] API:
98100

99101
[source,bash]
100102
-----
@@ -105,33 +107,35 @@ curl -X POST \
105107
-H "X-killbill-apisecret: usage-scenario" \
106108
-d '{"plans":[{"name":"usage-monthly","prettyName":"Usage Monthly Scenario","recurringBillingMode":"IN_ADVANCE","pricelistName":"DEFAULT","productName":"UsageDemo","phases":[{"prettyName":"Premium Annual Evergreen","type":"EVERGREEN","durationUnit":"UNLIMITED","durationLength":-1,"usages":[{"usageName":"usage-monthly-1","usageType":"CONSUMABLE","billingPeriod":"MONTHLY","tiers":[{"tierNumber":1,"blocks":[{"billingMeterCode":"input-M-tokens","size":1000000,"max":-1,"prices":[{"currency":"USD","value":"2.0"}]}]}]}]}]}],"products":[{"name":"UsageDemo","category":"BASE"}]}' \
107109
http://127.0.0.1:8080/plugins/aviate-plugin/v1/catalog/inputData
108-
109-
-> {"catalogName":"","plans":[{"name":"usage-monthly","prettyName":"Usage Monthly Scenario","recurringBillingMode":"IN_ADVANCE","effectiveDate":"2025-05-01T00:41:30.000Z","effectiveDateForExistingSubscriptions":"","productName":"UsageDemo","pricelistName":"DEFAULT","retired":false,"phases":[{"prettyName":"Premium Annual Evergreen","type":"EVERGREEN","durationUnit":"UNLIMITED","durationLength":-1,"fixedPrices":[],"usages":[{"usageName":"usage-monthly-1","prettyName":"","usageType":"CONSUMABLE","billingPeriod":"MONTHLY","tierBlockPolicy":"","tiers":[{"tierNumber":1,"blocks":[{"billingMeterCode":"input-M-tokens","size":1000000,"max":-1,"prices":[{"currency":"USD","value":"2.000000000"}]}]}]}]}]}],"products":[{"name":"UsageDemo","prettyName":"","category":"BASE","availableForBps":[],"availableAddons":[]}]}
110110
-----
111111

112112
== Creating a Customer Account
113113

114114
=== Step 1: Create an account
115115

116-
Use the standard Kill Bill API:https://killbill.github.io/slate/account.html#create-an-account
116+
Use the standard Kill Bill https://killbill.github.io/slate/account.html#create-an-account[Create Account] API:
117117

118118
[source,bash]
119119
-----
120120
curl -v -X POST -u admin:password \
121121
-H "X-Killbill-ApiKey: usage-scenario" \
122+
-H "X-killbill-apisecret: usage-scenario" \
123+
-H "X-Killbill-CreatedBy: demo" \
122124
-H "Content-Type: application/json" \
123125
-d '{ "name": "John Doe", "email": "john.doe@somewhere.com", "currency": "USD" }' \
124126
"http://127.0.0.1:8080/1.0/kb/accounts"
125127
-----
126128

127-
=== Step 2: Add a default payment method
129+
=== Step 2: Add a payment method
128130

129-
Use the standard Kill Bill API: https://killbill.github.io/slate/account.html#add-a-payment-method
131+
Use the standard Kill Bill https://killbill.github.io/slate/account.html#add-a-payment-method[Add Payment Method] API:
130132

131133
[source,bash]
132134
-----
133135
curl -v -X POST -u admin:password \
134136
-H "X-Killbill-ApiKey: usage-scenario" \
137+
-H "X-killbill-apisecret: usage-scenario" \
138+
-H "X-Killbill-CreatedBy: demo" \
135139
-H "Content-Type: application/json" \
136140
-d '{ "externalKey": "ExternalKey", "pluginName": "__EXTERNAL_PAYMENT__" }' \
137141
"http://127.0.0.1:8080/1.0/kb/accounts/{accountId}/paymentMethods"
@@ -141,12 +145,14 @@ Note that we did not pass the query parameter `?isDefault=true`, meaning there i
141145

142146
=== Step 3: Create a subscription using the usage plan previously created
143147

144-
Use the standard Kill Bill API: https://apidocs.killbill.io/subscription#create-a-subscription
148+
Use the standard Kill Bill https://apidocs.killbill.io/subscription#create-a-subscription[Create Subscription] API:
145149

146150
[source,bash]
147151
-----
148152
curl -v -X POST -u admin:password \
149153
-H "X-Killbill-ApiKey: usage-scenario" \
154+
-H "X-killbill-apisecret: usage-scenario" \
155+
-H "X-Killbill-CreatedBy: demo" \
150156
-H "Content-Type: application/json" \
151157
-d '{ "accountId": "{accountId}", "planName": "usage-monthly" }' \
152158
"http://127.0.0.1:8080/1.0/kb/subscriptions"
@@ -162,25 +168,29 @@ Finally, we also set some expiration dates on these credits as indicated in the
162168

163169
For reference, this uses the https://docs.killbill.io/latest/aviate-wallet[aviate wallet capabilities]
164170

171+
Use the https://killbill.github.io/slate/aviate-wallet.html#create-a-wallet[Create Wallet] API:
172+
165173
[source,bash]
166174
-----
167175
curl -v -X POST \
168176
-H "Authorization: Bearer ${ID_TOKEN}" \
169177
-H "X-Killbill-ApiKey: usage-scenario" \
178+
-H "X-killbill-apisecret: usage-scenario" \
170179
-H 'Content-Type: application/json' \
171180
-d '{ "kbAccountId": "{accountId}", "currency": "USD", "initCredit": { "creditType": "CREDIT_PAID", "amount": "10.00", "expDate": "2025-12-31T00:00:00Z" }, "topOff": { "topOffType": "TOP_OFF_TARGET", "lowWatermark": "5.00", "amount": "10.00", "expDurationUnit": "MONTHS", "expDurationLength": 3 } }' \
172181
http://127.0.0.1:8080/plugins/aviate-plugin/v1/wallet
173182
-----
174183

175184
Note that we see a `WALLET_PAYMENT_FAILED` status because we did not pass the query parameter `?isDefault=true` when adding the payment method. The wallet was created, but the initial credits are not yet made available.
176185

177-
178186
== Recording Usage Points
179187

180188
=== Step 1: Record usage points
181189

182190
For reference, this uses the https://docs.killbill.io/latest/aviate-metering[aviate metering capabilities]
183191

192+
Use the https://killbill.github.io/slate/aviate-metering.html#submit-usage-events[Submit Usage Event] API:
193+
184194
[source,bash]
185195
-----
186196
curl -v -X POST \
@@ -189,30 +199,33 @@ curl -v -X POST \
189199
-H "X-killbill-apiKey: usage-scenario" \
190200
-H "X-killbill-apisecret: usage-scenario" \
191201
-d '[{"billingMeterCode": "input-M-tokens", "subscriptionId": "{subscriptionId}", "timestamp": "2025-05-01T05:30:00.000Z", "value": 100000}]' \
192-
http://127.0.0.1:8080/plugins/aviate-plugin/v1/metering/billing/{tenantId}
202+
http://127.0.0.1:8080/plugins/aviate-plugin/v1/metering/billing/{accountId}
193203
-----
194204

195205
=== Step 2: Fetch usage points
196206

197-
Use the standard Kill Bill API: https://apidocs.killbill.io/usage#retrieve-usage-for-a-subscription
207+
Use the standard Kill Bill https://apidocs.killbill.io/usage#retrieve-usage-for-a-subscription[Retrieve Subscription Usage] API:
198208

199209
[source,bash]
200210
-----
201211
curl -v -u admin:password \
202212
-H "X-Killbill-ApiKey: usage-scenario" \
213+
-H "X-killbill-apisecret: usage-scenario" \
203214
"http://127.0.0.1:8080/1.0/kb/usages/{subscriptionId}?startDate=2025-05-01&endDate=2025-05-31"
204215
-----
205216

206217
== Invoicing Usage
207218

208219
=== Step 1: Trigger invoice
209220

210-
Use the standard Kill Bill API: https://apidocs.killbill.io/invoice#trigger-an-invoice-run
221+
Use the standard Kill Bill https://apidocs.killbill.io/invoice#trigger-an-invoice-run[Trigger Invoice Run] API:
211222

212223
[source,bash]
213224
-----
214225
curl -v -X POST -u admin:password \
215226
-H "X-Killbill-ApiKey: usage-scenario" \
227+
-H "X-killbill-apisecret: usage-scenario" \
228+
-H "X-Killbill-CreatedBy: demo" \
216229
-H "Content-Type: application/json" \
217230
"http://127.0.0.1:8080/1.0/kb/invoices?accountId={accountId}&targetDate=2025-06-01"
218231
@@ -221,49 +234,57 @@ curl -v -X POST -u admin:password \
221234

222235
=== Step 2: Fetch invoice
223236

224-
Use the standard Kill Bill API: https://apidocs.killbill.io/invoice#retrieve-an-invoice-by-id
237+
Use the standard Kill Bill https://apidocs.killbill.io/invoice#retrieve-an-invoice-by-id[Retrieve Invoice] API:
225238

226239
[source,bash]
227240
-----
228241
curl -v -u admin:password \
229242
-H "X-Killbill-ApiKey: usage-scenario" \
243+
-H "X-killbill-apisecret: usage-scenario" \
230244
"http://127.0.0.1:8080/1.0/kb/invoices/{invoiceId}"
231245
-----
232246

233247
== Payment Retry and Credit Activation
234248

235249
=== Step 1: Set default payment method
236250

237-
Use the standard Kill Bill API: https://killbill.github.io/slate/account.html#set-the-default-payment-method
251+
Use the standard Kill Bill https://killbill.github.io/slate/account.html#set-the-default-payment-method[Set Default Payment Method] API:
238252

239253
[source,bash]
240254
-----
241255
curl -v -X PUT -u admin:password \
242256
-H "X-Killbill-ApiKey: usage-scenario" \
257+
-H "X-killbill-apisecret: usage-scenario" \
258+
-H "X-Killbill-CreatedBy: demo" \
243259
"http://127.0.0.1:8080/1.0/kb/accounts/{accountId}/paymentMethods/{paymentMethodId}/setDefault"
244260
-----
245261

246262
=== Step 2: Retry invoice payment
247263

248-
Use the standard Kill Bill API: https://killbill.github.io/slate/invoice.html#trigger-a-payment-for-an-invoice
264+
Use the standard Kill Bill https://killbill.github.io/slate/invoice.html#trigger-a-payment-for-an-invoice[Trigger Payment for an Invoice] API:
249265

250266
[source,bash]
251267
-----
252268
curl -v -X POST -u admin:password \
253269
-H "X-Killbill-ApiKey: usage-scenario" \
270+
-H "X-killbill-apisecret: usage-scenario" \
271+
-H "X-Killbill-CreatedBy: demo" \
272+
-H "Content-Type: application/json" \
273+
-H "Accept: application/json" \
254274
-d '{ "accountId": "{accountId}", "purchasedAmount": 10, "targetInvoiceId": "{invoiceId}" }' \
255275
"http://localhost:8080/1.0/kb/invoices/{invoiceId}/payments"
256276
-----
257277

258278
=== Step 3: Fetch wallet accounts
259279

260-
https://apidocs.killbill.io/aviate-wallet#retrieve-wallets-for-user-account
280+
Use the https://apidocs.killbill.io/aviate-wallet#retrieve-wallets-for-user-account[Retrieve Wallets for Account] API:
261281

262282
[source,bash]
263283
-----
264284
curl -X GET \
265285
-H "Authorization: Bearer ${ID_TOKEN}" \
266286
-H 'X-Killbill-ApiKey: usage-scenario' \
287+
-H "X-killbill-apisecret: usage-scenario" \
267288
http://127.0.0.1:8080/plugins/aviate-plugin/v1/wallet/{accountId}
268289
-----
269290

0 commit comments

Comments
 (0)