<commit_before>"""Paypal2 -- Website Payments Pro Gateway

Please note that currently only Express Checkout is implemented.
Direct Payment can be supported in the future, but requires reworking
of core HiiCart models so they can use credit card numbers as required.
"""

import urllib

from hiicart.gateway.base import PaymentGatewayBase, CancelResult, SubmitResult
from hiicart.gateway.paypal2 import api
from hiicart.gateway.paypal2.errors import Paypal2GatewayError
from hiicart.gateway.paypal2.settings import SETTINGS as default_settings

LIVE_REDIRECT = "https://www.paypal.com/cgi-bin/webscr"
SANDBOX_REDIRECT = "https://www.sandbox.paypal.com/cgi-bin/webscr"

class Paypal2Gateway(PaymentGatewayBase):
    """Payment Gateway for Paypal Website Payments Pro."""

    def __init__(self):
        super(Paypal2Gateway, self).__init__("paypal2", default_settings)
        self._require_settings(["PASSWORD", "SIGNATURE", "USERID", "SELLER_EMAIL"])

    def _is_valid(self):
        """Return True if gateway is valid."""
        # TODO: Query Paypal to validate credentials
        return True

    def cancel_recurring(self, cart):
        """Cancel recurring lineitem."""
        pass

    def charge_recurring(self, cart, grace_period=None):
        """Charge a cart's recurring item, if necessary."""
        pass

    def sanitize_clone(self, cart):
        """Nothing to do here..."""
        return cart

    def submit(self, cart, collect_address=False):<commit_msg>More TODO notes.<commit_after>"""Paypal2 -- Website Payments Pro Gateway

Please note that currently only Express Checkout is implemented.
Direct Payment can be supported in the future, but requires reworking
of core HiiCart models so they can use credit card numbers as required.
"""

import urllib

from hiicart.gateway.base import PaymentGatewayBase, CancelResult, SubmitResult
from hiicart.gateway.paypal2 import api
from hiicart.gateway.paypal2.errors import Paypal2GatewayError
from hiicart.gateway.paypal2.settings import SETTINGS as default_settings

LIVE_REDIRECT = "https://www.paypal.com/cgi-bin/webscr"
SANDBOX_REDIRECT = "https://www.sandbox.paypal.com/cgi-bin/webscr"

class Paypal2Gateway(PaymentGatewayBase):
    """Payment Gateway for Paypal Website Payments Pro."""

    def __init__(self):
        super(Paypal2Gateway, self).__init__("paypal2", default_settings)
        self._require_settings(["PASSWORD", "SIGNATURE", "USERID", "SELLER_EMAIL"])

    def _is_valid(self):
        """Return True if gateway is valid."""
        # TODO: Query Paypal to validate credentials
        return True

    def cancel_recurring(self, cart):
        """Cancel recurring lineitem."""
        # TODO: Implement
        pass

    def charge_recurring(self, cart, grace_period=None):
        """Charge a cart's recurring item, if necessary."""
        # TODO: Investigate if this is necessary. I think Paypal still
        #       takes care of the recurring charges.
        pass

    def sanitize_clone(self, cart):
        """Nothing to do here..."""
        return cart

    def submit(self, cart, collect_address=False):
{'fraction_non_alphanumeric': 0.09520746220649727, 'fraction_numerical': 0.005146349308459312, 'mean_word_length': 3.7480916030534353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7639976', 'n_tokens_mistral': 914, 'n_tokens_neox': 896, 'n_words': 279}