[getpaid commit] r2692 - Everything works now to the point of review screen

0 views
Skip to first unread message

codesite...@google.com

unread,
Jun 10, 2009, 12:34:34 AM6/10/09
to getpaid...@groups.google.com
Author: mi...@redinnovation.com
Date: Tue Jun 9 20:52:51 2009
New Revision: 2692

Added:

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/pay.pt
Modified:

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/admin.py

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/checkout.py

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-payment-method.pt

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-review-pay.pt

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/settings-payment-processors.pt

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/member.py

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/preferences.py

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/dummy_processors.py

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/button.pt

Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/test_payment_processors.py

Log:
Everything works now to the point of review screen

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/admin.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/admin.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/admin.py
Tue Jun 9 20:52:51 2009
@@ -58,7 +58,7 @@
if interface is not None:
self.adapters = { interface :
interfaces.IGetPaidManagementOptions( self.context ) }
super( BaseSettingsForm, self).update()
-
+
class Identification( BaseSettingsForm ):
"""
get paid management interface
@@ -217,7 +217,7 @@
"
self.
"""
-
+
class PaymentProcessors(BrowserView):
""" The user goes to payment processor settings in GetPaid setup.

@@ -229,9 +229,9 @@

TODO: This form is not protected against XSS attacks.
"""
-
+
template =
ZopeTwoPageTemplateFile('templates/settings-payment-processors.pt')
-
+
def getCheckedForProcessor(self, processor):
"""

@@ -270,7 +270,7 @@
# Assume POST, user is changing active payment methods
self.processForm()
return self.template() # render page
-
+

class PaymentProcessor( BaseSettingsForm ):
"""

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/checkout.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/checkout.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/checkout.py
Tue Jun 9 20:52:51 2009
@@ -28,7 +28,10 @@
from getpaid.core import interfaces, options, cart
from getpaid.core.order import Order

+
from getpaid.paymentprocessors.registry import paymentProcessorRegistry
+from getpaid.paymentprocessors.interfaces import IPaymentMethodInformation
+
from Products.PloneGetPaid.payment import getActivePaymentProcessors

import Acquisition
@@ -93,31 +96,31 @@

class BasePaymentMethodButton(BrowserView):
""" Render payment method button on payment method checkout screen.
-
+
Subclass this to add your on payment method selection HTML on payment
selection
checkout screen.
"""
-
+
def update(self, processor, paymentMethodsView):
- """ Called by CheckoutPaymentMethodSelection to tell
-
+ """ Called by CheckoutPaymentMethodSelection to tell
+
@param processor: getpaid.paymentprocessor.registry.Entry instance
@param paymentMethodView: CheckoutPaymentMethodSelection instance
"""
self.processor = processor
self.paymentMethodsView = paymentMethodsView
-
+
def getProcessor(self):
"""
"""
return self.processor # Set externally by
CheckoutPaymentMethodSelection
-
- def isChecked(self):
+
+ def isChecked(self):
if self.processor.name in
self.paymentMethodsView.getActiveProcessorName():
return "CHECKED"
else:
- return None
-
+ return None
+

class BaseCheckoutForm( BaseFormView ):

@@ -173,7 +176,17 @@
interface = formSchemas.getInterface(section)
adapter = component.queryAdapter(user,interface)
if adapter is None:
- adapter = formSchemas.getBagClass(section)()
+
+ # PLEASE PLEASE PLEASE document your code.. it's not
*that* hard
+ # I have no idea wtf is going on here
+ # section "contact_info" returns class
Products.PloneGetPaid.member.ContactInfo
+ # section "payment" returns
getpaid.core.options.transientbag
+ # and they take different constructors...
+ # just my nightly curses -mikko
+
+ cls = formSchemas.getBagClass(section)
+ adapter = cls()
+
adapters[interface]=adapter
return adapters

@@ -213,7 +226,7 @@

order.shopping_cart = loads( dumps( shopping_cart ) )

- for section in
('contact_information','billing_address','shipping_address'):
+ for section in
('contact_information','billing_address','shipping_address','payment_method'):
interface = formSchemas.getInterface(section)
bag =
formSchemas.getBagClass(section).frominstance(adapters[interface])
setattr(order,section,bag)
@@ -257,6 +270,21 @@

BillingInfo = BillingInfo.makeclass( interfaces.IUserPaymentInformation )

+class PaymentMethodInfo(options.PropertyBag):
+ """ Store checkout session information about chosen payment method.
+
+ This is a transiet storage which checkout wizard part
+ can access through getSchemaAdapters().
+ """
+
+ title = "Payment Method Information"
+
+ def __getstate__( self ):
+ # don't store persistently
+ raise RuntimeError("Storage Not Allowed")
+
+PaymentMethodInfo = PaymentMethodInfo.makeclass(IPaymentMethodInformation)
+
class ImmutableBag( object ):

def initfrom( self, other, iface ):
@@ -544,16 +572,20 @@
"""
browser view for collecting credit card information and submitting it
to
a processor.
+
"""

template =
ZopeTwoPageTemplateFile("templates/checkout-payment-method.pt")
-
+
+ sections = ("payment_method",)
+
def getProcessors(self):
- """ Get active payment processors. """
+ """ Get active payment processors. """
processors = getActivePaymentProcessors(self.context)
return processors

def update( self ):
+ """ Process form inputs """
formbase.processInputs( self.request )
self.adapters = self.wizard.data_manager.adapters
super( CheckoutPaymentMethodSelection, self).update()
@@ -562,8 +594,12 @@
""" Create selection button renderer view and call it.

@param processor: registry.Entry instance
+ @return: HTML code as a string
"""
view = processor.getButtonView(self.context, self.request)
+
+ # View is BasePaymentMethodButton instance
+ view.update(processor, self)
return view()

@form.action(_(u"Cancel"), name="cancel", validator=null_condition)
@@ -572,11 +608,14 @@
url = url.replace("https://", "http://")
return self.request.response.redirect(url)

+ @form.action(_(u"Back"), name="back")
+ def handle_back( self, action, data, validator=null_condition):
+ self.next_step_name = wizard_interfaces.WIZARD_PREVIOUS_STEP
+
@form.action(_(u"Continue"), name="continue")
- def handle_continue( self, action, data ):
+ def handle_continue( self, action, data ):
self.next_step_name = wizard_interfaces.WIZARD_NEXT_STEP

-
class CheckoutReviewAndPay( BaseCheckoutForm ):

sections = ('payment',)
@@ -744,6 +783,7 @@
state = order.finance_state
f_states = interfaces.workflow_states.order.finance
base_url = self.context.absolute_url()
+
if not 'http://' in base_url:
base_url = base_url.replace("https://", "http://")

@@ -757,12 +797,11 @@
f_states.REVIEWING,
f_states.CHARGED):
return base_url
+ '/@@getpaid-thank-you?order_id=%s&finance_state=%s' %(order.order_id,
state)
-
+
def isPlone3(self):
"""test if it is a plone3 site
"""
return config.PLONE3
-

class ShippingRate( options.PropertyBag ):
title = "Shipping Rate"

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-payment-method.pt
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-payment-method.pt
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-payment-method.pt
Tue Jun 9 20:52:51 2009
@@ -1,8 +1,8 @@
-<html metal:use-macro="here/main_template/macros/master"
i18n:domain="plonegetpaid" >
- <body>
- <div metal:fill-slot="main" class="payment-selection" >
+<metal:page
use-macro="context/@@getpaid-content-template/macros/content_space"
+ i18n:domain="plonegetpaid">
+ <metal:block fill-slot="getpaid_content">

- <h1 i18n:translate="choose_payment_method" />
+ <h3 i18n:translate="choose_payment_method">choose_payment_method</h3>

<tal:payment-methods define="processors view/getProcessors">

@@ -12,12 +12,18 @@
that those payment processors are enabled in GetPaid portal setup.
</p>

- <form action="." method="POST" class="payment-method">
+ <form action="." method="POST" class="payment-methods"
tal:attributes="action request/URL">
+
+ <div class="hidden_fields"
+ tal:content="structure view/hidden_inputs"> </div>
+
+ <div class="portalMessage" tal:content="view/status"
tal:condition="view/status"> </div>
+
<table>
<tbody>
<tal:processor repeat="processor processors">
- <tr replace="structure python:view.renderProcessor(processor)" />
- </tal:processor>
+ <tr tal:replace="structure python:view.renderProcessor(processor)"
/>
+ </tal:processor>
</tbody>
</table>

@@ -39,7 +45,5 @@
</form>

</tal:payment-methods>
-
- </div>
- </body>
-</html>
\ No newline at end of file
+ </metal:block>
+</metal:page>

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-review-pay.pt
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-review-pay.pt
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/checkout-review-pay.pt
Tue Jun 9 20:52:51 2009
@@ -47,33 +47,33 @@

<div class="visualClear"><!-- --></div>

-
+
<div class="cart-listing">
<fieldset>
<legend i18n:translate=""> Shopping Cart </legend>
<div tal:replace="structure view/renderCart">cart</div>
-
+
<tal:cond condition="view/isPlone3">
<div tal:replace="structure
provider:getpaid.belowcartresume" />
</tal:cond>
-
-
+
+
<div id="save_order_template_entry" style="display: none">
<label for="order_template_entry_name"
id="order_template_entry_name_label" i18n:translate="">Order template
name</label>
<div class="formHelp"
i18n:translate=""
id="order_template_entry_name_help_text">A name you can remember this order
template by.</div>
<input type="text" id="order_template_entry_name"
name="order_template_entry_name" >
</div>
-
-

- <input type="button" id="save_order_template"
class="standalone" name="save_order_template" value="Save this order as a
template"
onclick="swapVisibility('save_order_template','save_order_template_entry')"
i18n:attributes="value" />
+
+
+ <input type="button" id="save_order_template"
class="standalone" name="save_order_template" value="Save this order as a
template"
onclick="swapVisibility('save_order_template','save_order_template_entry')"
i18n:attributes="value" />


</fieldset>
-
-
-
+
+
+
</div>

<div>
@@ -96,8 +96,10 @@
</tal:loop>
</span>
</div>
-
</form>
+
+ <div tal:replace="structure view/renderPayment" />
+
<metal:legal use-macro="context/@@legal-disclaimers-links/links" />

</metal:block>

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/settings-payment-processors.pt
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/settings-payment-processors.pt
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/browser/templates/settings-payment-processors.pt
Tue Jun 9 20:52:51 2009
@@ -6,7 +6,7 @@

<tal:core tal:define="portal_state context/@@plone_portal_state"
i18n:domain="getpaid.paymentprocessors">

- <form method="POST" tal:attributes="action
string:${portal_state/portal_url}/@@manage-getpaid-payment-options">
+ <form method="POST" tal:attributes="action
string:${portal_state/portal_url}/@@manage-getpaid-payment-processor">
<table>
<thead>
<tr>
@@ -18,7 +18,7 @@
<tal:payment-methods define="processors view/getProcessors">
<tr tal:repeat="processor processors">
<td>
- <input type="checkbox" name="active-payment-processors"
value="processor/name" tal:attributes="CHECKED
python:view.getCheckedForProcessor(processor) or None"/>
+ <input type="checkbox" name="active-payment-processors:list"
tal:attributes="value processor/name; CHECKED
python:view.getCheckedForProcessor(processor) or None"/>
<td class="payment-processor-link">
<span tal:content="processor/name" />
[ <a tal:attributes="href
string:${portal_state/portal_url}/@@${processor/settings_view}"
i18n:translate="edit_settings">edit_settings</a> ]

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/member.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/member.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/member.py
Tue Jun 9 20:52:51 2009
@@ -4,18 +4,18 @@
except ImportError:
#plone2.5 compatibility
from zope.app.location.interfaces import ILocation
-
+
from getpaid.core import options, interfaces

from Products.PloneGetPaid.i18n import _
from Products.CMFPlone.utils import getSiteEncoding

class ContactInfo( options.PersistentBag ):
- title = "Contact Information"
+ title = "Contact Information"
interface.implements( ILocation )
__parent__ = None
__name__ = None
-
+
ContactInfo.initclass( interfaces.IUserContactInformation )

class ShipAddressInfo( options.PersistentBag ):
@@ -31,7 +31,7 @@
interface.implements( ILocation )
__parent__ = None
__name__ = None
-
+
BillAddressInfo.initclass( interfaces.IBillingAddress )


@@ -45,8 +45,8 @@
field_map = schema.getFields( interfaces.IShippingAddress )
for n, f in field_map.items():
f.set( info, f.query( last_info, f.default ) )
- return info
-
+ return info
+
def lastBillAddress( user ):
order_manager = component.getUtility( interfaces.IOrderManager )
orders = order_manager.query( user_id = user.getId() )
@@ -57,8 +57,8 @@
field_map = schema.getFields( interfaces.IBillingAddress )
for n, f in field_map.items():
f.set( info, f.query( last_info, f.default ) )
- return info
-
+ return info
+
def lastOrderContactInfo( user ):
order_manager = component.getUtility( interfaces.IOrderManager )
orders = order_manager.query( user_id = user.getId() )
@@ -69,7 +69,7 @@
field_map = schema.getFields( interfaces.IUserContactInformation )
for n, f in field_map.items():
f.set( info, f.query( last_info, f.default ) )
- return info
+ return info

def memberContactInformation( user ):
"""
@@ -81,7 +81,7 @@
info = lastOrderContactInfo( user )
if info:
return info
-
+
# go from the user to the site via a user containment acquisition
# ( user, userfolder, container)
store = user.aq_inner.aq_parent.aq_parent
@@ -98,7 +98,7 @@
for n, f in field_map.items():
f.set( info, f.query( last_info, f.default ) )

-
+
# get a member which will properly wrap up a user in a member object
member = store.portal_membership.getMemberById( user.getId() )


Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/preferences.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/preferences.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/preferences.py
Tue Jun 9 20:52:51 2009
@@ -5,9 +5,12 @@
$Id$
"""

-from browser.checkout import BillingInfo
+from browser.checkout import BillingInfo, PaymentMethodInfo
from getpaid.core import interfaces as core_interfaces
from getpaid.core.options import PersistentOptions,
PersistentBag,FormSchemas
+
+from getpaid.paymentprocessors import interfaces as payment_interfaces
+
from member import ShipAddressInfo, BillAddressInfo, ContactInfo
from zope import component
import interfaces
@@ -18,7 +21,7 @@

if settings is None: # we have an unmigrated site.. fallback gracefully
return OldConfigurationPreferences( site )
-
+
# store access to the site, because our vocabularies get the setting
as context
# and want to access portal tools to construct various vocabs
settings._v_site = site
@@ -26,7 +29,7 @@

# previously we stored settings as annotations on the site, we've migrated
this to
# its own utility, so we don't have to carry context to access the store
settings.
-# we have it here so we can do a migration.
+# we have it here so we can do a migration.
OldConfigurationPreferences =
PersistentOptions.wire("OldConfigurationPreferences",
"getpaid.configuration",

interfaces.IGetPaidManagementOptions )
@@ -36,7 +39,7 @@
class StoreSettings( _StoreSettings ):

_v_site = None
-
+
@property
def context( self ):
return self._v_site
@@ -50,6 +53,7 @@
'shipping_address':core_interfaces.IShippingAddress,
'contact_information':core_interfaces.IUserContactInformation,
'payment':core_interfaces.IUserPaymentInformation,
+ 'payment_method' : payment_interfaces.IPaymentMethodInformation,
}

bags = {
@@ -57,5 +61,6 @@
'shipping_address':ShipAddressInfo,
'contact_information':ContactInfo,
'payment':BillingInfo,
+ 'payment_method':PaymentMethodInfo,
}


Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/dummy_processors.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/dummy_processors.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/dummy_processors.py
Tue Jun 9 20:52:51 2009
@@ -34,12 +34,19 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="foo">

+ <adapter
+ for="getpaid.core.interfaces.IStore"
+ provides="getpaid.core.interfaces.IPaymentProcessor"
+ factory="Products.PloneGetPaid.tests.dummy_processors.DummyProcessor"
+ name="Dummy Processor"
+ />
+
<paymentprocessors:registerProcessor
- name="dummy"
-
processor="Products.PloneGetPaid.tests.dummy_processors.DummyProcessor"
+ name="Dummy Processor"
selection_view="dummy_payment_processor_button"
thank_you_view="dummy_payment_processor_thank_you_page"
settings_view="dummy_payment_processor_settings"
+ pay_view="dummy_payment_processor_pay"
/>

<browser:page
@@ -65,6 +72,13 @@
permission="cmf.ManagePortal"
/>

+ <browser:page
+ for="getpaid.core.interfaces.IStore"
+ name="dummy_payment_processor_pay"
+ template="templates/pay.pt"
+ permission="zope2.View"
+ />
+
</configure>'''

# Enable two dummy payment processors
@@ -77,9 +91,9 @@

<paymentprocessors:registerProcessor
name="dummy2"
-
processor="Products.PloneGetPaid.tests.dummy_processors.DummyProcessor"
selection_view="dummy_payment_processor_button"
thank_you_view="dummy_payment_processor_thank_you_page"
+ pay_view="dummy_payment_processor_pay"
/>

</configure>'''

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/button.pt
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/button.pt
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/button.pt
Tue Jun 9 20:52:51 2009
@@ -1,11 +1,11 @@
<tr i18n:domain="getpaid.dummypaymentprocessor" tal:define="processor
view/getProcessor">
-
+
<td >
- <input name="payment-method" type="radio" tal:attributes="value
processor/name">
+ <input name="payment_method" type="radio" tal:attributes="value
processor/name">
<img src="foobar.jpg" alt="Magical processor"/>
</td>
<td i18n:translate="dummy_payment_method_description">
Magical string checked by unit tests
- </td>
+ </td>
</tr>


Added:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/pay.pt
==============================================================================
--- (empty file)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/templates/pay.pt
Tue Jun 9 20:52:51 2009
@@ -0,0 +1,10 @@
+<metal:page
use-macro="context/@@getpaid-content-template/macros/content_space"
+ i18n:domain="plonegetpaid">
+ <metal:block fill-slot="getpaid_content">
+
+
+ <h3 i18n:translate="heading_checkout_pay">Pay here</h3>
+
+
+ </metal:block>
+</metal:page>

Modified:
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/test_payment_processors.py
==============================================================================
---
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/test_payment_processors.py
(original)
+++
Products.PloneGetPaid/branches/multiplepaymentprocessors/Products/PloneGetPaid/tests/test_payment_processors.py
Tue Jun 9 20:52:51 2009
@@ -13,19 +13,26 @@
from getpaid.paymentprocessors.registry import
BadViewConfigurationException, paymentProcessorRegistry
import dummy_processors

+from getpaid.paymentprocessors.interfaces import IPaymentMethodInformation
+
class TestPaymentMethods(PloneGetPaidTestCase):
""" Test ZCML directives """
-
+
def afterSetUp(self):
PloneGetPaidTestCase.afterSetUp(self)
paymentProcessorRegistry.clear()
-
+
def loadDummyZCML(self, string):
""" Load ZCML as a string and set the folder so that template
references are related correctly. """
module = sys.modules[__name__]
dir = os.path.dirname(module.__file__)
os.chdir(dir)
- zcml.load_string(string)
+ zcml.load_string(string)
+
+ def enable_processor(self):
+ """ Enable one dummy payment processor for testing """
+ self.loadDummyZCML(dummy_processors.configure_zcml)
+
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "Dummy Processor"]

def render_admin(self):
""" Test rendering admin interface views with the current
paymentprocessor configuration. """
@@ -36,38 +43,38 @@
view =
self.portal.restrictedTraverse("@@manage-getpaid-payment-processor")
view()
self.logout()
-
-
+
+
def get_payment_method_selection_screen(self):
""" Get the checkout payment method selection view via checkout
wizard """
-
+
# Force in checkout wizard step
step = "checkout-payment-method"
self.portal.REQUEST["cur_step"] = step # See _wizard.pt
wizard =
self.portal.restrictedTraverse("@@getpaid-checkout-wizard")
-
- view = wizard.controller.getCurrentStep()
+
+ view = wizard.controller.getCurrentStep()
return view
-
+
def render_payment_method_selection_screen(self,
assertedProcessorCount):
""" Test rendering payment method selection page in checkout
wizard """

view = self.get_payment_method_selection_screen()
-
+
processors = view.getProcessors()
self.assertEqual(len(processors), assertedProcessorCount)

# Render payment method selection HTML - see that template doesn't
raise an error
# TODO: Check HTML output validy using functional tests
view()
-
+

def test_selection_screen_no_processor(self):
""" Test different count of site payment processors """

# Go to checkout process point where the payment method is selected
self.render_payment_method_selection_screen(0)
-
+

self.portal.portal_properties.payment_processor_properties.enabled_processors
= []

# Test rendering related admin interface pages and hope to catch
all raised exceptions
@@ -76,8 +83,8 @@
def test_selection_screen_one_processor(self):
""" Test different count of site payment processors """
self.loadDummyZCML(dummy_processors.configure_zcml)
-
-
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "dummy"]
+
+
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "Dummy Processor"]

# Go to checkout process point where the payment method is selected
self.render_payment_method_selection_screen(1)
@@ -90,8 +97,8 @@
""" Test different count of site payment processors """
self.loadDummyZCML(dummy_processors.configure_zcml)
self.loadDummyZCML(dummy_processors.configure_zcml_2)
-
-
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "dummy", "dummy2"]
+
+
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "Dummy Processor", "dummy2"]

# Go to checkout process point where the payment method is selected
self.render_payment_method_selection_screen(2)
@@ -110,15 +117,14 @@
i18n_domain="foo">

<paymentprocessors:registerProcessor
- name="dummy"
-
processor="Products.PloneGetPaid.tests.dummy_processors.DummyProcessor"
+ name="Dummy Processor"
selection_view="BAD_ENTRY_HERE"
thank_you_view="dummy_payment_processor_thank_you_page"
/>

</configure>'''
zcml.load_string(bad_button_configure_zcml)
-
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "dummy" ]
+
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "Dummy Processor" ]
try:
self.render_payment_method_selection_screen(1)
raise AssertionError("Should not be never reached")
@@ -133,44 +139,52 @@
# Do fake POST
request = self.portal.REQUEST
request["REQUEST_METHOD"] = "POST"
- request["active-payment-processors"] =["dummy"]
+ request["active-payment-processors"] =["Dummy Processor"]

view =
self.portal.restrictedTraverse("@@manage-getpaid-payment-processor")
view()
-
self.assertEqual(self.portal.portal_properties.payment_processor_properties.enabled_processors,
["dummy"])
+
self.assertEqual(self.portal.portal_properties.payment_processor_properties.enabled_processors,
["Dummy Processor"])

def test_settings_view(self):
""" Render settings view for an payment processor. """
self.loadDummyZCML(dummy_processors.configure_zcml)
self.loginAsPortalOwner()

self.portal.restrictedTraverse("@@dummy_payment_processor_settings")
-
-
+
def test_payment(self):
+ """ Walk through payment processor.
+
+ Open wizard payment method selection page and simulate payment
method selection.
+ """
+ self.enable_processor()

- self.loadDummyZCML(dummy_processors.configure_zcml)
-
-
self.portal.portal_properties.payment_processor_properties.enabled_processors
= [ "dummy"]
-
view = self.get_payment_method_selection_screen()
html = view()
-
- self.assertTrue('name="dummy"' in html) # Check that payment
processor button is rendered there
-
+
+ self.assertTrue('<input name="payment-method" type="radio"
value="Dummy Processor">' in html) # Check that payment processor button is
rendered there
+
# Now simulate POST
request = self.portal.REQUEST
request["REQUEST_METHOD"] = "POST"
- request["dummy"] = 'dummy' # <button> submit
-
- view = get_payment_method_selection_screen()
-
+ request["payment_method"] = 'Dummy Processor' # <button> submit
+
+ view = self.get_payment_method_selection_screen()
+
# Now we should contain the payment data in the wizard
step = "checkout-review-pay"
self.portal.REQUEST["cur_step"] = step # See _wizard.pt
wizard =
self.portal.restrictedTraverse("@@getpaid-checkout-wizard")
-
- entry = self.wizard.data_manager.get("payment_method")
- self.assertEqual(entry, "dummy")
+ view = wizard.controller.getCurrentStep()
+
+ # Check that input is as a hidden field on the page
+ html = view()
+ print html
+
+ storage = wizard.data_manager.adapters[IPaymentMethodInformation]
+
+ import pdb ; pdb.set_trace()
+ entry = wizard.data_manager.get("payment_method")
+ self.assertEqual(entry, "Dummy Processor")

def test_suite():
from unittest import TestSuite, makeSuite

Reply all
Reply to author
Forward
0 new messages