當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。