def get_details(request): token = request.GET.get('token', None) if not token: token = request.session.get('hiicart_paypal_express_token') cart = _find_cart(request) gateway = PaypalExpressCheckoutGateway(cart) result = gateway.get_details(token) request.session.update(result.session_args) return HttpResponseRedirect(result.url)
def finalize(request): token = request.GET.get('token', None) if not token: token = request.session.get('hiicart_paypal_express_token') payerid = request.GET.get('PayerID', None) if not payerid: payerid = request.session.get('hiicart_paypal_express_payerid') cart = _find_cart(request) gateway = PaypalExpressCheckoutGateway(cart) result = gateway.finalize(token, payerid) return HttpResponseRedirect(result.url)
def test_update_cart_details(self): pp_params = { 'PAYMENTREQUEST_0_SHIPTONAME': 'Dmitri Shostakovich', 'PAYMENTREQUEST_0_SHIPTOSTREET': '321 Blast Off Lane', 'PAYMENTREQUEST_0_SHIPTOSTREET2': 'Apt 456', 'PAYMENTREQUEST_0_SHIPTOCITY': 'New Moscow', 'PAYMENTREQUEST_0_SHIPTOSTATE': 'AK', 'PAYMENTREQUEST_0_SHIPTOZIP': '90210', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE': 'US' } self.cart.hiicart_settings.update(STORE_SETTINGS) gateway = PaypalExpressCheckoutGateway(self.cart) gateway._update_cart_details(pp_params) self.assertEqual(self.cart.ship_first_name, 'Dmitri') self.assertEqual(self.cart.ship_last_name, 'Shostakovich') self.assertEqual(self.cart.ship_street1, '321 Blast Off Lane') self.assertEqual(self.cart.ship_street2, 'Apt 456') self.assertEqual(self.cart.ship_city, 'New Moscow') self.assertEqual(self.cart.ship_state, 'AK') self.assertEqual(self.cart.ship_postal_code, '90210') self.assertEqual(self.cart.ship_country, 'US')