|
20 | 20 | token = '2977e78d1e3e4c9fa6b70'
|
21 | 21 |
|
22 | 22 | auth = ecommerce.authorization(card, amount, token=token)
|
| 23 | +if not auth: |
| 24 | + print('Fallo al realizar el pago, Error al conectar con el servicio') |
23 | 25 |
|
24 |
| -if auth.code != 0: |
| 26 | +elif auth.code != 0: |
25 | 27 | print('Fallo al realizar el pago, Error: {}'.format(auth.description))
|
26 | 28 |
|
27 | 29 | else:
|
|
36 | 38 |
|
37 | 39 | auth2 = ecommerce.authorization(card, amount)
|
38 | 40 |
|
39 |
| -if auth2.code != 0: |
| 41 | +if not auth2: |
| 42 | + print('Fallo al realizar el pago, Error al conectar con el servicio') |
| 43 | + |
| 44 | +elif auth2.code != 0: |
40 | 45 | print('Fallo al realizar el pago, Error: {}'.format(auth2.description))
|
41 | 46 |
|
42 | 47 | else:
|
|
49 | 54 |
|
50 | 55 | auth3 = ecommerce.authorization(card, amount)
|
51 | 56 |
|
52 |
| -if auth3.code != 0: |
| 57 | +if not auth3: |
| 58 | + print('Fallo al realizar el pago, Error al conectar con el servicio') |
| 59 | + |
| 60 | +elif auth3.code != 0: |
53 | 61 | print('Fallo al realizar el pago, Error: {}'.format(auth3.description))
|
54 | 62 |
|
55 | 63 | else:
|
56 | 64 | print('Pago procesado correctamente')
|
57 | 65 |
|
58 | 66 | # cancelar el pago con tarjeta (auth)
|
59 | 67 | cancel = ecommerce.cancellation(auth.transaction_id)
|
60 |
| -if cancel.code != 0: |
| 68 | +if not cancel: |
| 69 | + print('Fallo al cancelar el pago, Error al conectar con el servicio') |
| 70 | + |
| 71 | +elif cancel.code != 0: |
61 | 72 | print('Fallo al cancelar el pago, Error: {}'.format(cancel.description))
|
62 | 73 |
|
63 | 74 | else:
|
|
67 | 78 | amount = Amount(834, 'EUR')
|
68 | 79 |
|
69 | 80 | refund = ecommerce.refund(auth2.transaction_id, amount)
|
70 |
| -if refund.code != 0: |
| 81 | +if not refund: |
| 82 | + print('Fallo al hacer la devolución, Error al conectar con el servicio') |
| 83 | + |
| 84 | +elif refund.code != 0: |
71 | 85 | print('Fallo al hacer la devolución, Error: {}'.format(refund.description))
|
72 | 86 |
|
73 | 87 | else:
|
|
81 | 95 |
|
82 | 96 | refund2 = ecommerce.refund(card, amount)
|
83 | 97 |
|
84 |
| -if refund2.code != 0: |
| 98 | +if not refund2: |
| 99 | + print('Fallo al hacer la devolución, Error al conectar con el servicio') |
| 100 | + |
| 101 | +elif refund2.code != 0: |
85 | 102 | print('Fallo al hacer la devolución, Error: {}'.format(refund2.description))
|
86 | 103 |
|
87 | 104 | else:
|
|
93 | 110 |
|
94 | 111 | register = ecommerce.register(card, 'newtoken')
|
95 | 112 |
|
96 |
| -if register.code != 0: |
| 113 | +if not register: |
| 114 | + print('Fallo al registrar la tarjeta, Error al conectar con el servicio') |
| 115 | + |
| 116 | +elif register.code != 0: |
97 | 117 | print('Fallo al registrar la tarjeta, Error: {}'.format(register.description))
|
98 | 118 |
|
99 | 119 | else:
|
|
104 | 124 | # Borrar tarjeta de Sipay
|
105 | 125 | unregister = ecommerce.unregister('newtoken')
|
106 | 126 |
|
107 |
| -if unregister.code != 0: |
| 127 | +if not unregister: |
| 128 | + print('Fallo al borrar la tarjeta de Sipay, Error al conectar con el servicio') |
| 129 | + |
| 130 | +elif unregister.code != 0: |
108 | 131 | print('Fallo al borrar la tarjeta de Sipay, Error: {}'.format(unregister.description))
|
109 | 132 |
|
110 | 133 | else:
|
|
0 commit comments