示例#1
0
def get_transaction_data():
    # Get POST data
    try:
        data = json.loads(request.data)
    except JSONDecodeError:
        return abort(403)

    if 'api_secret' not in data or config_file['API_SECRET'] != data[
            'api_secret']:
        return abort(403)

    # Initilialize webpay
    configure_webpay()

    # ACK the transaction
    try:
        response = Transaction.commit(token=data['token'])
    except TransactionCommitError:
        # On error, return the status of the token
        try:
            response = Transaction.status(token=data['token'])
        except TransactionStatusError as e:
            # Invalid token
            return {"response_code": -1, "reason": e.message}

    return json.dumps(response, default=lambda x: x.__dict__)
示例#2
0
def webpay_plus_commit(request):
    token = request.POST.get("token_ws")
    print("commit for token_ws: {}".format(token))

    response = Transaction.commit(token=token)
    print("response: {}".format(response))

    data = {'token': token, 'response': response}
    return render(request, 'Webpay/commit.html', data)
示例#3
0
def webpay_plus_commit():
    token = request.form.get("token_ws")
    print("commit for token_ws: {}".format(token))

    response = Transaction.commit(token=token)
    print("response: {}".format(response))

    return render_template('webpay/plus/commit.html',
                           token=token,
                           response=response)
示例#4
0
文件: views.py 项目: zexza/2021Music
def webpay_plus_commit(request):
    token = request.POST.get("token_ws")
    response = Transaction.commit(token)
    return render(request, 'core/terminal.html', {"response":response,"token":token})
示例#5
0
 def commit(cls,
            token: str,
            options: Options = None) -> TransactionCommitResponse:
     return T.commit(token, cls.build_options(options))