def create(cls, buy_order: str, session_id: str, return_url: str, details: MallTransactionCreateDetails, options: Options = None) -> MallTransactionCreateResponse: options = cls.build_options(options) endpoint = cls.__base_url(options.integration_type) request = MallTransactionCreateRequest(buy_order, session_id, return_url, details.details) response = requests.post( endpoint, data=MallTransactionCreateRequestSchema().dumps(request).data, headers=HeadersBuilder().build(options)) json_response = response.text dict_response = MallTransactionCreateResponseSchema().loads( json_response).data if response.status_code not in range(200, 299): raise TransactionCreateError( message=dict_response["error_message"], code=response.status_code) return MallTransactionCreateResponse(**dict_response)
def create(self, buy_order: str, session_id: str, amount: float, cvv: str, card_number: str, card_expiration_date: str): ValidationUtil.has_text_with_max_length(buy_order, ApiConstants.BUY_ORDER_LENGTH, "buy_order") ValidationUtil.has_text_with_max_length(session_id, ApiConstants.SESSION_ID_LENGTH, "session_id") ValidationUtil.has_text_with_max_length( card_number, ApiConstants.CARD_NUMBER_LENGTH, "card_number") ValidationUtil.has_text_with_max_length( card_expiration_date, ApiConstants.CARD_EXPIRATION_DATE_LENGTH, "card_expiration_date") try: endpoint = Transaction.CREATE_ENDPOINT request = TransactionCreateRequest(buy_order, session_id, amount, card_number, cvv, card_expiration_date) return RequestService.post( endpoint, TransactionCreateRequestSchema().dumps(request).data, self.options) except TransbankError as e: raise TransactionCreateError(e.message, e.code)
def create(self, buy_order: str, session_id: str, amount: float, return_url: str, service_id: str, card_holder_id: str, card_holder_name: str, card_holder_last_name1: str, card_holder_last_name2: str, card_holder_mail: str, cellphone_number: str, expiration_date: str, commerce_mail: str, uf_flag: bool): ValidationUtil.has_text_with_max_length(buy_order, ApiConstants.BUY_ORDER_LENGTH, "buy_order") ValidationUtil.has_text_with_max_length(session_id, ApiConstants.SESSION_ID_LENGTH, "session_id") ValidationUtil.has_text_with_max_length(return_url, ApiConstants.RETURN_URL_LENGTH, "return_url") try: endpoint = Transaction.CREATE_ENDPOINT request = TransactionCreateRequest( buy_order, session_id, amount, return_url, service_id, card_holder_id, card_holder_name, card_holder_last_name1, card_holder_last_name2, card_holder_mail, cellphone_number, expiration_date, commerce_mail, uf_flag) return RequestService.post( endpoint, TransactionCreateRequestSchema().dumps(request).data, self.options) except TransbankError as e: raise TransactionCreateError(e.message, e.code)
def create(self, buy_order: str, session_id: str, return_url: str, details: MallTransactionCreateDetails): ValidationUtil.has_text_with_max_length(buy_order, ApiConstants.BUY_ORDER_LENGTH, "buy_order") ValidationUtil.has_text_with_max_length(session_id, ApiConstants.SESSION_ID_LENGTH, "session_id") ValidationUtil.has_text_with_max_length(return_url, ApiConstants.RETURN_URL_LENGTH, "return_url") ValidationUtil.has_elements(details.details, "details") for item in details.details: ValidationUtil.has_text_with_max_length( item.commerce_code, ApiConstants.COMMERCE_CODE_LENGTH, "details.commerce_code") ValidationUtil.has_text_with_max_length( item.buy_order, ApiConstants.BUY_ORDER_LENGTH, "details.buy_order") try: endpoint = MallTransaction.CREATE_ENDPOINT request = MallTransactionCreateRequest(buy_order, session_id, return_url, details.details) return RequestService.post( endpoint, MallTransactionCreateRequestSchema().dumps(request).data, self.options) except TransbankError as e: raise TransactionCreateError(e.message, e.code)
def create(cls, buy_order: str, session_id: str, amount: float, return_url: str, options: Options = None) \ -> TransactionCreateResponse: options = cls.build_options(options) endpoint = cls.__base_url(options.integration_type) request = TransactionCreateRequest(buy_order, session_id, amount, return_url) response = requests.post( endpoint, data=TransactionCreateRequestSchema().dumps(request).data, headers=HeadersBuilder.build(options)) json_response = response.text dict_response = TransactionCreateResponseSchema().loads( json_response).data if response.status_code not in (200, 299): raise TransactionCreateError( message=dict_response["error_message"], code=response.status_code) return TransactionCreateResponse(**dict_response)
def create(self, buy_order: str, session_id: str, amount: float, return_url: str): ValidationUtil.has_text_with_max_length(buy_order, ApiConstants.BUY_ORDER_LENGTH, "buy_order") ValidationUtil.has_text_with_max_length(session_id, ApiConstants.SESSION_ID_LENGTH, "session_id") ValidationUtil.has_text_with_max_length(return_url, ApiConstants.RETURN_URL_LENGTH, "return_url") try: endpoint = Transaction.CREATE_ENDPOINT request = TransactionCreateRequest(buy_order, session_id, amount, return_url) return RequestService.post( endpoint, TransactionCreateRequestSchema().dumps(request).data, self.options) except TransbankError as e: raise TransactionCreateError(e.message, e.code)
def create(cls, buy_order: str, session_id: str, card_number: str, card_expiration_date: str, details: list, options: Options = None) -> TransactionCreateResponse: options = cls.build_options(options) endpoint = cls.__base_url(options.integration_type) request = TransactionCreateRequest(buy_order, session_id, card_number, card_expiration_date, details) response = requests.post( endpoint, data=CreateTransactionRequestSchema().dumps(request).data, headers=HeadersBuilder.build(options)) response_json = response.text response_dict = CreateTransactionResponseSchema().loads( response_json).data if response.status_code in range(200, 299): return TransactionCreateResponse(**response_dict) raise TransactionCreateError(message=response_dict["error_message"])
def create(self, buy_order: str, session_id: str, card_number: str, card_expiration_date: str, details: list, cvv: str = None): ValidationUtil.has_text_with_max_length(buy_order, ApiConstants.BUY_ORDER_LENGTH, "buy_order") ValidationUtil.has_text_with_max_length(session_id, ApiConstants.SESSION_ID_LENGTH, "session_id") ValidationUtil.has_text_with_max_length( card_number, ApiConstants.CARD_NUMBER_LENGTH, "card_number") ValidationUtil.has_text_with_max_length( card_expiration_date, ApiConstants.CARD_EXPIRATION_DATE_LENGTH, "card_expiration_date") ValidationUtil.has_elements(details, "details") for item in details: ValidationUtil.has_text_with_max_length( item['commerce_code'], ApiConstants.COMMERCE_CODE_LENGTH, "details.commerce_code") ValidationUtil.has_text_with_max_length( item['buy_order'], ApiConstants.BUY_ORDER_LENGTH, "details.buy_order") try: endpoint = MallTransaction.CREATE_ENDPOINT request = TransactionCreateRequest(buy_order, session_id, card_number, card_expiration_date, details, cvv) return RequestService.post( endpoint, TransactionCreateRequestSchema().dumps(request).data, self.options) except TransbankError as e: raise TransactionCreateError(e.message, e.code)
def create(cls, buy_order: str, session_id: str, amount: float, return_url: str, service_id: str, card_holder_id: str, card_holder_name: str, card_holder_last_name1: str, card_holder_last_name2: str, card_holder_mail: str, cellphone_number: str, expiration_date: str, commerce_mail: str, uf_flag: bool, options: Options = None) -> TransactionCreateResponse: options = cls.build_options(options) endpoint = cls.__base_url(options.integration_type) request = TransactionCreateRequest( buy_order, session_id, amount, return_url, service_id, card_holder_id, card_holder_name, card_holder_last_name1, card_holder_last_name2, card_holder_mail, cellphone_number, expiration_date, commerce_mail, uf_flag) response = requests.post( endpoint, data=TransactionCreateRequestSchema().dumps(request).data, headers=HeadersBuilder.build(options)) json_response = response.text dict_response = TransactionCreateResponseSchema().loads( json_response).data if response.status_code not in range(200, 299): raise TransactionCreateError( message=dict_response["error_message"], code=response.status_code) return TransactionCreateResponse(**dict_response)