当前位置: 首页>>代码示例>>Python>>正文


Python payment_method.PaymentMethod类代码示例

本文整理汇总了Python中samurai.payment_method.PaymentMethod的典型用法代码示例。如果您正苦于以下问题:Python PaymentMethod类的具体用法?Python PaymentMethod怎么用?Python PaymentMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PaymentMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: store

 def store(self, credit_card, options=None):
     if isinstance(credit_card, CreditCard):
         if not self.validate_card(credit_card):
             raise InvalidCard("Invalid Card")
         payment_method = PaymentMethod.create(credit_card.number, 
                                                     credit_card.verification_value, 
                                                     credit_card.month, credit_card.year)
     else:
         # Using the token which has to be retained
         payment_method = PaymentMethod.find(credit_card)
         if payment_method.errors:
             transaction_was_unsuccessful.send(sender=self, 
                                               type="store",
                                               response=payment_method)
             return {'status': 'FAILURE', 'response': payment_method}
     response = payment_method.retain()
     if response.errors:
         transaction_was_unsuccessful.send(sender=self, 
                                           type="store",
                                           response=response)
         return {'status': 'FAILURE', 'response': response}
     transaction_was_successful.send(sender=self, 
                                     type="store",
                                     response=response)
     return {'status': 'SUCCESS', 'response': response}
开发者ID:atmb4u,项目名称:merchant,代码行数:25,代码来源:samurai_gateway.py

示例2: test_find_should_be_successful

 def test_find_should_be_successful(self):
   pm = PaymentMethod.create(**params)
   token = pm.payment_method_token
   pm = PaymentMethod.find(token)
   self.assertTrue(self.pm.is_sensitive_data_valid)
   self.assertTrue(self.pm.is_expiration_valid)
   self.assertEqual(self.pm.first_name, params['first_name'])
   self.assertEqual(self.pm.last_name, params['last_name'])
   self.assertEqual(self.pm.address_1, params['address_1'])
   self.assertEqual(self.pm.address_2, params['address_2'])
   self.assertEqual(self.pm.city, params['city'])
   self.assertEqual(self.pm.state, params['state'])
   self.assertEqual(self.pm.zip, params['zip'])
   self.assertEqual(self.pm.last_four_digits, params['card_number'][-4:])
   self.assertEqual(self.pm.expiry_month, int(params['expiry_month']))
   self.assertEqual(self.pm.expiry_year, int(params['expiry_year']))
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:16,代码来源:test_payment_method.py

示例3: default_payment_method

def default_payment_method(options={}):
  data = {
      'card_number': '4111111111111111',
      'sandbox' : True,
      'redirect_url' : 'http://test.host',
      'merchant_key' : config.merchant_key,
      'custom' : 'custom',
      'first_name' : 'FirstName',
      'last_name' : 'LastName',
      'address_1' : '1000 1st Av',
      'address_2' : '',
      'city' : 'Chicago',
      'state' : 'IL',
      'zip' : '10101',
      'card_number' : '4111111111111111',
      'cvv' : '111',
      'expiry_month' : '05',
      'expiry_year' : '2014',
    }

  data.update(options)
  return PaymentMethod.create(data.pop('card_number'),
                              data.pop('cvv'),
                              data.pop('expiry_month'),
                              data.pop('expiry_year'),
                              **data)
开发者ID:thoughtnirvana,项目名称:samurai-client-python,代码行数:26,代码来源:test_helper.py

示例4: test_should_fail_on_blank_card_number

 def test_should_fail_on_blank_card_number(self):
     params_tmp = params
     params_tmp['card_number'] =  ''
     pm = PaymentMethod.create(**params_tmp)
     self.assertFalse(pm.is_sensitive_data_valid)
     err = {'context': 'input.card_number', 'key': 'is_blank', 'subclass': 'error'}
     self.assertIn(err, pm.error_messages)
     self.assertIn('The card number was blank.', pm.errors['input.card_number'])
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:8,代码来源:test_payment_method.py

示例5: test_should_return_failed_checksum_card_number

 def test_should_return_failed_checksum_card_number(self):
     params_tmp = params
     params_tmp['card_number'] =  '4111-1111-1111-1234'
     pm = PaymentMethod.create(**params_tmp)
     self.assertFalse(pm.is_sensitive_data_valid)
     err = {'context': 'input.card_number', 'key': 'failed_checksum', 'subclass': 'error'}
     self.assertIn(err, pm.error_messages)
     self.assertIn('The card number was invalid.', pm.errors['input.card_number'])
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:8,代码来源:test_payment_method.py

示例6: unstore

 def unstore(self, identification, options=None):
     payment_method = PaymentMethod.find(identification)
     if payment_method.errors:
         return {"status": "FAILURE", "response": payment_method}
     payment_method = payment_method.redact()
     if payment_method.errors:
         return {"status": "FAILURE", "response": payment_method}
     return {"status": "SUCCESS", "response": payment_method}
开发者ID:SimpleTax,项目名称:merchant,代码行数:8,代码来源:samurai_gateway.py

示例7: test_should_return_too_short_cvv

 def test_should_return_too_short_cvv(self):
     params_tmp = params
     params_tmp['cvv'] =  '1'
     pm = PaymentMethod.create(**params_tmp)
     self.assertFalse(pm.is_sensitive_data_valid)
     err = {'context': 'input.cvv', 'key': 'too_short', 'subclass': 'error'}
     self.assertIn(err, pm.error_messages)
     self.assertIn('The CVV was too short.', pm.errors['input.cvv'])
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:8,代码来源:test_payment_method.py

示例8: test_should_return_is_blank_expiry_month

 def test_should_return_is_blank_expiry_month(self):
     params_tmp = params
     params_tmp['expiry_month'] =  ''
     pm = PaymentMethod.create(**params_tmp)
     self.assertFalse(pm.is_sensitive_data_valid)
     self.assertFalse(pm.is_expiration_valid)
     err = {'context': 'input.expiry_month', 'key': 'is_blank', 'subclass': 'error'}
     self.assertIn(err, pm.error_messages)
     self.assertIn('The expiration month was blank.', pm.errors['input.expiry_month'])
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:9,代码来源:test_payment_method.py

示例9: test_should_return_is_invalid_expiry_year

 def test_should_return_is_invalid_expiry_year(self):
     params_tmp = params
     params_tmp['expiry_year'] =  'abcd'
     pm = PaymentMethod.create(**params_tmp)
     self.assertFalse(pm.is_sensitive_data_valid)
     self.assertFalse(pm.is_expiration_valid)
     err = {'context': 'input.expiry_year', 'key': 'is_invalid', 'subclass': 'error'}
     self.assertIn(err, pm.error_messages)
     self.assertIn('The expiration year was invalid.', pm.errors['input.expiry_year'])
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:9,代码来源:test_payment_method.py

示例10: authorize

 def authorize(self, money, credit_card, options=None):
     if not self.validate_card(credit_card):
         raise InvalidCard("Invalid Card")
     try:
         from samurai.payment_method import PaymentMethod
         from samurai.processor import Processor
         pm = PaymentMethod.create(credit_card.number, credit_card.verification_value, credit_card.month, credit_card.year)
         payment_method_token = pm.payment_method_token
         response = Processor.authorize(payment_method_token, money)
     except Exception, error:
         return {'status': 'FAILURE', 'response': error}
开发者ID:hayyat,项目名称:merchant,代码行数:11,代码来源:samurai_gateway.py

示例11: authorize

 def authorize(self, money, credit_card, options=None):
     payment_method_token = credit_card
     if isinstance(credit_card, CreditCard):
         if not self.validate_card(credit_card):
             raise InvalidCard("Invalid Card")
         pm = PaymentMethod.create(credit_card.number, credit_card.verification_value, 
                                   credit_card.month, credit_card.year)
         payment_method_token = pm.payment_method_token
     response = Processor.authorize(payment_method_token, money)
     if response.errors:
         return {'status': 'FAILURE', 'response': response}
     return {'status': 'SUCCESS', 'response': response}
开发者ID:SimpleTax,项目名称:merchant,代码行数:12,代码来源:samurai_gateway.py

示例12: purchase

 def purchase(self, money, credit_card):
     # Cases where token is directly sent for e.g. from Samurai.js
     payment_method_token = credit_card
     if isinstance(credit_card, CreditCard):
         if not self.validate_card(credit_card):
             raise InvalidCard("Invalid Card")
         pm = PaymentMethod.create(credit_card.number, credit_card.verification_value,
                                   credit_card.month, credit_card.year)
         payment_method_token = pm.payment_method_token
     response = Processor.purchase(payment_method_token, money)
     if response.errors:
         return {'status': 'FAILURE', 'response': response}
     return {'status': 'SUCCESS', 'response': response}
开发者ID:SimpleTax,项目名称:merchant,代码行数:13,代码来源:samurai_gateway.py

示例13: default_payment_method

def default_payment_method(options={}):
  data = {
      'card_number': '4111111111111111',
      'cvv': '111',
      'expiry_month': '07',
      'expiry_year': '14',
      'first_name': 'first_name',
      'last_name': 'last_name',
      'sandbox': True
  }
  data.update(options)
  return PaymentMethod.create(data.pop('card_number'),
                              data.pop('cvv'),
                              data.pop('expiry_month'),
                              data.pop('expiry_year'),
                              **data)
开发者ID:edulender,项目名称:samurai-client-python,代码行数:16,代码来源:test_helper.py

示例14: purchase

def purchase(request):
    if request.method == "POST":
        data = request.POST
        token = PaymentMethod.create(data.get('card_number'), data.get('cvv'), data.get('expiry_month'),
                                     data.get('expiry_year'), first_name=data.get('first_name'),
                                     last_name=data.get('last_name'))
        trans = Processor.purchase(token.payment_method_token, 10)
        if trans.errors:
            errors = parse_error(trans.errors)
            for err in errors:
                messages.error(request, err, fail_silently=True)
            return redirect('/server_to_server/payment_form')
        else:
            messages.success(request, 'Purchase Successful.', fail_silently=True)
            return render_to_response('/server_to_server/receipt.html')
    else:
        return redirect('/server_to_server/payment_form')
开发者ID:FeeFighters,项目名称:samurai-example-python,代码行数:17,代码来源:views.py

示例15: test_update_should_be_successful_preserving_sensitive_data

 def test_update_should_be_successful_preserving_sensitive_data(self):
     params_tmp = paramsx
     params_tmp['card_number'] = '****************'
     params_tmp['cvv'] = '***'
     pm = PaymentMethod.create(**params)
     pm = pm.update(**paramsx)
     self.assertTrue(pm.is_expiration_valid)
     self.assertEqual(pm.first_name, params_tmp['first_name'])
     self.assertEqual(pm.last_name, params_tmp['last_name'])
     self.assertEqual(pm.address_1, params_tmp['address_1'])
     self.assertEqual(pm.address_2, params_tmp['address_2'])
     self.assertEqual(pm.city, params_tmp['city'])
     self.assertEqual(pm.state, params_tmp['state'])
     self.assertEqual(pm.zip, params_tmp['zip'])
     self.assertEqual(pm.last_four_digits, '1111')
     self.assertEqual(pm.expiry_month, int(params_tmp['expiry_month']))
     self.assertEqual(pm.expiry_year, int(params_tmp['expiry_year']))
开发者ID:FeeFighters,项目名称:samurai-client-python,代码行数:17,代码来源:test_payment_method.py


注:本文中的samurai.payment_method.PaymentMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。