Commit 15e46bc7 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_stripe: Use activity to store stripe session in ERP5

We set the module as a source to acquire roles. Also, we need to store request and response in HTTP Exchange.

This merge request is to fix nexedi/erp5@ec4a3f9d

See merge request nexedi/erp5!1771
parents c60eae9d 4c98e4bf
...@@ -6,15 +6,15 @@ stripe_payment_session = portal.stripe_payment_session_module.newContent( ...@@ -6,15 +6,15 @@ stripe_payment_session = portal.stripe_payment_session_module.newContent(
expiration_date=expiration_date, expiration_date=expiration_date,
resource=resource, resource=resource,
source_value=portal.restrictedTraverse(source), source_value=portal.restrictedTraverse(source),
causality=causality causality=causality)
)
http_exchange = portal.system_event_module.newContent( http_exchange = portal.system_event_module.newContent(
portal_type="HTTP Exchange", portal_type="HTTP Exchange",
title="Create Session", title="Create Session",
source_value=context,
follow_up_value=stripe_payment_session, follow_up_value=stripe_payment_session,
resource_value=portal.portal_categories.http_exchange_resource.stripe.create_session, resource_value=portal.portal_categories.http_exchange_resource.stripe.create_session,
) request=request, response=response)
http_exchange.confirm() http_exchange.confirm()
http_exchange.acknowledge() http_exchange.acknowledge()
......
...@@ -598,6 +598,14 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -598,6 +598,14 @@ class TestStripePaymentSession(ERP5TypeTestCase):
stripe_payment_session = self.portal.portal_catalog.getResultValue( stripe_payment_session = self.portal.portal_catalog.getResultValue(
portal_type="Stripe Payment Session", portal_type="Stripe Payment Session",
reference=session_id) reference=session_id)
http_exchange, = stripe_payment_session.getFollowUpRelatedValueList(portal_type="HTTP Exchange")
self.assertIn("line_items", json.loads(http_exchange.getRequest()))
self.assertEqual({
'status': 'open',
'url': 'https://stripe.url',
'object': 'checkout.session',
'id': 'abc321'
}, json.loads(http_exchange.getResponse()))
self._document_to_delete_list.append(stripe_payment_session) self._document_to_delete_list.append(stripe_payment_session)
with responses.RequestsMock() as rsps: with responses.RequestsMock() as rsps:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment