<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string>from DateTime import DateTime\n
payzen_event = state_change[\'object\']\n
\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
  vads_url_cancel = kwargs[\'vads_url_cancel\']\n
  vads_url_error = kwargs[\'vads_url_error\']\n
  vads_url_referral = kwargs[\'vads_url_referral\']\n
  vads_url_refused = kwargs[\'vads_url_refused\']\n
  vads_url_success = kwargs[\'vads_url_success\']\n
  vads_url_return = kwargs[\'vads_url_return\']\n
except KeyError:\n
  raise TypeError, "PayzenEvent_generateNavigationPage takes exactly 6 arguments"\n
\n
payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction")\n
now = DateTime()\n
payment_transaction.AccountingTransaction_updateStartDate(now)\n
\n
transaction_date, transaction_id = payment_transaction.PaymentTransaction_generatePayzenId()\n
if transaction_id is None:\n
  raise ValueError, "Transaction already registered"\n
\n
payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
\n
today = now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d\')\n
payzen_dict = {\n
  \'vads_currency\': payment_transaction.getResourceValue().Currency_getIntegrationMapping(),\n
  \'vads_amount\': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n
  \'vads_trans_date\': now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d%H%M%S\'),\n
  \'vads_trans_id\': transaction_id,\n
  \'vads_language\': \'en\',\n
  \'vads_url_cancel\': vads_url_cancel,\n
  \'vads_url_error\': vads_url_error,\n
  \'vads_url_referral\': vads_url_referral,\n
  \'vads_url_refused\': vads_url_refused,\n
  \'vads_url_success\': vads_url_success,\n
  \'vads_url_return\': vads_url_return,\n
}\n
\n
payment_service = payzen_event.getSourceValue(portal_type="Payzen Service")\n
html_document = payment_service.navigate(\n
  page_template=\'payzen_payment\',\n
  pay=\'Click to pay\',\n
  payzen_dict=payzen_dict,\n
)\n
payzen_event.newContent(\n
  title=\'Shown Page\',\n
  portal_type=\'Payzen Event Message\',\n
  text_content=html_document,\n
)\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>state_change</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>PayzenEvent_generateNavigationPage</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
