This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial support for stripe payment intents (#3847)
* temp: add project-zebra to branches that should run ci (#3824) * fix: initial implementation of stripe fixes (#3817) Co-authored-by: John Nagro <[email protected]> * feat: Add waffle flag to enable Stripe payments (#3816) REV-3004 * feat: initial implementation of Stripe processor (#3826) Co-authored-by: wdrussell2015 <[email protected]> Co-authored-by: John Nagro <[email protected]> * fix: billing address creation * fix: retreive calls cannot take idempotency keys * temp: add logging * temp: add more logging * temp: add logging * fix: parsing address from payment intent * chore: cleanup logs * fix: Get billing address line2 default empty (#3833) * fix: Stripe billing address line2 default to empty if null (#3835) REV-3069 * feat: add SDN check (#3834) * feat: add SDN check * feat: use confirm call to complete transaction with stripe in ecommerce checkout endpoint * fix: make capture-context more resilient to idempotency errors (#3836) * fix: make capture-context more resilient to idempotency errors * fix: add new card types for stripe * feat: /management fulfill actions for Stripe FulfillFrozenBaskets is a helper class for a management page in Ecommerce (hosted at URL /management) that fulfills baskets that are paid but stuck in queue for fulfillment, to be used if, for example, ecommerce-worker is down. Add Stripe support for FulfillFrozenBaskets. Change FulfillFrozenBaskets so it does not continue fulfillment if the billing details are not retrievable. For Stripe, this handles when: * The PaymentMethod was not expanded in the PaymentIntent stored in the PaymentProcessorResponse (generating a TypeError) * The PaymentMethod was not a card (generating a KeyError). Also switched Cybersource to not fulfill if it cannot find the card brand. * fix: update PaymentIntent before confirmation * fix: stripe refunds should be of payment_intents, not charges * fix: change PaymentIntents to update_or_create Apparently, idempotency keys can expire after 24 hours. https://stripe.com/docs/api/idempotent_requests "Keys are eligible to be removed from the system automatically after they're at least 24 hours old, and a new request is generated if a key is reused after the original has been pruned." * refactor: reduce number of statements in management/utils.py for quality * fix: enable Stripe custom actions beta in settings * fix: finish passing api_version and enable_telemetry to stripe client * fix: add 'unknown' stripe card brand * fix: stripe api calls should be to payment_method and payment_intent_id * test: patch for stripePaymentIntent.modify * fix: StripeCheckoutView as a View instead of a FormView-like class StripeCheckoutView was previously like a FormView. However, our implementation of Stripe is much simpler and we opted to remove the overhead of Forms in lieu of trying to ensure all existing interfaces related to StripeSubmitForm. * fix: handle when Stripe charge is already refunded * test: correct refund_mock to use new payment_intent API * test: update Stripe mock responses for new API using actual calls * fix: log when payment_intent_id is missing from basket * refactor: move logging before retrieving any baskets * fix: clear out edx.org-specific Stripe publishable_key and secret_key * fix: throw a 500 on capture_context exceptions The Payment MFE will hang silently if capture_context fails. Throwing the exception will show an error message in Payment MFE, cluing the user in to the fact that there might be a problem. * fix: convert StripeCheckoutView to DRF for JWT auth Looks like JWT auth only works with DRF. * fix: return 200s or 400s instead of 302s in StripeCheckoutView We tried using 302s to redirect the Payment MFE to the receipt page. This didn't work because the library that we use for requests, Axios, doesn't appear to support not following redirects. Return a 200 or 400 instead, and separately instruct the frontend on what to do when receiving these. * fix: deprecate ECOMMERCE_PAYMENT_PROCESSOR_CONFIG.stripe.error_url error_path is already autoset by _oscar.py and grabbed by property processors.stripe.Stripe.error_url. * Revert "fix: throw a 500 on capture_context exceptions" This reverts commit 1008272. It looks like there is a chance that we might depend on this behavior (no errors on exceptions in _add_capture_context) given how this error occurs with non-negligible frequency in production. Will attempt to warn user on frontend side. * add self.record_processor_response to more stripe code paths (#3852) * feat: REV-3076 | record payment processor for various stripe logical flows * chore: update tests for sanity checks * fix: address comments * fix: use ISO 3166-1 alpha-2 country code for SDN check (#3854) * fix: add waffle flag ENABLE_STRIPE_PAYMENT_PROCESSOR to get_client_side_payment_processor_class() The client-side payment processor decides which payment processor Ecommerce will use when generating the capture context for a payment. Force the client-side payment processor to be 'stripe' when the waffle flag is on. * fix: make postcode & state optional for stripe Cybersource has an optional line2, postcode, and state: https://github.com/openedx/ecommerce/blob/05404ebac527da1f6a0fac7df262ca79f3acec56/ecommerce/extensions/payment/views/cybersource.py#L544-L547 Do the same for Stripe. Co-authored-by: Chris Pappas <[email protected]> Co-authored-by: John Nagro <[email protected]> Co-authored-by: Juliana Kang <[email protected]> Co-authored-by: wdrussell2015 <[email protected]> Co-authored-by: Chris Pappas <[email protected]>
- Loading branch information
1 parent
05404eb
commit 140b75f
Showing
33 changed files
with
1,383 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
ecommerce/extensions/payment/migrations/0032_alter_source_card_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.15 on 2022-10-11 16:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('payment', '0031_sdnfallbackdata'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='source', | ||
name='card_type', | ||
field=models.CharField(blank=True, choices=[('american_express', 'American Express'), ('diners', 'Diners'), ('discover', 'Discover'), ('jcb', 'JCB'), ('mastercard', 'MasterCard'), ('unionpay', 'UnionPay'), ('unknown', 'Unknown'), ('visa', 'Visa')], max_length=255, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.