Commit e08a7f43 authored by Romain Courteaud's avatar Romain Courteaud

Send an email when creating a Payment Transaction

parent 36368395
......@@ -58,21 +58,49 @@ if (context.getPaymentMode() != \'payzen\'):\n
portal = context.getPortalObject()\n
ticket = context.PaymentTransaction_addPayzenTicket()\n
\n
site_message = portal.event_module.newContent(\n
portal_type=\'Site Message\',\n
# site_message = portal.event_module.newContent(\n
# portal_type=\'Site Message\',\n
# start_date=DateTime(),\n
# destination_value=context.getDestinationSectionValue(),\n
# follow_up=ticket.getRelativeUrl(),\n
# source_value=context.getSourceSectionValue(),\n
# resource=ticket.getResource(),\n
# title="Payment requested",\n
# # XXX Hardcoded script provided by another bt5\n
# text_content=\'Please pay your payment by clicking <a \'\\\n
# \'href="%s/PaymentTransaction_redirectToManualPayzenPayment">here</a>.\' % \\\n
# context.getRelativeUrl(),\n
# )\n
# site_message.start(comment=\'Requested manual payment.\')\n
\n
mail_message = portal.event_module.newContent(\n
portal_type=\'Mail Message\',\n
start_date=DateTime(),\n
destination_value=context.getDestinationSectionValue(),\n
follow_up=ticket.getRelativeUrl(),\n
source_value=context.getSourceSectionValue(),\n
title=\'Invoice payment requested\',\n
resource=ticket.getResource(),\n
title="Payment requested",\n
# XXX Hardcoded script provided by another bt5\n
text_content=\'Please pay your payment by clicking <a \'\\\n
\'href="%s/PaymentTransaction_redirectToManualPayzenPayment">here</a>.\' % \\\n
context.getRelativeUrl(),\n
)\n
site_message.start(comment=\'Requested manual payment.\')\n
return site_message\n
# # XXX Hardcoded script provided by another bt5\n
# text_content=\'Please pay your payment by clicking <a \'\\\n
# \'href="%s/PaymentTransaction_redirectToManualPayzenPayment">here</a>.\' % \\\n
# context.getRelativeUrl(),\n
text_content="""\n
Dear user,\n
\n
A new invoice has been generated. \n
You can access it in your invoice section at %s.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % portal.portal_preferences.getPreferredSlaposWebSiteUrl())\n
mail_message.start(comment=\'Requested manual payment.\')\n
mail_message.stop(comment=\'Requested manual payment.\')\n
mail_message.deliver(comment=\'Requested manual payment.\')\n
\n
return mail_message\n
]]></string> </value>
......
......@@ -5,6 +5,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \
from DateTime import DateTime
from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
class TestSlapOSPaymentTransaction_sendManualPayzenPaymentUrl(testSlapOSMixin):
......@@ -25,6 +26,11 @@ class TestSlapOSPaymentTransaction_sendManualPayzenPaymentUrl(testSlapOSMixin):
None)
def test_sendManualPayzenPaymentUrl_payzen_payment(self):
for preference in \
self.portal.portal_catalog(portal_type="System Preference"):
preference = preference.getObject()
if preference.getPreferenceState() == 'global':
preference.setPreferredSlaposWebSiteUrl('http://foobar.org/')
person1 = self.portal.person_module.newContent(portal_type="Person")
person2 = self.portal.person_module.newContent(portal_type="Person")
transaction = self.createPaymentTransaction()
......@@ -36,18 +42,30 @@ class TestSlapOSPaymentTransaction_sendManualPayzenPaymentUrl(testSlapOSMixin):
event = transaction.PaymentTransaction_sendManualPayzenPaymentUrl()
after_date = DateTime()
ticket = transaction.PaymentTransaction_addPayzenTicket()
self.assertEquals(event.getPortalType(), 'Site Message')
self.assertEquals(event.getPortalType(), 'Mail Message')
self.assertTrue(event.getStartDate() >= before_date)
self.assertTrue(event.getStopDate() <= after_date)
self.assertEquals(event.getTitle(), "Invoice payment requested")
self.assertEquals(event.getDestination(),
transaction.getDestinationSection())
self.assertEquals(event.getSourceSection(),
transaction.getSource())
self.assertEquals(event.getTextContent(),
'Please pay your payment by clicking <a href="' + \
transaction.getRelativeUrl() + \
'/PaymentTransaction_redirectToManualPayzenPayment">here</a>.')
self.assertEquals(event.getSimulationState(), 'started')
expected_text_content = """
Dear user,
A new invoice has been generated.
You can access it in your invoice section at http://foobar.org/.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
"""
self.assertEquals(event.getTextContent(), expected_text_content,
'\n'.join([x for x in difflib.unified_diff(
event.getTextContent().splitlines(),
expected_text_content.splitlines())]))
self.assertEquals(event.getSimulationState(), 'delivered')
self.assertEquals(event.getFollowUp(),
ticket.getRelativeUrl())
......
110
\ No newline at end of file
111
\ 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