Skip to content

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

Open
antonwestman wants to merge 2 commits intojnbt:masterfrom
fishbrain:add-full-subscription-info-verification
Open

[AppStore, Subscription] Add verification returning both receipt and receipt collection#15
antonwestman wants to merge 2 commits intojnbt:masterfrom
fishbrain:add-full-subscription-info-verification

Conversation

@antonwestman
Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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']
Copy link
Copy Markdown

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
Copy Markdown
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
Copy link
Copy Markdown

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
Copy Markdown
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.


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

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
Copy Markdown
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.

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

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
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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