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

Add ability to store payment source #4195

Merged
merged 81 commits into from
Jul 11, 2019
Merged

Conversation

salwator
Copy link
Contributor

@salwator salwator commented May 31, 2019

Adds ability to store credit card information on payment.

Closes #2700

This PR introduces:

  • new private meta field for user to store external data, ex. gateway information
  • new interface for extending parameters for client token generation, ex. braintree token for existing customer
  • new flag in CheckoutComplete mutation to rerquest saving user payment source in gateway (needs to be enabled in gateway settings too)
  • new flow for charging existing customer instead of one-time-token each time, implemented in Braintree gateway
  • improvement in testing, most sensitive tests in braintree gateway test suite are now gone and replaced with VCR-based containing real life sandbox communication
  • new gateway method for retrieving customer stored payment sources (credit cards)
  • fixes bug with billing and shipping addresses causing call_gateway to fail

Pull Request Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. Database migration files are up to date.
  6. The changes are tested.
  7. The code is documented (docstrings, project documentation).
  8. GraphQL schema and type definitions are up to date.
  9. Changes are mentioned in the changelog.

@salwator salwator added in progress payments Issues related to payments implementation labels May 31, 2019
@NyanKiyoshi
Copy link
Member

Closes #2700?

@codecov
Copy link

codecov bot commented Jun 17, 2019

Codecov Report

Merging #4195 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4195      +/-   ##
==========================================
+ Coverage   91.77%   91.77%   +<.01%     
==========================================
  Files         278      278              
  Lines       15548    15552       +4     
  Branches     1513     1513              
==========================================
+ Hits        14269    14273       +4     
  Misses        879      879              
  Partials      400      400
Impacted Files Coverage Δ
saleor/account/models.py 93.7% <100%> (+0.04%) ⬆️
saleor/payment/interface.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb6813c...41051fc. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 17, 2019

Codecov Report

Merging #4195 into master will increase coverage by 0.01%.
The diff coverage is 93.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4195      +/-   ##
==========================================
+ Coverage    90.7%   90.72%   +0.01%     
==========================================
  Files         291      291              
  Lines       16680    16792     +112     
  Branches     1691     1708      +17     
==========================================
+ Hits        15130    15234     +104     
- Misses       1054     1058       +4     
- Partials      496      500       +4
Impacted Files Coverage Δ
saleor/graphql/account/resolvers.py 95% <100%> (+1.66%) ⬆️
saleor/payment/models.py 94.89% <100%> (+0.05%) ⬆️
saleor/graphql/account/types.py 96.22% <100%> (+0.14%) ⬆️
saleor/payment/interface.py 100% <100%> (ø) ⬆️
saleor/graphql/payment/types.py 85.22% <100%> (+0.88%) ⬆️
saleor/graphql/payment/resolvers.py 100% <100%> (ø) ⬆️
saleor/graphql/payment/schema.py 100% <100%> (ø) ⬆️
saleor/graphql/checkout/mutations.py 94.06% <71.42%> (-0.56%) ⬇️
saleor/account/models.py 93.23% <85.71%> (-0.42%) ⬇️
saleor/payment/utils.py 90.47% <86.36%> (-0.61%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d528263...ad32191. Read the comment docs.

Copy link

django-queries commented Jun 17, 2019

Here is the report for ad32191 (mirumee/saleor @ store-credit-card-info)
Base comparison is d528263.

No differences were found. (click me)

# api.benchmark checkout
  test name                           	left count 	right count	duplicate count
  ------------------------------------	-----------	-----------	---------------
  add billing address to checkout     	         34	         34	             20
  add shipping to checkout            	          7	          7	              0
  checkout payment charge             	         14	         14	              0
  complete checkout                   	          6	          6	              0
  create checkout                     	         43	         43	             21

# api.benchmark homepage
  test name                           	left count 	right count	duplicate count
  ------------------------------------	-----------	-----------	---------------
  retrieve main menu                  	          5	          5	              0
  retrieve product list               	          4	          4	              0
  retrieve secondary menu             	          5	          5	              0
  retrieve shop                       	          2	          2	              0

# api.benchmark product
  test name                           	left count 	right count	duplicate count
  ------------------------------------	-----------	-----------	---------------
  product details                     	         13	         13	              3

# api.benchmark variant
  test name                           	left count 	right count	duplicate count
  ------------------------------------	-----------	-----------	---------------
  retrieve variant list               	          9	          9	              2

@salwator salwator force-pushed the store-credit-card-info branch 2 times, most recently from 3729d70 to 82a022f Compare June 17, 2019 13:05
@salwator salwator force-pushed the store-credit-card-info branch 2 times, most recently from b07b88d to b1961aa Compare June 27, 2019 11:48
saleor/payment/utils.py Outdated Show resolved Hide resolved
saleor/settings.py Outdated Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Outdated Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Outdated Show resolved Hide resolved
saleor/account/models.py Outdated Show resolved Hide resolved
saleor/account/models.py Show resolved Hide resolved
saleor/graphql/checkout/mutations.py Outdated Show resolved Hide resolved
saleor/payment/gateways/braintree/__init__.py Outdated Show resolved Hide resolved
saleor/payment/utils.py Outdated Show resolved Hide resolved
tests/api/test_payment.py Outdated Show resolved Hide resolved
tests/api/test_payment.py Show resolved Hide resolved
tests/gateway/test_braintree.py Outdated Show resolved Hide resolved
saleor/settings.py Outdated Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Outdated Show resolved Hide resolved
saleor/graphql/payment/schema.py Outdated Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Outdated Show resolved Hide resolved
saleor/graphql/payment/resolvers.py Show resolved Hide resolved
saleor/payment/utils.py Outdated Show resolved Hide resolved
tests/gateway/test_braintree.py Outdated Show resolved Hide resolved
tests/api/test_payment.py Show resolved Hide resolved
tests/api/test_payment.py Show resolved Hide resolved
tests/api/test_payment.py Show resolved Hide resolved
saleor/account/models.py Show resolved Hide resolved
saleor/graphql/checkout/mutations.py Outdated Show resolved Hide resolved
saleor/graphql/payment/schema.py Outdated Show resolved Hide resolved
saleor/graphql/payment/types.py Show resolved Hide resolved
saleor/payment/gateways/braintree/__init__.py Show resolved Hide resolved
saleor/payment/utils.py Show resolved Hide resolved
saleor/payment/utils.py Outdated Show resolved Hide resolved
saleor/payment/interface.py Outdated Show resolved Hide resolved
saleor/payment/interface.py Show resolved Hide resolved
saleor/payment/utils.py Outdated Show resolved Hide resolved
saleor/graphql/checkout/mutations.py Outdated Show resolved Hide resolved
saleor/graphql/payment/types.py Outdated Show resolved Hide resolved
salwator and others added 3 commits July 11, 2019 09:38
Co-Authored-By: NyanKiyoshi <hello@vanille.bid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
payments Issues related to payments implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to store credit card for further usage
5 participants