Gift card purchase fails with abnormal "no other attributes are allowed"
Closed this issue · 3 comments
Even if we manually remove the BillingInfo.currency attribute,
when we create a giftcard by passing a gifter's BillingInfo with only a token_id parameter,
we still get the error "no other attributes are allowed when a token is provided", see traces below.
In [7]: gift_card.save()
[2017-11-13 16:41:51,757] DEBUG : recurly.http.request : POST https://api.recurly.com/v2/gift_cards HTTP/1.1
[2017-11-13 16:41:51,757] DEBUG : recurly.http.request : Authorization: <redacted>
[2017-11-13 16:41:51,758] DEBUG : recurly.http.request : Content-Type: application/xml; charset=utf-8
[2017-11-13 16:41:51,758] DEBUG : recurly.http.request : Accept: application/xml
[2017-11-13 16:41:51,758] DEBUG : recurly.http.request : User-Agent: recurly-python/2.6.1; python 3.4.3
[2017-11-13 16:41:51,759] DEBUG : recurly.http.request : X-Api-Version: 2.8
[2017-11-13 16:41:51,759] DEBUG : recurly.http.request :
[2017-11-13 16:41:51,760] DEBUG : recurly.resource : Converting 'account_code' element with type None
[2017-11-13 16:41:51,760] DEBUG : recurly.http.request : b'<gift_card><currency>USD</currency><delivery><email_address>retertefd@ezrtezrt.com</email_address><first_name>ezrtezrtezrt</first_name><gifter_name>tezrt erte</gifter_name><last_name>zert</last_name><method>email</method><personal_message /></delivery><gifter_account><account_code>amorel2@medici.tv</account_code><billing_info><token_id>8hHo3yzh_Yqi0IxmMjUfTg</token_id></billing_info></gifter_account><product_code>essai</product_code><unit_amount_in_cents type="integer">9000</unit_amount_in_cents></gift_card>'
[2017-11-13 16:41:51,761] DEBUG : recurly.resource : Converting 'account_code' element with type None
[2017-11-13 16:41:57,219] DEBUG : recurly.http.response : HTTP/1.1 400 Bad Request
[2017-11-13 16:41:57,219] DEBUG : recurly.http.response : {'X-RateLimit-Remaining': '1985', 'X-RateLimit-Limit': '2000', 'Content-Language': 'en-US', 'X-Api-Version': '2.8', 'X-Request-Id': 'avmo5lc2br844q3muee0', 'Set-Cookie': '__cfduid=d400ce37a95ea018b2bc1b93bec3b19a41510587716; expires=Tue, 13-Nov-18 15:41:56 GMT; path=/; domain=.recurly.com; HttpOnly', 'Content-Type': 'application/xml; charset=utf-8', 'Server': 'cloudflare-nginx', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Mon, 13 Nov 2017 15:41:57 GMT', 'X-RateLimit-Reset': '1510587960', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'CF-RAY': '3bd2d68e580d3c41-CDG', 'Cache-Control': 'no-cache'}
[2017-11-13 16:41:57,219] DEBUG : recurly.http.response :
[2017-11-13 16:41:57,220] DEBUG : recurly.http.response : b'<?xml version="1.0" encoding="UTF-8"?>\n<error>\n <symbol>billing_info_invalid</symbol>\n <description>no other attributes are allowed when a token is provided</description>\n</error>\n'
I'm going to need to dig a little bit deeper on this one, but I think I know a way around this for now. Has the account amorel2@medici.tv
already been created in this case? If so, you do not need to set the billing info with the token. If you are trying to create the account with the gift card, can I ask you to try to create them separately? Example:
account_code = 'amorel2@medici.tv'
# First create account with billing info
account = recurly.Account(account_code=account_code)
account.billing_info = recurly.BillingInfo(token_id='TOKEN_ID')
account.save()
# Now create gift card
gift_card = recurly.GiftCard()
gift_card.product_code = 'test_gift_card'
gift_card.currency = 'USD'
gift_card.unit_amount_in_cents = 2000
gift_card.delivery = recurly.Delivery()
gift_card.delivery.method = 'email'
gift_card.delivery.email_address = 'john@email.com'
gift_card.delivery.first_name = 'John'
gift_card.delivery.last_name = 'Smith'
gift_card.gifter_account = recurly.Account(account_code=account_code)
gift_card.save()
print(gift_card)
My gut is telling me that the server side is setting the currency and you are getting that validation error from that. Going to see if I can reproduce.
Actually, just seeing this may be from a bug that was fixed server side, would you mind trying to reproduce yourself and letting me know?