Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appstore.py:validate() fails on line 37 with sandbox receipts, throws KeyError exception #13

Open
Vidder opened this issue May 18, 2018 · 6 comments

Comments

@Vidder
Copy link

Vidder commented May 18, 2018

The KeyError exception is possibly because there is no key called "response" in the response from Apple servers.

def validate(self, receipt, password=None):
    receipt_json = {'receipt-data': receipt}
    if password:
        receipt_json['password'] = password
    api_response = requests.post(self.url, json=receipt_json).json()
    **status = api_response['response']['status']** ...
    if status != api_result_ok:
        error = AppValidationError(api_result_errors.get(status, 'Unknown API status'), api_response)
        raise error
    response = api_response['response']

Line 43 with similar access might also be problematic.

@nnsnodnb
Copy link
Owner

@Vidder
Which did you check with "non-consumption", "consumption" or "subscription"?

@Vidder
Copy link
Author

Vidder commented May 24, 2018

it was a non-consumable subscription.

@Vidder
Copy link
Author

Vidder commented May 28, 2018

You may have reviewed this already but just in case https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW4

nnsnodnb added a commit that referenced this issue Jun 5, 2018
nnsnodnb added a commit that referenced this issue Jun 5, 2018
nnsnodnb added a commit that referenced this issue Jun 5, 2018
nnsnodnb added a commit that referenced this issue Jun 5, 2018
nnsnodnb added a commit that referenced this issue Jun 5, 2018
@nnsnodnb
Copy link
Owner

nnsnodnb commented Jun 5, 2018

@Vidder
I'm sorry for the delay in correspondence. I released 1.0.3 .
Please update to new version django-ios-storekit with your using package manager.

@Vidder
Copy link
Author

Vidder commented Jun 6, 2018

Thank you. I will test this out.

@Vidder
Copy link
Author

Vidder commented Jun 8, 2018

Now it throws the following: Exception Type: DataError at URL
Exception Value: (1264, "Out of range value for column 'transaction_id' at row 1")

For what it is worth, this may be because the storekit_inapp table defines transaction_id as int(11). However, the response seems to have a 16-digit transaction id.

Locals on stack are as follows:

cls | <class 'storekit.models.InApp'>

in_app | {'is_trial_period': False, 'original_purchase_date': '2018-05-17 21:49:29 Etc/GMT', 'original_purchase_date_ms': 1526593769000, 'original_purchase_date_pst': '2018-05-17 14:49:29 America/Los_Angeles', 'original_transaction_id': 1000000399635972, 'product_id': 'someproduct', 'purchase_date': '2018-05-17 21:49:27 Etc/GMT', 'purchase_date_ms': 1526593767000, 'purchase_date_pst': '2018-05-17 14:49:27 America/Los_Angeles', 'quantity': 1, 'transaction_id': 1000000399635972}
is_save | True
json | {'expires_date': '2018-05-17 21:54:27 Etc/GMT', 'expires_date_ms': '1526594067000', 'expires_date_pst': '2018-05-17 14:54:27 America/Los_Angeles', 'is_in_intro_offer_period': 'false', 'is_trial_period': 'false', 'original_purchase_date': '2018-05-17 21:49:29 Etc/GMT', 'original_purchase_date_ms': '1526593769000', 'original_purchase_date_pst': '2018-05-17 14:49:29 America/Los_Angeles', 'original_transaction_id': '1000000399635972', 'product_id': 'someproductid', 'purchase_date': '2018-05-17 21:49:27 Etc/GMT', 'purchase_date_ms': '1526593767000', 'purchase_date_pst': '2018-05-17 14:49:27 America/Los_Angeles', 'quantity': '1', 'transaction_id': '1000000399635972', 'web_order_line_item_id': '1000000033322585'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants