def auth_capture(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.AUTH_CAPTURE _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation outAuthInfoNo = body.get('outAuthInfoNo') authInfoNo = body.get('authInfoNo') if (outAuthInfoNo and authInfoNo and (body['outAuthInfoNo'] and body['authInfoNo']) is None) or ( not outAuthInfoNo and not authInfoNo): raise InvalidParamsError( "outAuthInfoNo and authInfoNo cannot be null at the same time") if outAuthInfoNo and authInfoNo and (body['outAuthInfoNo'] and body['authInfoNo']) is not None: raise InvalidParamsError( "outAuthInfoNo and authInfoNo cannot exist at the same time") requiredFileds = [ 'currency', 'settleCurrency', 'outAuthDetailNo', 'reference' ] self.validate_parameter(requiredFileds, body) self.amount_validate('amount', body['amount']) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def express_pay(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.EXPRESS_PAY _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation requiredFileds = [ 'cardNumber', 'cardExpYear', 'cardExpMonth', 'cardCvv', 'currency', 'settleCurrency', 'reference', 'clientIp' ] self.validate_parameter(requiredFileds, body) self.number_validate('cardNumber', body['cardNumber']) self.number_validate('cardExpYear', body['cardExpYear']) self.number_validate('cardExpMonth', body['cardExpMonth']) self.number_validate('cardCvv', body['cardCvv']) self.amount_validate('amount', body['amount']) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def reverse(self, body): """POST Request to reverse transaction Reverse Yuansfer transaction Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.REVERSE _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation transcationNo = body.get('transactionNo') reference = body.get('reference') if (transcationNo and reference and (body['transactionNo'] and body['reference']) is None) or ( not transcationNo and not reference): raise InvalidParamsError( "transaction and reference cannot be null at the same time") if transcationNo and reference and (body['transactionNo'] and body['reference']) is not None: raise InvalidParamsError( "transaction and reference cannot exist at the same time") # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def mobile_prepay(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.MOBILE_PREPAY _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation self.amount_validate('amount', body['amount']) requiredFileds = [ 'reference', 'currency', 'settleCurrency', 'vendor', 'terminal' ] self.validate_parameter(requiredFileds, body) if body['vendor'] == 'wechatpay': if body['terminal'] == 'MINIPROGRAM' and body['openid'] is None: raise RequireParamsError('openid') # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def secure_pay(self, body): """POST Request to SecurePay Creates a payment for selected vendor. Use this end points for various payment methods Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.ONLINE_SECURE_PAY _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation self.amount_validate('amount', body['amount']) requiredFileds = [ 'currency', 'settleCurrency', 'vendor', 'ipnUrl', 'callbackUrl', 'terminal', 'reference' ] self.validate_parameter(requiredFileds, body) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def create_account(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.PAYOUT_CREATE_ACCOUNT _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation requiredFileds = [ 'accountType', 'email', 'firstName', 'lastName', 'countryCode', 'dateOfBirth', 'street', 'city', 'state', 'zip' ] self.validate_parameter(requiredFileds, body) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def consult(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.RECURRING_CONSULT _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation requiredFileds = [ 'osType', 'osVersion', 'autoRedirectUrl', 'autoReference', 'vendor', 'terminal' ] self.validate_parameter(requiredFileds, body) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def process(self, body): """POST Request to Process Process a payment for Braintree. Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.ONLINE_PROCESS _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation requiredFileds = [ 'paymentMethod', 'paymentMethodNonce', 'transactionNo' ] self.validate_parameter(requiredFileds, body) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def auth_voucher_create(self, body): """POST Request Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.AUTH_VOUCHER_CREATE _query_builder = self.config.get_base_uri() _query_url = _query_builder + _url_path # Parameters validation requiredFileds = ['outAuthInfoNo', 'outAuthDetailNo', 'vendor'] self.validate_parameter(requiredFileds, body) self.amount_validate('amount', body['amount']) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def update_recurring(self, body): """POST Request to UpdateRecurring payment Process a UpdateRecurring payment . Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.UPDATE_RECURRING _query_builder = self.config.get_base_uri() _query_url = _query_builder+_url_path # Parameters validation requiredFileds = ['paymentCount','status'] self.validate_parameter(requiredFileds,body) if requiredFileds['paymentCount'] <= 0: raise InvalidParamsError('paymentCount should be greater than 0') # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result
def instore_create_tran_qrcode(self, body): """POST Request to InstoreCreateTranQRCode Create Yuansfer transaction and generate qr code Args: body: An object containing the fields to POST for the request. See the corresponding object definition for field details. Returns: ApiResponse: An object with the response value as well as other useful information such as status codes and headers. Success Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = constant.INSTORE_TRAN_QRCODE _query_builder = self.config.get_base_uri() _query_url = _query_builder+_url_path # Parameters validation self.amount_validate('amount',body['amount']) requiredFileds = ['currency','settleCurrency','reference'] self.validate_parameter(requiredFileds,body) # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=None, parameters=body) _response = self.execute_request(_request) if type(_response.response) is not dict: _errors = _response.reason else: _errors = None _result = ApiResponse(_response, body=_response.response, errors=_errors) return _result