pymill
pymill copied to clipboard
Parsing of preauthorization returns transaction instead of preauthorization data
I've been trying to do a preauthorization for a payment. The preauthorization goes through and the response comes back correctly. However, the Paymill API does not return the preauthorization as the top-level object, but a transaction instead. So the call to p.preauthorize does return a Transaction object that is filled with the details of the transaction instead of the preauthorization.
This causes further payment against the preauthorization to fail.
Have a look at the following session for a clearer example:
>>> private_key = '84987a01b958ab5b750fe34013f3f171'
>>> token = '098f6bcd4621d373cade4e832627b4f6'
>>> p = pymill.Pymill(private_key)
>>> preauth = p.preauthorize(
... amount=100,
... currency="EUR",
... description="example pre-auth",
... token=token
... )
>>> print preauth
tran_351dde91c67338bd39a650a2aaff
>>> pprint(preauth.preauthorization)
{u'amount': u'100',
u'app_id': None,
u'client': {u'app_id': None,
u'created_at': 1379352485,
u'description': None,
u'email': None,
u'id': u'client_cb56cffde673004842ca',
u'payment': [],
u'subscription': None,
u'updated_at': 1379352485},
u'created_at': 1379352485,
u'currency': u'EUR',
u'id': u'preauth_7cb8754344991259b052',
u'livemode': False,
u'payment': {u'app_id': None,
u'card_holder': u'',
u'card_type': u'visa',
u'client': u'client_cb56cffde673004842ca',
u'country': None,
u'created_at': 1379352485,
u'expire_month': u'12',
u'expire_year': u'2014',
u'id': u'pay_e837057aee2982291f6d1043',
u'last4': u'1111',
u'type': u'creditcard',
u'updated_at': 1379352485},
u'status': u'closed',
u'updated_at': 1379352485}