Commit b1694904 authored by Romain Courteaud's avatar Romain Courteaud

Mail is send when payment is generated.

parent 967c72f1
...@@ -500,45 +500,33 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -500,45 +500,33 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.assertEqual(len(line_list), 0) self.assertEqual(len(line_list), 0)
@changeSkin('Hosting') @changeSkin('Hosting')
def usePayzenManually(self, web_site): def usePayzenManually(self, web_site, user_reference):
# No more acknowledgment
acknowledgement_json = \ acknowledgement_json = \
web_site.AcknowledgementTool_getUserUnreadAcknowledgementJSON() web_site.AcknowledgementTool_getUserUnreadAcknowledgementJSON()
acknowledgement_dict = json.loads(acknowledgement_json) acknowledgement_dict = json.loads(acknowledgement_json)
self.assertTrue('result' in acknowledgement_dict, "%s" % acknowledgement_dict) self.assertTrue('result' in acknowledgement_dict, "%s" % acknowledgement_dict)
message_list = acknowledgement_dict['result'] message_list = acknowledgement_dict['result']
self.assertEquals(len(message_list), 1, "%s" % message_list) self.assertEquals(len(message_list), 0, "%s" % message_list)
message = message_list[0]
self.assertTrue('acknowledge_url' in message, "%s" % message)
self.assertTrue('text_content' in message, "%s" % message)
acknowledge_url = message['acknowledge_url']
text_content = message['text_content']
self.assertTrue(acknowledge_url.startswith( # User received an email for payment
'AcknowledgementTool_acknowledge?acknowledgement_url=event_module/'), email = '%s@example.com' % user_reference
"%s" % acknowledge_url) def findMessage(email, body):
for candidate in reversed(self.portal.MailHost.getMessageList()):
self.assertTrue(text_content.startswith( if [q for q in candidate[1] if email in q] and body in candidate[2]:
'Please pay your payment by clicking <a href="accounting_module/'), return candidate[2]
"%s" % text_content) to_click_message = findMessage(email, 'A new invoice has been generated.')
self.assertTrue(text_content.endswith( self.assertNotEqual(None, to_click_message)
'/PaymentTransaction_redirectToManualPayzenPayment">here</a>.'),
"%s" % text_content)
# Pay to payzen # Pay to payzen
to_click_url = re.search('href="(.+?)"', text_content).group(1) document_id = self.portal.portal_catalog.getResultValue(
module, document_id, skin = to_click_url.split('/') portal_type="Payment Transaction",
simulation_state="started",
).getId()
click_result = \ click_result = \
web_site.accounting_module[document_id].\ web_site.accounting_module[document_id].\
PaymentTransaction_redirectToManualPayzenPayment() PaymentTransaction_redirectToManualPayzenPayment()
# Acknowledge
event_url = str(acknowledge_url.split('=')[-1])
web_site.AcknowledgementTool_acknowledge(acknowledgement_url=event_url)
def test(self): def test(self):
# some preparation # some preparation
self.logout() self.logout()
...@@ -763,8 +751,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -763,8 +751,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.assertPersonDocumentCoverage(person) self.assertPersonDocumentCoverage(person)
self.login(public_reference) self.login(public_reference)
self.usePayzenManually(self.web_site) self.usePayzenManually(self.web_site, public_reference)
self.login(friend_reference) self.login(friend_reference)
self.usePayzenManually(self.web_site) self.usePayzenManually(self.web_site, friend_reference)
\ No newline at end of file
...@@ -96,7 +96,7 @@ Do not hesitate to visit the web forum (http://community.slapos.org/forum) in ca ...@@ -96,7 +96,7 @@ Do not hesitate to visit the web forum (http://community.slapos.org/forum) in ca
Regards,\n Regards,\n
The slapos team\n The slapos team\n
""" % portal.portal_preferences.getPreferredSlaposWebSiteUrl())\n """ % portal.portal_preferences.getPreferredSlaposWebSiteUrl())\n
mail_message.start(comment=\'Requested manual payment.\')\n portal.portal_workflow.doActionFor(mail_message, \'start_action\', send_mail=True, comment=\'Requested manual payment.\')\n
mail_message.stop(comment=\'Requested manual payment.\')\n mail_message.stop(comment=\'Requested manual payment.\')\n
mail_message.deliver(comment=\'Requested manual payment.\')\n mail_message.deliver(comment=\'Requested manual payment.\')\n
\n \n
......
111 112
\ No newline at end of file \ No newline at end of file
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