本文整理汇总了Python中trytond.pool.Pool.capture方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.capture方法的具体用法?Python Pool.capture怎么用?Python Pool.capture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.capture方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _pay_using_profile
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def _pay_using_profile(self, payment_profile, amount):
'''
Complete the Checkout using a payment_profile. Only available to the
registered users of the website.
:param payment_profile: Active record of payment profile
:param amount: Decimal amount to charge the card for
'''
PaymentTransaction = Pool().get('payment_gateway.transaction')
if payment_profile.party != self.party:
self.raise_user_error(
"Payment profile'd owner is %s, but the customer is %s" % (
payment_profile.party.name,
self.party.name,
)
)
payment_transaction = PaymentTransaction(
party=self.party,
address=self.invoice_address,
payment_profile=payment_profile,
amount=amount,
currency=self.currency,
gateway=payment_profile.gateway,
sale=self,
)
payment_transaction.save()
PaymentTransaction.capture([payment_transaction])
示例2: process_pending_payments
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def process_pending_payments(self):
"""Process waiting payments for corresponding sale.
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
if self.payment_processing_state == "waiting_for_auth":
for payment in self.sorted_payments:
payment.authorize()
self.payment_processing_state = None
elif self.payment_processing_state == "waiting_for_capture":
# Transactions waiting for capture.
txns = PaymentTransaction.search([
('sale_payment.sale', '=', self.id),
])
# Settle authorized transactions
PaymentTransaction.settle(filter(
lambda txn: txn.state == 'authorized', txns
))
# Capture other transactions
PaymentTransaction.capture(filter(
lambda txn: txn.state == "draft", txns
))
self.payment_processing_state = None
else:
# Weird! Why was I called if there is nothing to do
return
self.save()
示例3: capture
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def capture(self):
"""
Captures the given amount from this transaction
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
PaymentTransaction.capture(self.payment_transactions)
示例4: capture
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def capture(self):
"""
Captures the given amount from this transaction
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
PaymentTransaction.capture(
filter(
lambda txn: txn.state in ('draft', 'authorized', 'in-progress'),
self.payment_transactions
)
)
示例5: process
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def process(cls, sale, payment_method_id):
"""Begins the payment processing.
Returns a response object if a redirect to third party website is
required, else processes the payment.
:param sale: Browse Record of the Sale
:param payment_method_id: ID of payment method
"""
Sale = Pool().get('sale.sale')
try_to_authorize = (
request.nereid_website.payment_mode == 'auth_if_available'
)
payment_method = cls(payment_method_id)
allowed_gateways = cls._get_available_gateways(
sale.invoice_address.country
)
if payment_method not in allowed_gateways:
current_app.logger.error("Payment method %s is not valid" %
payment_method.name)
abort(403)
payment_method_obj = Pool().get(payment_method.model.model)
Sale.write([sale], {'payment_method': payment_method.id})
if try_to_authorize and hasattr(payment_method_obj, 'authorize'):
return payment_method_obj.authorize(sale)
else:
return payment_method_obj.capture(sale)
示例6: transition_pay
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def transition_pay(self):
"""
Creates a new payment transaction and pay invoice with it
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
profile = self.start.payment_profile
if self.start.method == 'credit_card' and (
not self.start.use_existing_card
):
profile = self.create_payment_profile()
transaction = self.create_payment_transaction(profile=profile)
transaction.save()
# Capture Transaction
PaymentTransaction.capture([transaction])
# Pay invoice using above captured transaction
self.start.invoice.pay_using_transaction(transaction)
return 'end'
示例7: transition_redeem
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def transition_redeem(self):
"""
Transition where PaymentTransaction is created and associated
with current gift card.
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
Date = Pool().get('ir.date')
transaction, = PaymentTransaction.create([{
'description': self.start.description,
'date': Date.today(),
'party': self.start.party.id,
'address': self.start.address,
'amount': self.start.amount,
'currency': self.start.currency.id,
'gateway': self.start.gateway.id,
'gift_card': self.start.gift_card.id,
}])
PaymentTransaction.capture([transaction])
return 'done'
示例8: transition_pay
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import capture [as 别名]
def transition_pay(self):
"""
Creates a new payment transaction and pay invoice with it
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
if self.start.transaction_type == 'charge':
profile = self.start.payment_profile
if self.start.method == 'credit_card' and (
not self.start.use_existing_card
):
profile = self.create_payment_profile()
transaction = self.create_payment_transaction(profile=profile)
transaction.save()
# Capture Transaction
PaymentTransaction.capture([transaction])
if transaction.state in ('completed', 'posted'):
# Pay invoice using above captured transaction
self.start.invoice.pay_using_transaction(transaction)
else:
self.failed.message = \
"Payment capture failed, refer transaction logs"
return 'failed'
elif self.start.transaction_type == 'refund':
refund_transaction = self.start.transaction.create_refund(
self.start.amount
)
PaymentTransaction.refund([refund_transaction])
if refund_transaction.state in ('completed', 'posted'):
self.start.invoice.pay_using_transaction(refund_transaction)
else:
self.failed.message = \
"Payment refund failed, refer transaction logs"
return 'failed'
return 'end'