示例#1
0
def lambda_handler(event, context):
    """
    LINE Pay API(confirm)の処理結果を返す
    Parameters
    ----------
    event : dict
        POST時に渡されたパラメータ
    context : dict
        コンテキスト内容。
    Returns
    -------
    response : dict
        LINE Pay APIの通信結果
    """
    logger.info(event)
    if event['body'] is None:
        error_msg_display = common_const.const.MSG_ERROR_NOPARAM
        return utils.create_error_response(error_msg_display, 400)
    req_body = json.loads(event['body'])

    # パラメータバリデーションチェック
    param_checker = TableOrderParamCheck(req_body)

    if error_msg := param_checker.check_api_payment_confirm():
        error_msg_disp = ('\n').join(error_msg)
        logger.error(error_msg_disp)
        return utils.create_error_response(error_msg_disp, status=400)  # noqa: E501
def lambda_handler(event, context):
    """
    該当の会計情報を会計済みにする
    Parameters
    ----------
    event : dict
        POST時に渡されたパラメータ
    context : dict
        コンテキスト内容
    Returns
    -------
    なし(共通項目のみ)
    """
    # パラメータログ
    logger.info(event)
    if event['body'] is None:
        error_msg_display = common_const.const.MSG_ERROR_NOPARAM
        return utils.create_error_response(error_msg_display, 400)
    req_body = json.loads(event['body'])

    # パラメータバリデーションチェック
    param_checker = TableOrderParamCheck(req_body)

    if error_msg := param_checker.check_api_payment_confirm_nolinepay():
        error_msg_disp = ('\n').join(error_msg)
        logger.error(error_msg_disp)
        return utils.create_error_response(error_msg_disp,
                                           status=400)  # noqa: E501
def lambda_handler(event, context):
    """
    会計IDをもとに注文情報を取得し、返却する
    Parameters
    ----------
    event : dict
        フロントより渡されたパラメータ
    context : dict
        コンテキスト内容。
    Returns
    -------
    payment_info : dict
        注文情報
    """
    # パラメータログ
    logger.info(event)
    if event['queryStringParameters'] is None:
        error_msg_display = common_const.const.MSG_ERROR_NOPARAM
        return utils.create_error_response(error_msg_display, 400)

    req_params = event['queryStringParameters']
    param_checker = TableOrderParamCheck(req_params)

    if error_msg := param_checker.check_api_order_info():
        error_msg_disp = ('\n').join(error_msg)
        logger.error(error_msg_disp)
        return utils.create_error_response(error_msg_disp, status=400)  # noqa: E501
示例#4
0
def lambda_handler(event, context):
    """
    商品情報を返す
    Parameters
    ----------
    event : dict
        フロントより渡されたパラメータ
    context : dict
        コンテキスト内容
    Returns
    -------
    items : dict
        商品情報
    """
    # パラメータログ
    logger.info(event)

    try:
        items = get_item_list(event['queryStringParameters'])
    except Exception as e:
        logger.error('Occur Exception: %s', e)
        return utils.create_error_response('ERROR')

    return utils.create_success_response(
        json.dumps(items, default=utils.decimal_to_int, ensure_ascii=False))
def lambda_handler(event, context):
    """
    商品カテゴリ情報を返す
    Parameters
    ----------
    event : dict
        フロントより渡されたパラメータ
    context : dict
        コンテキスト内容。
    Returns
    -------
    categories : dict
        商品カテゴリ一覧情報
    """
    # パラメータログ
    logger.info(event)
    try:
        categories = get_category()
    except Exception as e:
        logger.error('Occur Exception: %s', e)
        return utils.create_error_response('ERROR')

    return utils.create_success_response(
        json.dumps(categories, default=utils.decimal_to_int,
                   ensure_ascii=False))
示例#6
0
def lambda_handler(event, context):
    """
    User IDをもとに会計IDを取得し、返却する
    Parameters
    ----------
    event : dict
        フロントより渡されたパラメータ
    context : dict
        コンテキスト内容。
    Returns
    -------
    payment_info : dict
        会計ID情報
    """
    # パラメータログ
    logger.info(event)
    if event['queryStringParameters'] is None:
        error_msg_display = common_const.const.MSG_ERROR_NOPARAM
        return utils.create_error_response(error_msg_display, 400)

    req_params = event['queryStringParameters']

    # ユーザーID取得
    try:
        user_profile = line.get_profile(req_params['idToken'], LIFF_CHANNEL_ID)
        if 'error' in user_profile and 'expired' in user_profile['error_description']:  # noqa 501
            return utils.create_error_response('Forbidden', 403)
        else:
            req_params['userId'] = user_profile['sub']
    except Exception:
        logger.exception('不正なIDトークンが使用されています')
        return utils.create_error_response('Error')

    try:
        payment_id = get_payment_id(req_params['userId'])
    except Exception as e:
        logger.error('Occur Exception: %s', e)
        return utils.create_error_response('ERROR')

    return utils.create_success_response(
        json.dumps(payment_id, default=utils.decimal_to_int,
                   ensure_ascii=False))
def lambda_handler(event, context):
    """
    注文情報を登録する
    Parameters
    ----------
    event : dict
        フロントより渡されたパラメータ
    context : dict
        コンテキスト内容
    Returns
    -------
    payment_id : dict
        会計ID
    """
    # パラメータログ
    logger.info(event)
    if event['body'] is None:
        error_msg_display = common_const.const.MSG_ERROR_NOPARAM
        return utils.create_error_response(error_msg_display, 400)

    body = json.loads(event['body'])

    # ユーザーID取得
    try:
        user_profile = line.get_profile(body['idToken'], LIFF_CHANNEL_ID)
        if 'error' in user_profile and 'expired' in user_profile[
                'error_description']:  # noqa 501
            return utils.create_error_response('Forbidden', 403)
        else:
            body['userId'] = user_profile['sub']
    except Exception:
        logger.exception('不正なIDトークンが使用されています')
        return utils.create_error_response('Error')

    # パラメータバリデーションチェック
    param_checker = TableOrderParamCheck(body)

    if error_msg := param_checker.check_api_order_put():
        error_msg_disp = ('\n').join(error_msg)
        logger.error(error_msg_disp)
        return utils.create_error_response(error_msg_disp,
                                           status=400)  # noqa: E501
    # ユーザーID取得
    try:
        user_profile = line.get_profile(body['idToken'], LIFF_CHANNEL_ID)
        if 'error' in user_profile and 'expired' in user_profile[
                'error_description']:  # noqa 501
            return utils.create_error_response('Forbidden', 403)
        else:
            body['userId'] = user_profile['sub']
    except Exception:
        logger.exception('不正なIDトークンが使用されています')
        return utils.create_error_response('Error')

    # パラメータバリデーションチェック
    param_checker = TableOrderParamCheck(body)

    if error_msg := param_checker.check_api_order_put():
        error_msg_disp = ('\n').join(error_msg)
        logger.error(error_msg_disp)
        return utils.create_error_response(error_msg_disp,
                                           status=400)  # noqa: E501

    try:
        payment_id = put_order(body)
    except Exception as e:
        logger.error('Occur Exception: %s', e)
        return utils.create_error_response('ERROR')
    return utils.create_success_response(
        json.dumps(payment_id,
                   default=utils.decimal_to_int,
                   ensure_ascii=False))
示例#9
0
        amount = float(payment_info['amount'])
        currency = 'JPY'
        # 会計テーブルを更新
        payment_order_table_controller.update_payment_info(
            payment_id, transaction_id)
        # LINE PayAPI予約処理
        try:
            linepay_api_response = api.confirm(
                transaction_id, amount, currency)
            res_body = json.dumps(linepay_api_response)
        except Exception as e:
            # LINE Pay側でエラーが発生した場合は会計テーブルを戻す
            logger.error('Occur Exception: %s', e)
            transaction_id = 0
            payment_order_table_controller.update_payment_info(
                payment_id, transaction_id)
            return utils.create_error_response("Error")
        # プッシュメッセージ送信
        send_messages(payment_info)

    except Exception as e:
        if transaction_id is not None and transaction_id == 0:
            logger.critical(
                'payment_id: %s could not update, please update transaction_id = 0 manually and confirm the payment',  # noqa 501
                payment_id)
        else:
            logger.error('Occur Exception: %s', e)
        return utils.create_error_response("Error")

    return utils.create_success_response(res_body)