Stripe checkout #104411
@ -127,6 +127,7 @@ class TestSubscriptionSettingsChangePaymentMethod(BaseSubscriptionTestCase):
|
||||
expected_redirect_url = 'https://checkout.stripe.com/c/pay/cs_test_c1QeSt36UcbmnmrXJnEYZpWakr377WPMfbWLeR9d3ZBYJPWXRUJ3TQ0UG9#fidkdWxOYHwnPyd1blpxYHZxWjA0VUpnNzNAMU5EUEcwYW92dWIwclxRMzQ8ZkxsUDRET2dPbTVidnBCNEJTdlBJQTRJYFF2c09BMEFBdlxVT19USGpWSXRSXFJwdm5UQXRpdVw2Rmp%2FZ11NNTU3fHdHUl1JTCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBaZmppcGhrJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl'
|
||||
self.assertEqual(response['Location'], expected_redirect_url, response['Location'])
|
||||
|
||||
# **N.B**: this flow happens in 2 different views separated by a Stripe payment page.
|
||||
# Pretend that checkout session was completed and we've returned to the success page with its ID:
|
||||
checkout_session_id = 'cs_test_c1QeSt36UcbmnmrXJnEYZpWakr377WPMfbWLeR9d3ZBYJPWXRUJ3TQ0UG9'
|
||||
success_url = url + f'{checkout_session_id}/'
|
||||
@ -286,6 +287,7 @@ class TestPayExistingOrder(BaseSubscriptionTestCase):
|
||||
expected_redirect_url = 'https://checkout.stripe.com/c/pay/cs_test_a1XUS0akCexOKoMTKKnt9SjK1UjPI9UTrF7LiLzXWYInOcANZzOFLBkA5w#fidkdWxOYHwnPyd1blpxYHZxWjA0VUpnNzNAMU5EUEcwYW92dWIwclxRMzQ8ZkxsUDRET2dPbTVidnBCNEJTdlBJQTRJYFF2c09BMEFBdlxVT19USGpWSXRSXFJwdm5UQXRpdVw2Rmp%2FZ11NNTU3fHdHUl1JTCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl'
|
||||
self.assertEqual(response['Location'], expected_redirect_url)
|
||||
|
||||
# **N.B**: this flow happens in 2 different views separated by a Stripe payment page.
|
||||
# Pretend that checkout session was completed and we've returned to the success page with its ID:
|
||||
checkout_session_id = 'cs_test_a1XUS0akCexOKoMTKKnt9SjK1UjPI9UTrF7LiLzXWYInOcANZzOFLBkA5w'
|
||||
url = reverse(
|
||||
@ -295,6 +297,12 @@ class TestPayExistingOrder(BaseSubscriptionTestCase):
|
||||
url = url.replace('CHECKOUT_SESSION_ID', checkout_session_id)
|
||||
with responses.RequestsMock() as rsps:
|
||||
rsps._add_from_file(f'{responses_dir}stripe_retrieve_checkout_session_usd.yaml')
|
||||
# Replace metadata's "order_id" hardcoded in the response YAML with current order ID,
|
||||
# because it differs depending on whether this test is run alone or with all the tests.
|
||||
for _ in rsps.registered():
|
||||
if '%5D=payment_intent' in _.url:
|
||||
assert '\"order_id\": \"1' in _.body
|
||||
_.body = _.body.replace('\"order_id\": \"1', f'\"order_id\": \"{order.pk}')
|
||||
response = self.client.get(url)
|
||||
|
||||
self.assertEqual(order.transaction_set.count(), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user