-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2abf0aa
commit 87832e3
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import xendit | ||
|
||
from xendit.models.paymentmethod import ewallet | ||
|
||
from print_running_function import print_running_function | ||
|
||
|
||
class CreatePaymentMethod: | ||
@staticmethod | ||
def run(xendit_instance, **kwargs): | ||
try: | ||
payment_method = xendit_instance.PaymentMethod.create(**kwargs) | ||
print(payment_method) | ||
except xendit.XenditError as e: | ||
print("Error status code:", e.status_code) | ||
print("Error message:", e) | ||
|
||
@staticmethod | ||
def example(xendit_instance): | ||
args = { | ||
"type": "EWALLET", | ||
"reusability": "ONE_TIME_USE", | ||
"ewallet": ewallet.EWallet.Query( | ||
channel_code="PAYMAYA", | ||
channel_properties=ewallet.ChannelProperties.Query( | ||
success_return_url="https://mock-test.co", | ||
failure_return_url="https://mock-test.co", | ||
cancel_return_url="https://mock-test.co", | ||
), | ||
), | ||
} | ||
print_running_function("xendit.PaymentMethod.create", args) | ||
CreatePaymentMethod.run(xendit_instance, **args) | ||
|
||
|
||
def ask_payment_method_input(): | ||
print("Input the action that you want to use") | ||
print("0. Exit") | ||
print("1. Create Payment Method") | ||
try: | ||
return int(input()) | ||
except ValueError: | ||
print("Invalid input. Please type a number") | ||
return ask_payment_method_input() | ||
|
||
|
||
def payment_method_example(xendit_instance): | ||
payment_method_input = ask_payment_method_input() | ||
while payment_method_input != 0: | ||
if payment_method_input == 1: | ||
print("Running example of Create Payment Method") | ||
CreatePaymentMethod.example(xendit_instance) | ||
payment_method_input = ask_payment_method_input() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import xendit | ||
|
||
from xendit.models import ewallet, PaymentMethod | ||
|
||
from print_running_function import print_running_function | ||
|
||
|
||
class CreatePaymentRequest: | ||
@staticmethod | ||
def run(xendit_instance, **kwargs): | ||
try: | ||
payment_request = xendit_instance.PaymentRequest.create(**kwargs) | ||
print(payment_request) | ||
except xendit.XenditError as e: | ||
print("Error status code:", e.status_code) | ||
print("Error message:", e) | ||
|
||
@staticmethod | ||
def example(xendit_instance): | ||
args = { | ||
"amount": 1500, | ||
"currency": "IDR", | ||
"payment_method": PaymentMethod.Query( | ||
type="EWALLET", | ||
reusability="ONE_TIME_USE", | ||
ewallet=ewallet.EWallet.Query( | ||
channel_code="OVO", | ||
channel_properties=ewallet.ChannelProperties.Query( | ||
mobile_number="+628123123123" | ||
), | ||
), | ||
), | ||
} | ||
print_running_function("xendit.PaymentRequest.create", args) | ||
CreatePaymentRequest.run(xendit_instance, **args) | ||
|
||
|
||
def ask_payment_method_input(): | ||
print("Input the action that you want to use") | ||
print("0. Exit") | ||
print("1. Create Payment Request") | ||
try: | ||
return int(input()) | ||
except ValueError: | ||
print("Invalid input. Please type a number") | ||
return ask_payment_method_input() | ||
|
||
|
||
def payment_method_example(xendit_instance): | ||
payment_method_input = ask_payment_method_input() | ||
while payment_method_input != 0: | ||
if payment_method_input == 1: | ||
print("Running example of Create Payment Method") | ||
CreatePaymentRequest.example(xendit_instance) | ||
payment_method_input = ask_payment_method_input() |