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


Python Pool.serialize_and_create方法代码示例

本文整理汇总了Python中trytond.pool.Pool.serialize_and_create方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.serialize_and_create方法的具体用法?Python Pool.serialize_and_create怎么用?Python Pool.serialize_and_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trytond.pool.Pool的用法示例。


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

示例1: capture_beanstream

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def capture_beanstream(self, card_info=None):
        """
        Capture using beanstream for the specific transaction.

        :param card_info: An instance of CreditCardView
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        credit_card = None
        if card_info is not None:
            credit_card = CreditCard(
                card_info.number,
                str(card_info.expiry_year)[-2:],
                card_info.expiry_month,
                card_info.owner,
                card_info.csc,
            )

        client = self.gateway.get_beanstream_client()
        result = client.transaction.purchase(self, credit_card)

        # save the result to the logs
        TransactionLog.serialize_and_create(self, result)

        # TODO: Update the timestamp with the trnDate return value from
        # beanstream sent in the format '%m/%d/%Y %I:%M:%S %p' but the
        # timezone is not mentioned in the docs

        self.provider_reference = result['trnId']
        if result['trnApproved'] == '1':
            self.state = 'completed'
            self.safe_post()
        else:
            self.state = 'failed'
        self.save()
开发者ID:aroraumang,项目名称:payment-gateway-beanstream,代码行数:37,代码来源:transaction.py

示例2: authorize_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def authorize_authorize_net(self, card_info=None):
        """
        Authorize using authorize.net for the specific transaction.

        :param credit_card: An instance of CreditCardView
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        client = self.gateway.get_authorize_client()
        client._transaction.base_params['x_currency_code'] = self.currency.code

        if card_info:
            cc = CreditCard(
                card_info.number,
                card_info.expiry_year,
                card_info.expiry_month,
                card_info.csc,
                card_info.owner,
            )
            credit_card = client.card(cc)
        elif self.payment_profile:
            credit_card = client.saved_card(
                self.payment_profile.provider_reference
            )
        else:
            self.raise_user_error('no_card_or_profile')

        try:
            result = credit_card.auth(self.amount)
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:GauravButola,项目名称:payment-gateway-authorize-net,代码行数:35,代码来源:transaction.py

示例3: authorize_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def authorize_authorize_net(self, card_info=None):
        """
        Authorize using authorize.net for the specific transaction.
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        # Initialize authorize client
        self.gateway.get_authorize_client()

        auth_data = self.get_authorize_net_request_data()
        if card_info:
            billing_address = self.address.get_authorize_address(
                card_info.owner)
            shipping_address = {}
            if self.shipping_address:
                shipping_address = self.shipping_address.get_authorize_address(
                    card_info.owner)

            auth_data.update({
                'email': self.party.email,
                'credit_card': {
                    'card_number': card_info.number,
                    'card_code': str(card_info.csc),
                    'expiration_date': "%s/%s" % (
                        card_info.expiry_month, card_info.expiry_year
                    ),
                },
                'billing': billing_address,
                'shipping': shipping_address,
            })

        elif self.payment_profile:
            if self.shipping_address:
                if self.shipping_address.authorize_id:
                    address_id = self.shipping_address.authorize_id
                else:
                    address_id = self.shipping_address.send_to_authorize(
                        self.payment_profile.authorize_profile_id)
            else:
                if self.address.authorize_id:
                    address_id = self.address.authorize_id
                else:
                    address_id = self.address.send_to_authorize(
                        self.payment_profile.authorize_profile_id)
            auth_data.update({
                'customer_id': self.payment_profile.authorize_profile_id,
                'payment_id': self.payment_profile.provider_reference,
                'address_id': address_id,
            })
        else:
            self.raise_user_error('no_card_or_profile')

        try:
            result = authorize.Transaction.auth(auth_data)
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:priyankarani,项目名称:trytond-payment-gateway-authorize-net,代码行数:60,代码来源:transaction.py

示例4: update_beanstream

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def update_beanstream(self):
        """
        Update the status of the transaction from beanstream
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        client = self.gateway.get_beanstream_client()

        result = client.transaction.query(self.uuid)

        # save the result to the logs
        TransactionLog.serialize_and_create(self, result)

        print result
开发者ID:aroraumang,项目名称:payment-gateway-beanstream,代码行数:16,代码来源:transaction.py

示例5: refund_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def refund_authorize_net(self):
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        # Initialize authorize.net client
        self.gateway.get_authorize_client()

        try:
            result = authorize.Transaction.refund({
                'amount': self.amount,
                'last_four': self.last_four_digits,
                'transaction_id': self.origin.provider_reference,
            })
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:priyankarani,项目名称:trytond-payment-gateway-authorize-net,代码行数:18,代码来源:transaction.py

示例6: settle_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def settle_authorize_net(self):
        """
        Settles this transaction if it is a previous authorization.
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        client = self.gateway.get_authorize_client()
        client._transaction.base_params['x_currency_code'] = self.currency.code

        auth_net_transaction = client.transaction(self.provider_reference)
        try:
            result = auth_net_transaction.settle()
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:GauravButola,项目名称:payment-gateway-authorize-net,代码行数:18,代码来源:transaction.py

示例7: cancel_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def cancel_authorize_net(self):
        """
        Cancel this authorization or request
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        if self.state != 'authorized':
            self.raise_user_error('cancel_only_authorized')

        # Initialize authurize.net client
        self.gateway.get_authorize_client()

        # Try to void the transaction
        try:
            result = authorize.Transaction.void(self.provider_reference)
        except AuthorizeResponseError, exc:
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:priyankarani,项目名称:trytond-payment-gateway-authorize-net,代码行数:19,代码来源:transaction.py

示例8: settle_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def settle_authorize_net(self):
        """
        Settles this transaction if it is a previous authorization.
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        # Initialize authorize.net client
        self.gateway.get_authorize_client()

        try:
            result = authorize.Transaction.settle(
                self.provider_reference, self.amount
            )
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
开发者ID:priyankarani,项目名称:trytond-payment-gateway-authorize-net,代码行数:19,代码来源:transaction.py

示例9: refund_stripe

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def refund_stripe(self):
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        stripe.api_key = self.gateway.stripe_api_key

        try:
            refund = stripe.Refund.create(
                charge=self.origin.provider_reference,
                amount=int(self.amount * 100),  # Amount is in cents
            )
        except (
            stripe.error.InvalidRequestError,
            stripe.error.AuthenticationError, stripe.error.APIConnectionError,
            stripe.error.StripeError
        ), exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.json_body)
开发者ID:fulfilio,项目名称:trytond-payment-gateway-stripe,代码行数:20,代码来源:transaction.py

示例10: cancel_stripe

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def cancel_stripe(self):
        """
        Cancel this authorization or request
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        if self.state != 'authorized':
            self.raise_user_error('cancel_only_authorized')

        stripe.api_key = self.gateway.stripe_api_key

        try:
            charge = stripe.Charge.retrieve(self.provider_reference).refund()
        except (
            stripe.error.InvalidRequestError,
            stripe.error.AuthenticationError, stripe.error.APIConnectionError,
            stripe.error.StripeError
        ), exc:
            TransactionLog.serialize_and_create(self, exc.json_body)
开发者ID:usudaysingh,项目名称:trytond-payment-gateway-stripe,代码行数:21,代码来源:transaction.py

示例11: settle_stripe

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def settle_stripe(self):
        """
        Settle an authorized charge
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        assert self.state == 'authorized'

        stripe.api_key = self.gateway.stripe_api_key

        try:
            charge = stripe.Charge.retrieve(self.provider_reference)
            charge = charge.capture(amount=int(self.amount * 100))
        except (
            stripe.error.InvalidRequestError,
            stripe.error.AuthenticationError, stripe.error.APIConnectionError,
            stripe.error.StripeError
        ), exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.json_body)
开发者ID:fulfilio,项目名称:trytond-payment-gateway-stripe,代码行数:23,代码来源:transaction.py

示例12: authorize_stripe

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def authorize_stripe(self, card_info=None):
        """
        Authorize using stripe.
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        stripe.api_key = self.gateway.stripe_api_key

        charge_data = self.get_stripe_charge_data(card_info=card_info)
        charge_data['capture'] = False

        try:
            charge = stripe.Charge.create(**charge_data)
        except (
            stripe.error.CardError, stripe.error.InvalidRequestError,
            stripe.error.AuthenticationError, stripe.error.APIConnectionError,
            stripe.error.StripeError
        ), exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.json_body)
开发者ID:usudaysingh,项目名称:trytond-payment-gateway-stripe,代码行数:23,代码来源:transaction.py

示例13: cancel_authorize_net

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import serialize_and_create [as 别名]
    def cancel_authorize_net(self):
        """
        Cancel this authorization or request
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        if self.state != 'authorized':
            self.raise_user_error('cancel_only_authorized')

        client = self.gateway.get_authorize_client()
        client._transaction.base_params['x_currency_code'] = self.currency.code

        auth_net_transaction = client.transaction(self.provider_reference)

        # Try to void the transaction
        result = auth_net_transaction.void()

        # Mark the state as cancelled
        self.state = 'cancel'
        self.save()

        TransactionLog.serialize_and_create(self, result.full_response)
开发者ID:GauravButola,项目名称:payment-gateway-authorize-net,代码行数:24,代码来源:transaction.py


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