def Charge(self, customer_id, amount_cents): logging.error('USING FAKE STRIPE') if customer_id == 'doomed_customer': raise handlers.PaymentError( 'You have no chance to survive make your time') logging.error('CHARGED CUSTOMER %s %d cents', customer_id, amount_cents) return 'fake_charge_1234'
def expectStripeDeclined(self): self.stripe.CreateCustomer( email=self.pledge['email'], card_token=self.pledge['payment']['STRIPE']['token']).AndReturn( env.FakeStripe().CreateCustomer( '*****@*****.**', self.pledge['payment']['STRIPE']['token'])) self.stripe.Charge('doomed_customer', self.pledge['amountCents']) \ .AndRaise(handlers.PaymentError('You got no money'))
def Charge(self, customer_id, amount_cents): stripe.api_key = self.stripe_private_key try: charge = stripe.Charge.create( amount=amount_cents, currency='usd', customer=customer_id, statement_descriptor="Lessig Equal Citizens" ) except stripe.CardError, e: logging.info('Stripe returned error for customer: %s ' % customer_id) raise handlers.PaymentError(str(e))