Пример #1
0
    def test_set_payment_status(self):

        # Generate shoppingcart signatures
        post_params = sign(self.client_post_params)
        # Configure the view to declined payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="decline",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "DECLINE"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'DECLINE')

        # Configure the view to fail payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="failure",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "REJECT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'REJECT')

        # Configure the view to accept payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="success",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "ACCEPT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'ACCEPT')
Пример #2
0
    def test_set_payment_status(self):

        # Generate shoppingcart signatures
        post_params = sign(self.CLIENT_POST_PARAMS)

        # Configure the view to fail payments
        resp = self.client.put(
            '/shoppingcart/payment_fake',
            data="failure", content_type='text/plain'
        )
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "REJECT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'REJECT')

        # Configure the view to accept payments
        resp = self.client.put(
            '/shoppingcart/payment_fake',
            data="success", content_type='text/plain'
        )
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "ACCEPT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'ACCEPT')
Пример #3
0
    def test_sends_valid_signature(self):

        # Generate shoppingcart signatures
        post_params = sign(self.client_post_params)

        # Get the POST params that the view would send back to us
        resp_params = PaymentFakeView.response_post_params(post_params)

        # Check that the client accepts these
        try:
            verify_signatures(resp_params)

        except CCProcessorSignatureException:
            self.fail("Client rejected signatures.")
Пример #4
0
    def test_sends_valid_signature(self):

        # Generate shoppingcart signatures
        post_params = sign(self.CLIENT_POST_PARAMS)

        # Get the POST params that the view would send back to us
        resp_params = PaymentFakeView.response_post_params(post_params)

        # Check that the client accepts these
        try:
            verify_signatures(resp_params)

        except CCProcessorSignatureException:
            self.fail("Client rejected signatures.")
Пример #5
0
    url(r'^clear/$', views.clear_cart, name='shoppingcart.views.clear_cart'),
    url(r'^remove_item/$',
        views.remove_item,
        name='shoppingcart.views.remove_item'),
    url(r'^add/course/{}/$'.format(settings.COURSE_ID_PATTERN),
        views.add_course_to_cart,
        name='add_course_to_cart'),
    url(r'^register/redeem/(?P<registration_code>[0-9A-Za-z]+)/$',
        views.register_code_redemption,
        name='register_code_redemption'),
    url(r'^use_code/$', views.use_code, name='shoppingcart.views.use_code'),
    url(r'^update_user_cart/$',
        views.update_user_cart,
        name='shoppingcart.views.update_user_cart'),
    url(r'^reset_code_redemption/$',
        views.reset_code_redemption,
        name='shoppingcart.views.reset_code_redemption'),
    url(r'^billing_details/$', views.billing_details, name='billing_details'),
    url(r'^verify_cart/$',
        views.verify_cart,
        name='shoppingcart.views.verify_cart'),
]

if settings.FEATURES.get('ENABLE_PAYMENT_FAKE'):
    from shoppingcart.tests.payment_fake import PaymentFakeView
    urlpatterns += [
        url(r'^payment_fake',
            PaymentFakeView.as_view(),
            name='shoppingcart.views.payment_fake'),
    ]
Пример #6
0
from django.conf.urls import patterns, url
from django.conf import settings

urlpatterns = patterns('shoppingcart.views',  # nopep8
    url(r'^postpay_callback/$', 'postpay_callback'),  # Both the ~accept and ~reject callback pages are handled here
    url(r'^receipt/(?P<ordernum>[0-9]*)/$', 'show_receipt'),
    url(r'^csv_report/$', 'csv_report', name='payment_csv_report'),
)

if settings.FEATURES['ENABLE_SHOPPING_CART']:
    urlpatterns += patterns(
        'shoppingcart.views',
        url(r'^$', 'show_cart'),
        url(r'^clear/$', 'clear_cart'),
        url(r'^remove_item/$', 'remove_item'),
        url(r'^add/course/{}/$'.format(settings.COURSE_ID_PATTERN), 'add_course_to_cart', name='add_course_to_cart'),
        url(r'^use_coupon/$', 'use_coupon'),
    )

if settings.FEATURES.get('ENABLE_PAYMENT_FAKE'):
    from shoppingcart.tests.payment_fake import PaymentFakeView
    urlpatterns += patterns(
        'shoppingcart.tests.payment_fake',
        url(r'^payment_fake', PaymentFakeView.as_view()),
    )
Пример #7
0
from django.conf.urls import patterns, url
from django.conf import settings

urlpatterns = patterns(
    "shoppingcart.views",  # nopep8
    url(r"^postpay_callback/$", "postpay_callback"),  # Both the ~accept and ~reject callback pages are handled here
    url(r"^receipt/(?P<ordernum>[0-9]*)/$", "show_receipt"),
    url(r"^donation/$", "donate", name="donation"),
    url(r"^csv_report/$", "csv_report", name="payment_csv_report"),
    # These following URLs are only valid if the ENABLE_SHOPPING_CART feature flag is set
    url(r"^$", "show_cart"),
    url(r"^clear/$", "clear_cart"),
    url(r"^remove_item/$", "remove_item"),
    url(r"^add/course/{}/$".format(settings.COURSE_ID_PATTERN), "add_course_to_cart", name="add_course_to_cart"),
    url(
        r"^register/redeem/(?P<registration_code>[0-9A-Za-z]+)/$",
        "register_code_redemption",
        name="register_code_redemption",
    ),
    url(r"^use_code/$", "use_code"),
    url(r"^update_user_cart/$", "update_user_cart"),
    url(r"^reset_code_redemption/$", "reset_code_redemption"),
    url(r"^billing_details/$", "billing_details", name="billing_details"),
    url(r"^register_courses/$", "register_courses"),
)

if settings.FEATURES.get("ENABLE_PAYMENT_FAKE"):
    from shoppingcart.tests.payment_fake import PaymentFakeView

    urlpatterns += patterns("shoppingcart.tests.payment_fake", url(r"^payment_fake", PaymentFakeView.as_view()))
Пример #8
0
from shoppingcart import views

urlpatterns = [
    # Both the ~accept and ~reject callback pages are handled here
    url(r'^postpay_callback/$', views.postpay_callback, name='shoppingcart.views.postpay_callback'),

    url(r'^receipt/(?P<ordernum>[0-9]*)/$', views.show_receipt, name='shoppingcart.views.show_receipt'),
    url(r'^donation/$', views.donate, name='donation'),
    url(r'^csv_report/$', views.csv_report, name='payment_csv_report'),

    # These following URLs are only valid if the ENABLE_SHOPPING_CART feature flag is set
    url(r'^$', views.show_cart, name='shoppingcart.views.show_cart'),
    url(r'^clear/$', views.clear_cart, name='shoppingcart.views.clear_cart'),
    url(r'^remove_item/$', views.remove_item, name='shoppingcart.views.remove_item'),
    url(r'^add/course/{}/$'.format(settings.COURSE_ID_PATTERN), views.add_course_to_cart, name='add_course_to_cart'),
    url(r'^register/redeem/(?P<registration_code>[0-9A-Za-z]+)/$',
        views.register_code_redemption, name='register_code_redemption'),
    url(r'^use_code/$', views.use_code, name='shoppingcart.views.use_code'),
    url(r'^update_user_cart/$', views.update_user_cart, name='shoppingcart.views.update_user_cart'),
    url(r'^reset_code_redemption/$', views.reset_code_redemption, name='shoppingcart.views.reset_code_redemption'),
    url(r'^billing_details/$', views.billing_details, name='billing_details'),
    url(r'^verify_cart/$', views.verify_cart, name='shoppingcart.views.verify_cart'),
]

if settings.FEATURES.get('ENABLE_PAYMENT_FAKE'):
    from shoppingcart.tests.payment_fake import PaymentFakeView
    urlpatterns += [
        url(r'^payment_fake', PaymentFakeView.as_view(), name='shoppingcart.views.payment_fake'),
    ]