def transaction(transaction_id: str, amount: int=None, description: str=None, process_date: str=None, products: dict={}, vat_percentage: float=None, exchange_url: str=None): """ Refund a transaction :param transaction_id: Transaction ID :type transaction_id: str :param amount: transaction amount to refund :type amount: int :param description: refund description :type description: str :param process_date: date at which refund needs to be processed TODO: this *should* be a datetime :type process_date: str :param products: dictionary of products to refund (keys: product ID, value: quantity) :type products: dict :param vat_percentage: VAT percentage :type vat_percentage: float :param exchange_url: URL for the exchange call :type exchange_url: str :return: Transaction refund response :rtype: paynlsdk.api.refund.transaction.Response """ from paynlsdk.api.refund.transaction import Request client = APIClient() request = Request(transaction_id, amount, description, process_date, products, vat_percentage, exchange_url) client.perform_request(request) return request.response
def refund_response(transaction_id: str, amount: int = None, description: str = None, process_date: datetime = None): """ Get a transaction refund :class:`paynlsdk.api.transaction.refund.Response` instance Please note this will immediately call the API, returning the response instance :param transaction_id: transaction ID :type transaction_id: str :param amount: transaction amount to refund :type amount: int :param description: refund description :type description: str :param process_date: date at which refund needs to be processed TODO: this *should* be a datetime :type process_date: str :return: transaction status :rtype: paynlsdk.api.transaction.refund.Response """ from paynlsdk.api.transaction.refund import Request client = APIClient() request = Request(transaction_id, amount, description, process_date) client.perform_request(request) return request.response
def get_status(self): """ Get transaction status :return: Response object if transaction.status API :rtype: paynlsdk.api.transaction.status.Response """ from paynlsdk.api.transaction.status import Request from paynlsdk.api.client import APIClient client = APIClient() request = Request(self.transaction_id) client.perform_request(request) return request.response
def get_banks() -> List[BankDetails]: """ Gets the list of banks. :return: List of banks :rtype: List[BankDetails] """ from paynlsdk.api.transaction.getbanks import Request client = APIClient() request = Request() client.perform_request(request) return request.response.banks
def start_response(amount: str, ip_address: str, finish_url: str, payment_option_id: int = None, payment_option_sub_id: int = None, transaction: TransactionData = None, stats_data: TransactionStartStatsData = None, end_user: TransactionEndUser = None, sale_data: SalesData = None, test_mode: bool = False, transfer_type: str = None, transfer_value: str = None): """ Get a transaction start :class:`paynlsdk.api.transaction.start.Response` instance Please note this will immediately call the API, returning the response instance :param amount: total order amount(cents) :type amount: int :param ip_address: IP address :type ip_address: str :param finish_url: URL to call when finished :type finish_url: str :param payment_option_id: The ID of the payment option (for iDEAL use 10). :type payment_option_id: int :param payment_option_sub_id: In case of an iDEAL payment this is the ID of the bank See the paymentOptionSubList in the getService function. :type payment_option_sub_id: int :param transaction: :type transaction: TransactionData :param stats_data: :type stats_data: TransactionStartStatsData :param end_user: :type end_user: TransactionEndUser :param sale_data: :type sale_data: SalesData :param test_mode: whether or not to perform this transaction start in TEST mode :type test_mode: bool :param transfer_type: Use transaction, merchant or alliance to change the benificiary owner of the transaction :type transfer_type: str :param transfer_value: Merchant ID (M-xxxx-xxxx) or order ID :type transfer_value: str :return: Transaction start response instance :rtype: paynlsdk.api.transaction.start.Response """ from paynlsdk.api.transaction.start import Request client = APIClient() request = Request(amount, ip_address, finish_url, payment_option_id, payment_option_sub_id, transaction, stats_data, end_user, sale_data, test_mode, transfer_type, transfer_value) client.perform_request(request) return request.response
def get_service_response(payment_method_id: int): """ Get a transaction getservice :class:`paynlsdk.api.transaction.getservice.Response` instance Please note this will immediately call the API, returning the response instance :return: Transaction getservice response instance :rtype: paynlsdk.api.transaction.getservice.Response """ from paynlsdk.api.transaction.getservice import Request client = APIClient() request = Request(payment_method_id) client.perform_request(request) return request.response
def get_banks_response(): """ Get a transaction getbanks :class:`paynlsdk.api.transaction.getbanks.Response` instance Please note this will immediately call the API, returning the response instance :return: Transaction getbanks response instance :rtype: paynlsdk.api.transaction.getbanks.Response """ from paynlsdk.api.transaction.getbanks import Request client = APIClient() request = Request() client.perform_request(request) return request.response
def pay_server_ip_response(ip_address: str): """ Get a Pay server IP validation :class:`paynlsdk.api.validate.payserverip.Response` instance :param ip_address: IP address :type ip_address: str :return: Response instance :rtype: paynlsdk.api.validate.payserverip.Response """ from paynlsdk.api.validate.payserverip import Request client = APIClient() request = Request(ip_address) client.perform_request(request) return request.response
def info(refund_id: str): """ Return refund info :param refund_id: Refund ID (starts wih "RF-") :type refund_id: str :return: Info Response :rtype: paynlsdk.api.refund.info.Response """ from paynlsdk.api.refund.info import Request client = APIClient() request = Request(refund_id) client.perform_request(request) return request.response
def decline(self) -> bool: """ Decline transaction that needs verification :return: Result of the decline: True is successful :rtype: bool :raise: TransactionStatusException if not current status is not VERIFY """ if not self.is_being_verified(): raise TransactionStatusException('Cannot decline transaction because it does not have the status VERIFY') from paynlsdk.api.transaction.decline import Request from paynlsdk.api.client import APIClient client = APIClient() request = Request(self.transaction_id) client.perform_request(request) return request.response.result
def status_response(transaction_id: str): """ Get a transaction status :class:`paynlsdk.api.transaction.status.Response` instance Please note this will immediately call the API, returning the response instance :param transaction_id: transaction ID :type transaction_id: str :return: Transaction status response instance :rtype: paynlsdk.api.transaction.status.Response """ from paynlsdk.api.transaction.status import Request client = APIClient() request = Request(transaction_id) client.perform_request(request) return request.response
def capture(self) -> bool: """ Capture authorized transaction :return: Result of the capture: True is successful :rtype: bool :raise: TransactionNotAuthorizedException if not yet authorized """ if not self.is_authorized(): raise TransactionNotAuthorizedException('Cannot capture transaction, status is not authorized') # We will NOT use the "utility" methds here but the full API implementation from paynlsdk.api.transaction.capture import Request from paynlsdk.api.client import APIClient client = APIClient() request = Request(self.transaction_id) client.perform_request(request) return request.response.result
def info_response(transaction_id: str, entrance_code: str = None): """ Get a transaction info :class:`paynlsdk.api.transaction.info.Response` instance Please note this will immediately call the API, returning the response instance :param transaction_id: transaction ID :type transaction_id: str :param entrance_code: entrance code :type entrance_code: str :return: Transaction info response instance :rtype: paynlsdk.api.transaction.info.Response """ from paynlsdk.api.transaction.info import Request client = APIClient() request = Request(transaction_id, entrance_code) client.perform_request(request) return request.response
def decline_response(order_id: str, entrance_code: str = None): """ Get a transaction decline :class:`paynlsdk.api.transaction.decline.Response` instance Please note this will immediately call the API, returning the response instance :param order_id: order ID :type order_id: str :param entrance_code: entrance code :type entrance_code: str :return: Transaction decline response instance :rtype: paynlsdk.api.transaction.decline.Response """ from paynlsdk.api.transaction.decline import Request client = APIClient() request = Request(order_id, entrance_code) client.perform_request(request) return request.response
def get_list( payment_method_id: int = None) -> Dict[int, ServicePaymentProfile]: """ Gets the list of payment methods. :param payment_method_id: payment method ID (defaults to 10, or iDeal) :type payment_method_id: int :return: List of banks :rtype: List[ServicePaymentProfile] """ from paynlsdk.api.transaction.getservicepaymentoptions import Request client = APIClient() request = Request() client.perform_request(request) profiles = request.response.payment_profiles if payment_method_id is None: return profiles elif payment_method_id in profiles: return {payment_method_id: profiles[payment_method_id]} raise KeyError( 'Payment methos ID "{}" is not found in the result dictionary'. format(payment_method_id))
def capture_response(transaction_id: str, products: dict = {}, tracktrace: str = None): """ Get a transaction void :class:`paynlsdk.api.transaction.capture.Response` instance Please note this will immediately call the API, returning the response instance :param transaction_id: order ID :type transaction_id: str :param products: entrance code :type products: dict (keys: product id, value: quantity) :param tracktrace: track and trace code Some payment methods require proof of shipment. Provide the Track&Trace code if available/applicable :type tracktrace: str :return: Transaction capture response instance :rtype: paynlsdk.api.transaction.capture.Response """ from paynlsdk.api.transaction.capture import Request client = APIClient() request = Request(transaction_id, products, tracktrace) client.perform_request(request) return request.response