def test_init_amount(self): with self.assertRaises(TypeError): self.amount5 = Amount('300.00', 'USD', '#', '.') with self.assertRaises(TypeError): self.amount5 = Amount('300.00', 'USD', '.', '$') with self.assertRaises(TypeError): self.amount5 = Amount('300.00', 'USD', '.', '.') with self.assertRaises(ValueError): self.amount5 = Amount('300.00', 'UK', ',', '.')
def __init__(self, request, response): """Initialize.""" super().__init__(request, response) payload = response['payload'] self.order = payload.get('order') self.reconciliation = payload.get('reconciliation') self.transaction_id = payload.get('transaction_id') if payload.get('amount') and payload.get('currency'): self.amount = Amount(payload['amount'], payload['currency']) else: self.amount = None
def __init__(self, request, response): """Initialize.""" super().__init__(request, response) payload = response['payload'] self.approval = payload.get('approval') self.authorizator = payload.get('authorizator') self.card_trade = payload.get('card_trade') self.card_type = payload.get('card_type') self.masked_card = payload.get('masked_card') self.order = payload.get('order') self.reconciliation = payload.get('reconciliation') self.transaction_id = payload.get('transaction_id') if payload.get('amount') and payload.get('currency'): self.amount = Amount(payload['amount'], payload['currency']) else: self.amount = None
def __init__(self, data): """Initialize.""" self.channel_name = data['channel_name'] self.channel = data['channel'] self.method = data['method'] self.date = datetime.strptime(data['date'] + data['time'], '%Y-%m-%d%H:%M:%S') self.order = data['order'] self.transaction_id = data['transaction_id'] self.internal_code = data['code'] self.method_name = data['method_name'] self.operation = data['operation'] self.amount = Amount(int(data['amount']), data['currency']) self.authorization_id = data['authorization_id'] self.description = data['description'] self.masked_card = data['masked_card'] self.operation_name = data['operation_name'] self.status = data['status']
from sipay.paymethod.card import Card from sipay.paymethod.storedcard import StoredCard from sipay.paymethod.fastpay import FastPay from sipay.amount import Amount from pathlib import Path parent = str(Path(__file__).parent.resolve().parent) config_file = '{}/etc/config.ini'.format(parent) ecommerce = Ecommerce(config_file) # pago de un Euro con tarjeta y almacenar en Sipay con un token pan_example = '4242424242424242' amount = Amount(100, 'EUR') card = Card(pan_example, 2050, 2) token = '2977e78d1e3e4c9fa6b70' auth = ecommerce.authorization(card, amount, token=token) if not auth: print('Fallo al realizar el pago, Error al conectar con el servicio') elif auth.code != 0: print('Fallo al realizar el pago, Error: {}'.format(auth.description)) else: print('Pago procesado correctamente') # pago de 4.56 euros con tarjeta ya almacenada en Sipay
def setUp(self): self.amount1 = Amount(100, 'EUR') self.amount3 = Amount(100, 'EUR') self.amount2 = Amount(200, 'EUR') self.amount4 = Amount(300, 'TRY')