import json


def hostedPaymentPagePayload(amount, capture_now, merchant_reference, return_url, locale, account, organisation,
                             currency, dynamic_descriptor,
                             webhook_transaction_update, shopper_interaction, first_name, last_name, email,
                             address, city, state, postal_code, country, phone, three_ds_required,
                             show_order_summary, create_token, card_brand):
    """

    Function for constructing payload for hostedPaymentPage API call.
    Note: All parameters are of type String unless otherwise stated below.

    :param amount: Integer - Amount of currency's smallest denomination to be moved
    :param capture_now: Boolean - Specify whether or not to capture the transaction immediately
    :param merchant_reference: Reference code for the merchant
    :param return_url: The return url to which the customer is redirected after an transaction is processed.
    :param locale: Valid values: "en_GB", "en_US". Locale code
    :param account: The ID of the account. Acts as an override. Must be submitted if organisation and currency are not
                        used in the request.
    :param organisation: The ID of the organisation
    :param currency: A 3-letter ISO 4217 currency code, see Currencies Section for more details.
    :param dynamic_descriptor: A short reference/descriptor that will show up on the customers bank statement.
                        Only supported by some acquirers. Please confirm with your Implementation Manager for supported
                        acquirers and formats.
    :param webhook_transaction_update: A webhook url that is called when a transaction is updated. Note: This overrides any URL set on the account.
    :param shopper_interaction: String (Valid values "ecommerce" "pos" "moto" "unknown") - Determines the point of sale
                        of a customer. Default value: ecommerce.
    :param first_name: Note: Only alphabetic characters, Special characters allowed are (hyphen(-),
                        underscore(_), dot(.), comma(,) and apostrophe(‘))
    :param last_name: Note: Only alphabetic characters, Special characters allowed are (hyphen(-),
                        underscore(_), dot(.), comma(,) and apostrophe(‘))
    :param email: Note: Only alphabets, numeric, @, comma(,) dot(.), plus(+), underscore(_), dash(-) and
                        apostrophe(‘)
    :param address: Note: All characters support
    :param city: Note: Only alphabetic characters, Special characters allowed are (hyphen(-), underscore(_),
                        dot(.), comma(,) and apostrophe(‘))
    :param state: Note: Only alphabetic characters, Special characters allowed are (hyphen(-), underscore(_),
                        dot(.), comma(,) and apostrophe(‘))
    :param postal_code: Note: Only alpha-numeric characters
    :param country: A 2-letter ISO3166 alpha-2. country code for the address. Note: Alphabets upto two
                        characters (e.g. GB, RU etc..)
    :param phone: Numbers only, no dash or any other separator. Note: Length - min(3) & max(20)
    :param three_ds_required: Boolean - True if 3DS required for this transaction, False otherwise.
                        Note: This field is mandatory if account is not passed.
    :param create_token: Boolean - Whether create a token or not for the card. Defaults to 'false'. Setting the to
                        'true' will create the token for the card.
    :param show_order_summary: Boolean - This field allows you to customise the order summary block in the HPP iframe.
                        True will load the order summary in the page and false will hide it.
    :param card_brand: String (Valid values "amex" "diners" "discover" "elo" "jcb" "maestro" "mastercard" "visa"
                        "visa electron") - Card brand for the card used for processing.
    :return: JSON Payload for API call
    """
    payload_py = {
        "account": account,
        "amount": amount,
        "capture_now": capture_now,
        "dynamic_descriptor": dynamic_descriptor,
        "merchant_reference": merchant_reference,
        "return_url": return_url,
        "webhook_transaction_update": webhook_transaction_update,
        "organisation": organisation,
        "locale": locale,
        "currency": currency,
        "shopper_interaction": shopper_interaction,
        "create_token": create_token,
        "card_brand": card_brand,
        "billing_address": {
            "first_name": first_name,
            "last_name": last_name,
            "email": email,
            "address": address,
            "city": city,
            "state": state,
            "postal_code": postal_code,
            "country": country,
            "phone": phone
        },
        "three_ds": {
            "three_ds_required": three_ds_required
        },
        "show_order_summary": show_order_summary
    }

    payload_json = json.dumps(payload_py)

    return payload_json