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, Subscription] Add verification returning both receipt and receipt collection #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

[AppStore, Subscription] Add verification returning both receipt and receipt collection #15

wants to merge 2 commits into from

Conversation

antonwestman
Copy link

@antonwestman antonwestman commented Jun 1, 2017

This PR adds two new objects FullSubscriptionVerification and SubscriptionReceipt as well as a new method CandyCheck::AppStore::Verifier#verify_subscription_with_full_response.

The SubscriptionReceipt consist of a Receipt and a ReceiptCollection.

I also added the undocumented response code 21009.

@coveralls
Copy link

coveralls commented Jun 1, 2017

Coverage Status

Coverage decreased (-0.4%) to 98.102% when pulling 1eee57e on fishbrain:add-full-subscription-info-verification into a61a689 on jnbt:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.102% when pulling 1eee57e on fishbrain:add-full-subscription-info-verification into a61a689 on jnbt:master.

@coveralls
Copy link

coveralls commented Jun 1, 2017

Coverage Status

Coverage decreased (-0.4%) to 98.102% when pulling 4a161f2 on fishbrain:add-full-subscription-info-verification into a61a689 on jnbt:master.

Please Rubocop 👮🏻

Bump Rubocop 👮🏻

Fix rubocop issues

Bump version to 0.1.0.pre

Add information about PlayStore configto README

Refs #12

Unify code style

Add failing test for expired check

Base expired? check based on time comparison

Satisfy recent rubocop suggestions

Update dev Ruby version to 2.4.1

Test more Ruby versions on Travis CI

Update dev dependencies

Fix Travis JRuby modes for JRuby 1.7

Use JRuby 1.7.26 on Travis

Drop rubinius test on Travis

Bump version to 0.1.1

Fix some merge conflicts

Add information about PlayStore configto README
def valid?
@response && @response['status'] == STATUS_OK && @response['receipt']
@response && response_status_ok? && @response['receipt']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit like response_status_ok? is not self-contained if you have to check @response before you use it. Maybe it would be nicer with two black boxes: response_status_ok? and response_has_receipt? which both take care of validating all that they need. This would mean duplicating the @response check, but I think that's acceptable, or if the response is only set once, then you could even cache/memoize this in a has_response? method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it 👍

# @return [SubscriptionReceipt] if successful
# @return [VerificationFailure] otherwise
def verify_subscription_with_full_response(receipt_data, secret = nil)
@verifier = FullSubscriptionVerification

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's weird to have @verifier as instance state. It introduces coupling in the order of invocation of the public methods here, which can cause race conditions if run in parallel.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. However I would like to keep it consistent with the rest of the code.

@@ -25,17 +27,18 @@ def initialize(attributes)

# Check if the expiration date is passed
# @return [bool]
# rubocop:disable Style/NumericPredicate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use .positive? ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported in older versions.

@@ -26,7 +28,7 @@

it 'has positive overdue days' do
overdue = subject.overdue_days
overdue.must_be_instance_of Fixnum
overdue.is_a?(Integer).must_be_true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we shouldn't care this much about types anyway. Maybe asserting that it is .positive? should suffice?

Copy link

@beatmadsen beatmadsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Just a few comments.

@jnbt
Copy link
Owner

jnbt commented Jun 8, 2017

@antonwestman thanks for your work. I'm currently in a situation where I cannot work on this project for a couple of weeks. I'm very sorry for this, but my family goes first.
I'll check this PR as soon as possible.
Are you able to test this against the sandbox environment?

@antonwestman
Copy link
Author

Good priorities @jnbt. Family should always come first. 👍

We have tested against the sandbox environment with positive results.

I'm looking forward to your response. 🖖🏻

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

Successfully merging this pull request may close these issues.

4 participants