Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dotpot/InAppPy
Browse files Browse the repository at this point in the history
  • Loading branch information
dotpot committed Aug 18, 2019
2 parents 0c8f3c6 + f4b5790 commit 563b7a4
Show file tree
Hide file tree
Showing 20 changed files with 519 additions and 36 deletions.
10 changes: 5 additions & 5 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[flake8]
jobs = 16
jobs = 4
exclude = build,dist,.tox,.pytest_cache,__pycache__
inline-quotes = double
max-line-length = 120

max-complexity = 6

application-import-names = app,helpers,tests
max-complexity = 8
ignore = D1,C812,C814
application-import-names = inappy,helpers,tests
import-order-style = pycharm
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

<!--- Provide a general summary of the issue in the Title above -->

## Description
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->

## Expected Behavior
<!--- Tell us what should happen -->

## Actual Behavior
<!--- Tell us what happens instead -->

## Possible Fix
<!--- Not obligatory, but suggest a fix or reason for the bug -->

## Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- How has this bug affected you? What were you trying to accomplish? -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used:
* Operating System and version:
* Link to your project (if it's open source):
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: feature
assignees: ''

---

<!--- Provide a general summary of the issue in the Title above -->

## Detailed Description
<!--- Provide a detailed description of the change or addition you are proposing -->

## Context
<!--- Why is this change important to you? How would you use it? -->
<!--- How can it benefit other users? -->

## Possible Implementation
<!--- Not obligatory, but suggest an idea for implementing addition or change -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used:
* Operating System and version:
* Link to your project (if it's open source):
20 changes: 20 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=120
skip_glob=
.git,
.idea,
.tox,
.pytest_cache,
.venv,
.vscode
build
dist
*.egg-info,
migrations,
static,
docs,
node_modules
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at dotpot@tutanota.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ test:
black:
pipenv run black --config black.toml .

isort:
pipenv run isort --recursive --atomic .

lint:
pipenv run flake8

Expand Down
33 changes: 33 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Related Issue
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
6 changes: 6 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pytest-asyncio = "*"
pytest-sugar = "*"
pytest-cov = "*"
black = "*"
flake8-builtins = "*"
flake8-commas = "*"
flake8-eradicate = "*"
flake8-quotes = "*"
flake8-super-call = "*"
isort = "*"

[requires]
python_version = "3.6"
Expand Down
52 changes: 44 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ Table of contents
2. Installation
3. Google Play (`receipt` + `signature`)
4. Google Play (verification)
5. App Store (`receipt` + using optional `shared-secret`)
6. App Store Response (`validation_result` / `raw_response`) example
7. App Store, **asyncio** version (available in the inapppy.asyncio package)
8. Development
5. Google Play (verification with result)
6. App Store (`receipt` + using optional `shared-secret`)
7. App Store Response (`validation_result` / `raw_response`) example
8. App Store, **asyncio** version (available in the inapppy.asyncio package)
9. Development


1. Introduction
Expand Down Expand Up @@ -88,7 +89,42 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S
return response
5. App Store (validates `receipt` using optional `shared-secret` against iTunes service)
5. Google Play verification (with result)
=========================================
Alternative to `.verify` method, instead of raising an error result class will be returned.

.. code:: python
from inapppy import GooglePlayVerifier, errors
def google_validator(receipt):
"""
Accepts receipt, validates in Google.
"""
purchase_token = receipt['purchaseToken']
product_sku = receipt['productId']
verifier = GooglePlayVerifier(
GOOGLE_BUNDLE_ID,
GOOGLE_SERVICE_ACCOUNT_KEY_FILE,
)
response = {'valid': False, 'transactions': []}
result = verifier.verify_with_result(
purchase_token,
product_sku,
is_subscription=True
)
# result contains data
raw_response = result.raw_response
is_canceled = result.is_canceled
is_expired = result.is_expired
return result
6. App Store (validates `receipt` using optional `shared-secret` against iTunes service)
========================================================================================
.. code:: python
Expand All @@ -110,7 +146,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S
6. App Store Response (`validation_result` / `raw_response`) example
7. App Store Response (`validation_result` / `raw_response`) example
====================================================================
.. code:: json
Expand Down Expand Up @@ -190,7 +226,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S
}
7. App Store, asyncio version (available in the inapppy.asyncio package)
8. App Store, asyncio version (available in the inapppy.asyncio package)
========================================================================
.. code:: python
Expand All @@ -213,7 +249,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S
8. Development
9. Development
==============

.. code:: bash
Expand Down
2 changes: 1 addition & 1 deletion inapppy/asyncio/appstore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from aiohttp import ClientSession, ClientError, ClientTimeout
from aiohttp import ClientError, ClientSession, ClientTimeout

from ..appstore import AppStoreValidator, api_result_errors, api_result_ok
from ..errors import InAppPyValidationError
Expand Down
16 changes: 12 additions & 4 deletions inapppy/errors.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
class InAppPyValidationError(BaseException):
class InAppPyValidationError(Exception):
""" Base class for all validation errors """

raw_response = None
message = None

def __init__(self, message: str = None, raw_response: dict = None, *args, **kwargs):
self.raw_response = raw_response
super().__init__(message, raw_response, *args, **kwargs)
self.message = message

super().__init__(message, *args, **kwargs)

def __str__(self):
return f"{self.__class__.__name__} {self.message} {self.raw_response}"

def __repr__(self):
return f"{self.__class__.__name__}(message={self.message!r}, raw_response={self.raw_response!r})"


class GoogleError(InAppPyValidationError):
def __init__(self, message, raw_response, *args, **kwargs):
super().__init__(message, raw_response, *args, **kwargs)
pass

0 comments on commit 563b7a4

Please sign in to comment.