示例#1
0
def _try_notify_client(tx, refund_record):
    from api_x.utils.notify import sign_and_notify_client
    url = refund_record.client_notify_url
    if not url:
        return

    params = None
    if tx.state == RefundTxState.SUCCESS:
        params = {
            'code': 0,
            'order_id': refund_record.order_id,
            'amount': refund_record.amount
        }
    elif tx.state == RefundTxState.FAILED:
        params = {
            'code': 1,
            'order_id': refund_record.order_id,
            'amount': refund_record.amount
        }

    # notify
    sign_and_notify_client(url,
                           params,
                           tx.channel_name,
                           task=tasks.refund_notify)
示例#2
0
文件: __init__.py 项目: webee/pay
def _try_notify_client(tx, payment_record):
    from api_x.utils.notify import sign_and_notify_client

    url = payment_record.client_notify_url
    if not url:
        return

    user_mapping = get_user_map_by_account_user_id(payment_record.payer_id)
    user_id = user_mapping.user_id

    params = None
    if tx.state in [PaymentTxState.SECURED, PaymentTxState.SUCCESS]:
        params = {
            'code': 0,
            'user_id': user_id,
            'sn': payment_record.sn,
            'order_id': payment_record.order_id,
            'amount': payment_record.amount
        }
    elif tx.state == PaymentTxState.FAILED:
        params = {
            'code': 1,
            'user_id': user_id,
            'sn': payment_record.sn,
            'order_id': payment_record.order_id,
            'amount': payment_record.amount
        }

    # notify
    sign_and_notify_client(url, params, tx.channel_name, task=tasks.pay_notify)
示例#3
0
def _try_notify_client(tx, withdraw_record):
    from api_x.utils.notify import sign_and_notify_client
    url = withdraw_record.client_notify_url
    if not url:
        return

    user_mapping = get_user_map_by_account_user_id(
        withdraw_record.from_user_id)
    user_id = user_mapping.user_id
    params = None
    if tx.state == WithdrawTxState.SUCCESS:
        params = {
            'code': 0,
            'user_id': user_id,
            'sn': tx.sn,
            'amount': withdraw_record.amount,
            'actual_amount': withdraw_record.actual_amount,
            'fee': withdraw_record.fee
        }
    elif tx.state == WithdrawTxState.FAILED:
        params = {
            'code': 1,
            'user_id': user_id,
            'sn': tx.sn,
            'amount': withdraw_record.amount,
            'actual_amount': withdraw_record.actual_amount,
            'fee': withdraw_record.fee
        }

    # notify
    sign_and_notify_client(url,
                           params,
                           tx.channel_name,
                           task=tasks.withdraw_notify)
示例#4
0
文件: __init__.py 项目: webee/pay
def _try_notify_client(tx, cheque_record):
    from api_x.utils.notify import sign_and_notify_client
    url = cheque_record.client_notify_url
    if not url:
        return

    params = None
    if tx.state == ChequeTxState.CASHED:
        user_mapping = get_user_map_by_account_user_id(cheque_record.from_id)
        user_id = user_mapping.user_id
        params = {
            'code': 0,
            'sn': tx.sn,
            'user_id': user_id,
            'amount': cheque_record.amount,
            'order_id': tx.order_id
        }

    # notify
    sign_and_notify_client(url,
                           params,
                           tx.channel_name,
                           task=tasks.cash_cheque_notify)