- raise ValueError("Expecting dict with `orderId` key, got: %s" % response)
- self.order_id = response['orderId']
- self.save()
+ code = response.get('status', {}).get('codeLiteral', '')
+ if code:
+ self.status = 'ERR-' + str(code)
+ self.save()
+ self.status_updated()
+ else:
+ raise ValueError("Expecting dict with `orderId` key, got: %s" % response)
+ else:
+ self.order_id = response['orderId']
+ self.save()