def METHOD_NAME(invoice_identifier):
    """
    Create a paypal payment.
    :return: The payment id of the created payment.
    """
    try:
        paypal_payment_id = request.json['data']['attributes']['paypal_payment_id']
        paypal_payer_id = request.json['data']['attributes']['paypal_payer_id']
    except Exception as e:
        raise BadRequestError({'source': e}, 'Bad Request Error')
    event_invoice = safe_query(
        EventInvoice, 'identifier', invoice_identifier, 'identifier'
    )
    # save the paypal payment_id with the order
    event_invoice.paypal_token = paypal_payment_id
    save_to_db(event_invoice)
    # execute the invoice transaction.
    status, error = PayPalPaymentsManager.execute_payment(
        paypal_payer_id, paypal_payment_id
    )
    if status:
        # successful transaction hence update the order details.
        event_invoice.paid_via = 'paypal'
        event_invoice.payment_mode = 'paypal'
        event_invoice.status = 'paid'
        event_invoice.transaction_id = paypal_payment_id
        event_invoice.completed_at = datetime.datetime.now()
        save_to_db(event_invoice)
        return jsonify(status="Charge Successful", payment_id=paypal_payment_id)
    # return the error message from Paypal
    return jsonify(status="Charge Unsuccessful", error=error)