Skip to content

Commit 7b2724b

Browse files
committed
update readme
1 parent e5c2a9b commit 7b2724b

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ snap = midtransclient.Snap(
6363
)
6464
```
6565

66+
```python
67+
# Create Subscription API instance
68+
subscription = midtransclient.Subscription(
69+
is_production=False,
70+
server_key='YOUR_SERVER_KEY',
71+
client_key='YOUR_CLIENT_KEY'
72+
)
73+
```
74+
75+
```python
76+
# Create Tokenization API instance
77+
tokenization = midtransclient.Tokenization(
78+
is_production=False,
79+
server_key='YOUR_SERVER_KEY',
80+
client_key='YOUR_CLIENT_KEY'
81+
)
82+
```
83+
6684
You can also re-set config using `Snap.api_config.set( ... )`
6785
example:
6886

@@ -303,6 +321,88 @@ The credit card charge result may contains `redirect_url` for 3DS authentication
303321
For full example on Credit Card 3DS transaction refer to:
304322
- [Flask App examples](/examples/flask_app) that implement Snap & Core Api
305323

324+
### 2.2.D Subscription API
325+
You can see some Subscription API examples [here](examples/subscription).
326+
327+
```python
328+
# Create Subscription API instance
329+
subscription = midtransclient.Subscription(
330+
is_production=False,
331+
server_key='YOUR_SERVER_KEY',
332+
client_key='YOUR_CLIENT_KEY'
333+
)
334+
# Build parameter
335+
param = {
336+
"name": "SUBSCRIPTION-STARTER-1",
337+
"amount": "100000",
338+
"currency": "IDR",
339+
"payment_type": "credit_card",
340+
"token": "436502qFfqfAQKScMtPRPdZDOaeg7199",
341+
"schedule": {
342+
"interval": 1,
343+
"interval_unit": "month",
344+
"max_interval": 3,
345+
"start_time": "2021-10-01 07:25:01 +0700"
346+
},
347+
"metadata": {
348+
"description": "Recurring payment for STARTER 1"
349+
},
350+
"customer_details": {
351+
"first_name": "John A",
352+
"last_name": "Doe A",
353+
"email": "[email protected]",
354+
"phone": "+62812345678"
355+
}
356+
}
357+
create_subscription = subscription.create(param)
358+
359+
subscription_id = create_subscription['id']
360+
# get subscription by subscription_id
361+
get_subscription = subscription.get(subscription_id)
362+
363+
# disable subscription by subscription_id
364+
disable_subscription = subscription.disable(subscription_id)
365+
366+
# enable subscription by subscription_id
367+
enable_subscription = subscription.enable(subscription_id)
368+
369+
# update subscription by subscription_id
370+
update_param = {
371+
"name": "SUBSCRIPTION-STARTER-1-UPDATE",
372+
}
373+
update_subscription = subscription.update(subscription_id, update_param)
374+
```
375+
376+
### 2.2.E Tokenization API
377+
You can see some Tokenization API examples [here](examples/tokenization).
378+
379+
```python
380+
# Create Tokenization API instance
381+
tokenization = midtransclient.Tokenization(
382+
is_production=False,
383+
server_key='YOUR_SERVER_KEY',
384+
client_key='YOUR_CLIENT_KEY'
385+
)
386+
# Build parameter
387+
param = {
388+
"payment_type": "gopay",
389+
"gopay_partner": {
390+
"phone_number": "81234567891",
391+
"country_code": "62",
392+
"redirect_url": "https://midtrans.com"
393+
}
394+
}
395+
396+
# link payment account
397+
link_payment_account = tokenization.link_account(param)
398+
399+
# get payment account
400+
get_payment_account = tokenization.get_account(active_account_id)
401+
402+
# unlink account
403+
unlink_payment_account = tokenization.unlink_account(active_account_id)
404+
```
405+
306406
### 2.3 Handle HTTP Notification
307407

308408
> **IMPORTANT NOTE**: To update transaction status on your backend/database, **DO NOT** solely rely on frontend callbacks! For security reason to make sure the status is authentically coming from Midtrans, only update transaction status based on HTTP Notification or API Get Status.
@@ -479,6 +579,8 @@ Under the hood this API wrapper is using [Requests](https://github.com/requests/
479579
Examples are available on [/examples](/examples) folder.
480580
There are:
481581
- [Core Api examples](/examples/core_api)
582+
- [Subscription examples](/examples/subscription)
583+
- [Tokenization examples](/examples/tokenization)
482584
- [Snap examples](/examples/snap)
483585
- [Flask App examples](/examples/flask_app) that implement Snap & Core Api
484586

0 commit comments

Comments
 (0)