Exemplo n.º 1
0
    def process_payment(self, project, user):
        """
        Process the payment with given the credit card information.

        :project: revolv.project.models.Project
        :user: the User making the payment
        :return:
        """
        if not self.is_valid():
            raise Exception('Cannot process invalid form')

        # Remove the amount field for the tuple
        cc_dict = deepcopy(self.cleaned_data)
        del cc_dict['amount']

        credit_card = CreditCard(**cc_dict)

        instrument = PayPalCreditCardInstrument(credit_card)

        # TODO: error handling
        # Make the payment
        payment = PaymentService.create_payment(
            user.revolvuserprofile, user.revolvuserprofile,
            self.cleaned_data.get('amount'), project, instrument)

        return payment
Exemplo n.º 2
0
 def test_create_credit_card(self):
     """Verify that we can create a credit card."""
     CreditCard('visa', '1234123412341234', '01', '2018', '000', 'John', 'Smith')
Exemplo n.º 3
0
 def setUp(self):
     self.credit_card = CreditCard('visa', '4032038705456659', '10', '2019', '000', 'John', 'Smith')
Exemplo n.º 4
0
 def test_check_converts_to_dict(self):
     """Verify that the credit card converts to dict."""
     c = CreditCard('visa', '1234123412341234', '01', '2018', '000', 'John', 'Smith')
     self.assertIsNotNone(c.to_dict())
Exemplo n.º 5
0
 def test_check_cannot_change_credit_card(self):
     """Verify that we cannot change the credit card once manipulated."""
     c = CreditCard('visa', '1234123412341234', '01', '2018', '000', 'John', 'Smith')
     with self.assertRaises(AttributeError):
         c.expire_year = 2