Ignore:
Timestamp:
12 Jan 2015, 14:33:22 (10 years ago)
Author:
uli
Message:

Offer a possibility to store credit card data.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/payments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/paypal.py

    r12326 r12453  
    11391139        return site['creditcards'].get(payer_id, None)
    11401140
     1141    def store_credit_card(self, paypal_credit_card):
     1142        """Store `paypal_credit_card` in vault.
     1143
     1144        Returns a credit card token in case of success.
     1145
     1146        `paypal_credit_card` must provide `ICreditCard`. The credit
     1147        card created is stored at PayPal and gets a token stored
     1148        locally.
     1149
     1150        If no `creditcards` are available in local site, we create a
     1151        container.
     1152        """
     1153        site = grok.getSite()
     1154        if not 'creditcards' in site:
     1155            site['creditcards'] = grok.Container()
     1156        return
     1157
    11411158    def create_payment(self, payer, payment_item,  payee=None):
    11421159        if not IPayer.providedBy(payer):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_paypal.py

    r12326 r12453  
    11001100        return site
    11011101
     1102    def get_credit_card(self):
     1103        # get a valid credit card
     1104        credit_card = CreditCard(
     1105            credit_card_type=u"visa",
     1106            payer_id=u"PAYER_0123456789012345678901",
     1107            number=u"4417119669820331",
     1108            expire_month=11,
     1109            expire_year=2018,
     1110            cvv2=u"874",
     1111            first_name=u"Joe",
     1112            last_name=u"Shopper",
     1113            )
     1114        return credit_card
     1115
    11021116    def test_iface(self):
    11031117        # we fullfill all interface contracts
     
    11271141    def test_get_credit_card(self):
    11281142        # we can get a credit card, if one was stored
    1129         class MyCard(grok.Model):
     1143        class MyCard(object):
    11301144            myid = 'CARD1'
    11311145
     
    11361150        site['creditcards'] = grok.Container()
    11371151        card = MyCard()
    1138         card.myid = 'CHANGED ID'
     1152        card.myid = 'CHANGED CARD ID'
    11391153        site['creditcards'][u'CARD1'] = card
    11401154        service = PayPalCreditCardService()
    11411155        assert service.get_credit_card(u'CARD1') == card
    11421156        assert service.get_credit_card(u'CARD2') is None
     1157
     1158    def test_store_credit_card_no_credcard_container(self):
     1159        # a missing creditcards container is created on-the-fly
     1160        site = self.create_site()
     1161        assert 'creditcards' not in site
     1162        service = PayPalCreditCardService()
     1163        credit_card = self.get_credit_card()
     1164        service.store_credit_card(credit_card)
     1165        assert 'creditcards' in site
    11431166
    11441167    def test_create_payment_no_credictard(self):
Note: See TracChangeset for help on using the changeset viewer.