當前位置: 首頁>>代碼示例>>Python>>正文


Python Processor.purchase方法代碼示例

本文整理匯總了Python中samurai.processor.Processor.purchase方法的典型用法代碼示例。如果您正苦於以下問題:Python Processor.purchase方法的具體用法?Python Processor.purchase怎麽用?Python Processor.purchase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在samurai.processor.Processor的用法示例。


在下文中一共展示了Processor.purchase方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cvv_should_return_processor_cvv_result_code_N

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_cvv_should_return_processor_cvv_result_code_N(self):
     token = test_helper.default_payment_method({'cvv':'222'}).payment_method_token
     purchase = Processor.purchase(token,
                                   1.00,
                                   billing_reference=self.rand)
     self.assertTrue(purchase.success)
     self.assertEqual(purchase.processor_response['cvv_result_code'], 'N')
開發者ID:thoughtnirvana,項目名稱:samurai-client-python,代碼行數:9,代碼來源:test_processor.py

示例2: test_purchase_should_return_input_amount_invalid

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_should_return_input_amount_invalid(self):
     token = self.pm.payment_method_token
     purchase = Processor.purchase(token,
                                   1.10,
                                   billing_reference=self.rand)
     self.assertFalse(purchase.success)
     err = {'context': 'input.amount', 'key': 'invalid', 'subclass': 'error'}
     self.assertIn(err, purchase.error_messages)
     self.assertIn('The transaction amount was invalid.', purchase.errors['input.amount'])
開發者ID:thoughtnirvana,項目名稱:samurai-client-python,代碼行數:11,代碼來源:test_processor.py

示例3: test_should_return_processor_avs_result_code_N

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_should_return_processor_avs_result_code_N(self):
     token = test_helper.default_payment_method({'address_1':'123 Main St',
                                                'address_2':'',
                                                'zip':'60610'}).payment_method_token
     purchase = Processor.purchase(token,
                                   1.00,
                                   billing_reference=self.rand)
     self.assertTrue(purchase.success)
     self.assertEqual(purchase.processor_response['avs_result_code'], 'N')
開發者ID:thoughtnirvana,項目名稱:samurai-client-python,代碼行數:11,代碼來源:test_processor.py

示例4: test_purchase_should_return_processor_transaction_declined

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_should_return_processor_transaction_declined(self):
     token = self.pm.payment_method_token
     purchase = Processor.purchase(token,
                                   1.02,
                                   billing_reference=self.rand)
     self.assertFalse(purchase.success)
     err = {'context': 'processor.transaction', 'key': 'declined', 'subclass': 'error'}
     self.assertIn(err, purchase.error_messages)
     self.assertIn('The card was declined.' , purchase.errors['processor.transaction'])
開發者ID:thoughtnirvana,項目名稱:samurai-client-python,代碼行數:11,代碼來源:test_processor.py

示例5: purchase

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
def purchase(request):
    token = request.GET.get('payment_method_token', None)
    trans = Processor.purchase(token, 10)
    if trans.errors:
        errors = parse_error(trans.errors)
        for err in errors:
            messages.error(request, err, fail_silently=True)
        return redirect('/transparent_redirect/payment_form')
    else:
        messages.success(request, 'Purchase Successful.', fail_silently=True)
        return render_to_response('/transparent_redirect/receipt.html')
開發者ID:thoughtnirvana,項目名稱:samurai-example-python,代碼行數:13,代碼來源:views.py

示例6: purchase

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
def purchase(request):
    if request.method == 'POST':
        token = request.POST.get('payment_method_token', None)
        trans = Processor.purchase(token, 10)
        if trans.errors:
            success=False
        else:
            success=True
        return_data = simplejson.dumps({'transaction':{'success':success}})
        return HttpResponse(return_data)
    else:
        return redirect('/samurai_js/payment_form')
開發者ID:FeeFighters,項目名稱:samurai-example-python,代碼行數:14,代碼來源:views.py

示例7: capture

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def capture(self, amount, credit_card=None, billing_info=None, shipping_info=None):
     # set up the card for charging, obviously
     card_token = self.charge_setup(credit_card, billing_info)
     # start the timer
     start = time.time()
     # send it over for processing
     response = Processor.purchase(card_token, amount)
     # measure time
     end = time.time() # done timing it
     response_time = '%0.2f' % (end-start)
     # return parsed response
     return self.parse(response, response_time)
開發者ID:AdamJacobMuller,項目名稱:Paython,代碼行數:14,代碼來源:samurai_ff.py

示例8: purchase

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def purchase(self, money, credit_card):
     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.purchase(payment_method_token, money)
     except Exception, error:
         return {'status': 'FAILURE', 'response': error}
開發者ID:hayyat,項目名稱:merchant,代碼行數:14,代碼來源:samurai_gateway.py

示例9: purchase

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 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,代碼行數:15,代碼來源:samurai_gateway.py

示例10: test_purchase_should_be_successful

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_should_be_successful(self):
     options = {'description':'description',
                'descriptor_name':'descriptor_name',
                'descriptor_phone':'descriptor_phone',
                'custom':'custom',
                'billing_reference':'ABC123%s' % self.rand,
                'customer_reference':'Customer (123)'}
     token = self.pm.payment_method_token
     purchase = Processor.purchase(token, 10.0, None, **options)
     self.assertTrue(purchase.success)
     self.assertEquals(purchase.error_messages, [])
     self.assertEqual(purchase.description, 'description')
     self.assertEqual(purchase.descriptor_name, 'descriptor_name')
     self.assertEqual(purchase.descriptor_phone, 'descriptor_phone')
     self.assertEqual(purchase.custom, 'custom')
     self.assertEqual(purchase.billing_reference, 'ABC123%s' % self.rand)
     self.assertEqual(purchase.customer_reference, 'Customer (123)')
開發者ID:thoughtnirvana,項目名稱:samurai-client-python,代碼行數:19,代碼來源:test_processor.py

示例11: test_purchase_should_return_invalid_sandbox_card_error

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_should_return_invalid_sandbox_card_error(self):
     data = {
         'custom' : '',
         'first_name' : '',
         'last_name' : '',
         'address_1' : '',
         'address_2' : '',
         'city' : '',
         'state' : '',
         'zip' : '10101',
         'card_number' : '5256486068715680',
         'cvv' : '111',
         'expiry_month' : '05',
         'expiry_year' : '2014',
       }
     token = test_helper.default_payment_method(data).payment_method_token
     purchase = Processor.purchase(token, 1.00)
     self.assertIn({'context': 'system.general', 'key': 'default', 'subclass': 'error', 'text': 'Invalid Sandbox Card Number. For more information, see: https://samurai.feefighters.com/developers/sandbox'}, purchase.error_messages)
開發者ID:FeeFighters,項目名稱:samurai-client-python,代碼行數:20,代碼來源:test_processor.py

示例12: test_purchase_should_return_payment_method_errors_on_blank_pm

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_should_return_payment_method_errors_on_blank_pm(self):
     data = {
         'custom' : '',
         'first_name' : '',
         'last_name' : '',
         'address_1' : '',
         'address_2' : '',
         'city' : '',
         'state' : '',
         'zip' : '',
         'card_number' : '',
         'cvv' : '',
         'expiry_month' : '05',
         'expiry_year' : '2014',
       }
     token = test_helper.default_payment_method(data).payment_method_token
     purchase = Processor.purchase(token, 1.00)
     self.assertFalse(purchase.success)
     self.assertIn({'context': 'input.card_number', 'key': 'not_numeric', 'subclass': 'error'}, purchase.error_messages)
     self.assertIn({'context': 'input.card_number', 'key': 'too_short', 'subclass': 'error'}, purchase.error_messages)
     self.assertIn({'context': 'input.card_number', 'key': 'is_blank', 'subclass': 'error'}, purchase.error_messages)
開發者ID:FeeFighters,項目名稱:samurai-client-python,代碼行數:23,代碼來源:test_processor.py

示例13: test_purchase_partial_reverse

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_partial_reverse(self):
     purchase = Processor.purchase(self.pm.payment_method_token, 10.0)      
     trans = purchase.reverse(5.0)
     self.assertTrue(trans.success)
     self.assertEquals(trans.errors, [])
     self.assertEquals(trans.amount, '5.0')
開發者ID:edulender,項目名稱:samurai-client-python,代碼行數:8,代碼來源:test_transaction.py

示例14: test_purchase_failure

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase_failure(self):
     token = self.pm.payment_method_token
     trans = Processor.purchase(token, 10.02)
     errors = [{'context': 'processor.transaction', 'key': 'declined', 'subclass': 'error'}]
     self.assertEquals(trans.errors, errors)
開發者ID:edulender,項目名稱:samurai-client-python,代碼行數:7,代碼來源:test_processor.py

示例15: test_purchase

# 需要導入模塊: from samurai.processor import Processor [as 別名]
# 或者: from samurai.processor.Processor import purchase [as 別名]
 def test_purchase(self):
     token = self.pm.payment_method_token
     trans = Processor.purchase(token, 10.0)
     self.assertTrue(trans.success)
     self.assertEquals(trans.errors, [])
開發者ID:edulender,項目名稱:samurai-client-python,代碼行數:7,代碼來源:test_processor.py


注:本文中的samurai.processor.Processor.purchase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。