Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/auth_manager/get_api_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from dotenv import load_dotenv

from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.auth.api_token.response.api_token import ApiToken
from multisafepay.api.paths.auth.auth_manager import AuthManager
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse
from multisafepay.api.paths import AuthManager
from multisafepay.api.paths.auth import ApiToken

# Load environment variables from a .env file
load_dotenv()
Expand Down
19 changes: 11 additions & 8 deletions examples/capture_manager/capture_reservation_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from dotenv import load_dotenv

from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.capture.request.capture_request import CaptureRequest
from multisafepay.api.paths.capture.response.capture import CancelReservation
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse
from multisafepay.api.paths.capture.request import CaptureRequest

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -21,12 +20,16 @@
capture_manager = multisafepay_sdk.get_capture_manager()

# Create a capture request with status 'cancelled' and a reason
capture_request = (CaptureRequest().add_status('cancelled').add_reason('<reason>'))
capture_request = (
CaptureRequest().add_status('cancelled').add_reason('<reason>')
)

# Cancel the capture reservation for the given order ID
capture_reservation_cancel_response: CustomApiResponse = capture_manager.capture_reservation_cancel(
'<order_id>',
capture_request)
capture_reservation_cancel_response: CustomApiResponse = (
capture_manager.capture_reservation_cancel(
'<order_id>', capture_request
)
)
# Print the API response containing the capture reservation cancel information
# print(capture_reservation_cancel_response)

Expand Down
11 changes: 6 additions & 5 deletions examples/category_manager/get_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

from dotenv import load_dotenv

from multisafepay.api.base.listings.listing import Listing
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.categories.response.category import Category
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse
from multisafepay.api.paths.categories.response import Category

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -22,7 +21,9 @@
category_manager = multisafepay_sdk.get_category_manager()

# Request categories through the category manager
get_categories_response: CustomApiResponse = category_manager.get_categories()
get_categories_response: CustomApiResponse = (
category_manager.get_categories()
)

# Print the API response containing the categories
# print(get_categories_response)
Expand Down
13 changes: 7 additions & 6 deletions examples/gateway_manager/get_by_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from dotenv import load_dotenv

from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.gateways.gateway_manager import GatewayManager
from multisafepay.api.paths.gateways.response.gateway import Gateway
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse
from multisafepay.api.paths.gateways.response import Gateway

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -18,10 +17,12 @@
multisafepay_sdk: Sdk = Sdk(API_KEY, False)

# Get the gateway manager from the SDK
gateway_manager: GatewayManager = multisafepay_sdk.get_gateway_manager()
gateway_manager = multisafepay_sdk.get_gateway_manager()

# Request the gateway information by its code
get_by_code_response: CustomApiResponse = gateway_manager.get_by_code("IDEAL")
get_by_code_response: CustomApiResponse = gateway_manager.get_by_code(
"IDEAL"
)

# Print the API response containing the gateway information
# print(get_by_code_response)
Expand Down
17 changes: 9 additions & 8 deletions examples/gateway_manager/get_gateways.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

from dotenv import load_dotenv

from multisafepay.api.base.listings.listing import Listing
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.gateways.gateway_manager import GatewayManager
from multisafepay.api.paths.gateways.response.gateway import Gateway
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse
from multisafepay.api.paths import GatewayManager
from multisafepay.api.paths.gateways.response import Gateway

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -23,12 +22,14 @@
gateway_manager: GatewayManager = multisafepay_sdk.get_gateway_manager()

# Request the list of gateways
get_gateways_response: CustomApiResponse = gateway_manager.get_gateways()
get_gateways_response: CustomApiResponse = (
gateway_manager.get_gateways()
)

# Print the API response containing the list of gateways
# print(get_gateways_response)

# Extract the listing of gateways from the response
gatewayListing: List[Gateway] = get_gateways_response.get_data()
gateway_listing: List[Gateway] = get_gateways_response.get_data()

print(gatewayListing)
print(gateway_listing)
15 changes: 9 additions & 6 deletions examples/issuer_manager/get_issuers_by_gateway_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

from dotenv import load_dotenv

from multisafepay.api.base.response.custom_api_response import CustomApiResponse
from multisafepay.api.paths.issuers.issuer_manager import IssuerManager
from multisafepay.sdk import Sdk
from multisafepay import Sdk
from multisafepay.api.base.response import CustomApiResponse

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -17,15 +16,19 @@
multisafepay_sdk = Sdk(API_KEY, False)

# Get the issuer manager from the SDK
issuer_manager: IssuerManager = multisafepay_sdk.get_issuer_manager()
issuer_manager = multisafepay_sdk.get_issuer_manager()

# Request the list of issuers by the gateway code "MYBANK"
get_issuers_by_gateway_code_response: CustomApiResponse = issuer_manager.get_issuers_by_gateway_code("MYBANK")
get_issuers_by_gateway_code_response: CustomApiResponse = (
issuer_manager.get_issuers_by_gateway_code("MYBANK")
)

# Print the API response containing the list of issuers
# print(get_issuers_by_gateway_code_response)

# Print the API response containing the list of issuers
issuers_by_gateway_code = get_issuers_by_gateway_code_response.get_data()
issuers_by_gateway_code = (
get_issuers_by_gateway_code_response.get_data()
)

print(issuers_by_gateway_code)
2 changes: 1 addition & 1 deletion examples/me_manager/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dotenv import load_dotenv

from multisafepay.sdk import Sdk
from multisafepay import Sdk

# Load environment variables from a .env file
load_dotenv()
Expand Down
21 changes: 12 additions & 9 deletions examples/order_manager/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from dotenv import load_dotenv

from multisafepay.api.paths.orders.order_id.capture.request.capture_request import CaptureOrderRequest
from multisafepay.sdk import Sdk
from multisafepay.value_object.amount import Amount
from multisafepay.value_object.currency import Currency
from multisafepay import Sdk
from multisafepay.api.paths.orders.order_id.capture.request import (
CaptureOrderRequest,
)
from multisafepay.value_object import Amount

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -24,11 +25,13 @@
amount = Amount(amount=10)

# Create a CaptureOrderRequest object and add the capture details
capture_request = (CaptureOrderRequest()
.add_amount(amount)
.add_reason('Order captured')
.add_new_order_id('<capture_order_id>')
.add_new_order_status('completed'))
capture_request = (
CaptureOrderRequest()
.add_amount(amount)
.add_reason('Order captured')
.add_new_order_id('<capture_order_id>')
.add_new_order_status('completed')
)

# Capture the order with the specified order ID using the order manager
capture_response = order_manager.capture('<order_id>', capture_request)
Expand Down
127 changes: 69 additions & 58 deletions examples/order_manager/create.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import time
import os
import time

from dotenv import load_dotenv
from multisafepay.value_object.weight import Weight
from multisafepay.api.shared.cart.cart_item import CartItem
from multisafepay.api.paths.orders.request.components.checkout_options import CheckoutOptions
from multisafepay.api.paths.orders.request.components.payment_options import PaymentOptions
from multisafepay.api.paths.orders.request.components.plugin import Plugin
from multisafepay.api.paths.orders.request.order_request import OrderRequest
from multisafepay.api.shared.cart.shopping_cart import ShoppingCart
from multisafepay.api.shared.customer import Customer
from multisafepay.sdk import Sdk
from multisafepay.value_object.amount import Amount
from multisafepay.value_object.country import Country
from multisafepay.value_object.currency import Currency
from multisafepay.api.shared.description import Description
from multisafepay.value_object.email_address import EmailAddress
from multisafepay.value_object.ip_address import IpAddress
from multisafepay.value_object.phone_number import PhoneNumber
from multisafepay.api.paths.orders.response.order_response import Order

from multisafepay import Sdk
from multisafepay.api.paths.orders.request import OrderRequest
from multisafepay.api.paths.orders.request.components import (
CheckoutOptions,
PaymentOptions,
Plugin,
)
from multisafepay.api.paths.orders.response import Order
from multisafepay.api.shared import Customer, Description
from multisafepay.api.shared.cart import CartItem, ShoppingCart
from multisafepay.value_object import (
Amount,
Country,
Currency,
EmailAddress,
IpAddress,
PhoneNumber,
Weight,
)

# Load environment variables from a .env file
load_dotenv()
Expand Down Expand Up @@ -83,52 +87,59 @@

# Create cart items
cart_items = [
CartItem()
.add_name('Geometric Candle Holders')
.add_description('Geometric Candle Holders description')
.add_unit_price(90)
.add_quantity(3)
.add_merchant_item_id('1111')
.add_tax_rate_percentage(21)
.add_weight(Weight(value=1.0, unit='kg')),

CartItem()
.add_name('Nice apple')
.add_description('Nice apple description')
.add_unit_price(35)
.add_quantity(1)
.add_merchant_item_id('666666')
.add_tax_rate_percentage(9)
.add_weight(Weight(value=20, unit='kg')),

CartItem()
.add_name('Flat Rate - Fixed')
.add_description('Shipping')
.add_unit_price(10)
.add_quantity(1)
.add_merchant_item_id('msp-shipping')
.add_tax_rate_percentage(0)
.add_weight(Weight(value=0, unit='kg'))
(
CartItem()
.add_name('Geometric Candle Holders')
.add_description('Geometric Candle Holders description')
.add_unit_price(90)
.add_quantity(3)
.add_merchant_item_id('1111')
.add_tax_rate_percentage(21)
.add_weight(Weight(value=1.0, unit='kg'))
),
(
CartItem()
.add_name('Nice apple')
.add_description('Nice apple description')
.add_unit_price(35)
.add_quantity(1)
.add_merchant_item_id('666666')
.add_tax_rate_percentage(9)
.add_weight(Weight(value=20, unit='kg'))
),
(
CartItem()
.add_name('Flat Rate - Fixed')
.add_description('Shipping')
.add_unit_price(10)
.add_quantity(1)
.add_merchant_item_id('msp-shipping')
.add_tax_rate_percentage(0)
.add_weight(Weight(value=0, unit='kg'))
),
]

# Create shopping_cart
shopping_cart = ShoppingCart().add_items(cart_items)

# Create an OrderRequest object and add the order details
order_request = (OrderRequest()
.add_type('direct')
.add_order_id(order_id)
.add_description(description)
.add_amount(amount)
.add_currency(currency)
.add_gateway('IDEAL')
.add_customer(customer)
.add_delivery(customer)
.add_plugin(plugin)
.add_payment_options(payment_options)
.add_shopping_cart(shopping_cart)
.add_checkout_options(CheckoutOptions.generate_from_shopping_cart(shopping_cart))
)
order_request = (
OrderRequest()
.add_type('direct')
.add_order_id(order_id)
.add_description(description)
.add_amount(amount)
.add_currency(currency)
.add_gateway('IDEAL')
.add_customer(customer)
.add_delivery(customer)
.add_plugin(plugin)
.add_payment_options(payment_options)
.add_shopping_cart(shopping_cart)
.add_checkout_options(
CheckoutOptions.generate_from_shopping_cart(shopping_cart)
)
)

# Get the order manager from the SDK
order_manager = multisafepay_sdk.get_order_manager()
Expand Down
8 changes: 6 additions & 2 deletions examples/order_manager/create_refund_request.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

from dotenv import load_dotenv

from multisafepay import Sdk
from multisafepay.api.paths.orders.order_manager import OrderManager
from multisafepay.sdk import Sdk

# Load environment variables from a .env file
load_dotenv()
Expand All @@ -20,7 +22,9 @@
order_response = order_manager.get('<order_id>')

# Create a refund request for the retrieved order
create_refund_request_response = OrderManager.create_refund_request(order_response.get_data())
create_refund_request_response = OrderManager.create_refund_request(
order_response.get_data()
)

# Print the response of the refund request
print(create_refund_request_response)
2 changes: 1 addition & 1 deletion examples/order_manager/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dotenv import load_dotenv

from multisafepay.sdk import Sdk
from multisafepay import Sdk

# Load environment variables from a .env file
load_dotenv()
Expand Down
Loading