import { array , boolean , lazy , object , optional , Schema , string , } from '../schema' ; import { AdditionalRecipient , additionalRecipientSchema , } from './additionalRecipient' ; import { Address , addressSchema } from './address' ; import { Order , orderSchema } from './order' ; /**
 * Square Checkout lets merchants accept online payments for supported
 * payment types using a checkout workflow hosted on squareup.com.
 */ export interface Checkout { /** ID generated by Square Checkout when a new checkout is requested. */ id ? : string ; /**
     * The URL that the buyer's browser should be redirected to after the
     * checkout is completed.
     */ checkoutPageUrl ? : string ; /**
     * If `true`, Square Checkout will collect shipping information on your
     * behalf and store that information with the transaction information in your
     * Square Dashboard.
     * Default: `false`.
     */ askForShippingAddress ? : boolean ; /**
     * The email address to display on the Square Checkout confirmation page
     * and confirmation email that the buyer can use to contact the merchant.
     * If this value is not set, the confirmation page and email will display the
     * primary email address associated with the merchant's Square account.
     * Default: none; only exists if explicitly set.
     */ merchantSupportEmail ? : string ; /**
     * If provided, the buyer's email is pre-populated on the checkout page
     * as an editable text field.
     * Default: none; only exists if explicitly set.
     */ prePopulateBuyerEmail ? : string ; /**
     * Represents a postal address in a country. The address format is based
     * on an [open-source library from Google](https://github.com/google/libaddressinput). For more information,
     * see [AddressValidationMetadata](https://github.com/google/libaddressinput/wiki/AddressValidationMetadata).
     * This format has dedicated fields for four address components: postal code,
     * locality (city), administrative district (state, prefecture, or province), and
     * sublocality (town or village). These components have dedicated fields in the
     * `Address` object because software sometimes behaves differently based on them.
     * For example, sales tax software may charge different amounts of sales tax
     * based on the postal code, and some software is only available in
     * certain states due to compliance reasons.
     * For the remaining address components, the `Address` type provides the
     * `address_line_1` and `address_line_2` fields for free-form data entry.
     * These fields are free-form because the remaining address components have
     * too many variations around the world and typical software does not parse
     * these components. These fields enable users to enter anything they want.
     * Note that, in the current implementation, all other `Address` type fields are blank.
     * These include `address_line_3`, `sublocality_2`, `sublocality_3`,
     * `administrative_district_level_2`, `administrative_district_level_3`,
     * `first_name`, `last_name`, and `organization`.
     * When it comes to localization, the seller's language preferences
     * (see [Language preferences](https://developer.squareup.com/docs/locations-api#location-specific-and-seller-level-language-preferences))
     * are ignored for addresses. Even though Square products (such as Square Point of Sale
     * and the Seller Dashboard) mostly use a seller's language preference in
     * communication, when it comes to addresses, they will use English for a US address,
     * Japanese for an address in Japan, and so on.
     */ prePopulateShippingAddress ? : Address ; /**
     * The URL to redirect to after checkout is completed with `checkoutId`,
     * Square's `orderId`, `transactionId`, and `referenceId` appended as URL
     * parameters. For example, if the provided redirect_url is
     * `http://www.example.com/order-complete`, a successful transaction redirects
     * the customer to:
     * <pre><code>http://www.example.com/order-complete?checkoutId=xxxxxx&amp;orderId=xxxxxx&amp;referenceId=xxxxxx&amp;transactionId=xxxxxx</code></pre>
     * If you do not provide a redirect URL, Square Checkout will display an order
     * confirmation page on your behalf; however Square strongly recommends that
     * you provide a redirect URL so you can verify the transaction results and
     * finalize the order through your existing/normal confirmation workflow.
     */ redirectUrl ? : string ; /**
     * Contains all information related to a single order to process with Square,
     * including line items that specify the products to purchase. `Order` objects also
     * include information about any associated tenders, refunds, and returns.
     * All Connect V2 Transactions have all been converted to Orders including all associated
     * itemization data.
     */ order ? : Order ; /** The time when the checkout was created, in RFC 3339 format. */ createdAt ? : string ; /**
     * Additional recipients (other than the merchant) receiving a portion of this checkout.
     * For example, fees assessed on the purchase by a third party integration.
     */ additionalRecipients ? : AdditionalRecipient [ ] ; } export const checkoutSchema = object ( { id : [ 'id' , optional ( string ( ) ) ] , checkoutPageUrl : [ 'checkout_page_url' , optional ( string ( ) ) ] , askForShippingAddress : [ 'ask_for_shipping_address' , optional ( boolean ( ) ) ] , merchantSupportEmail : [ 'merchant_support_email' , optional ( string ( ) ) ] , prePopulateBuyerEmail : [ 'pre_populate_buyer_email' , optional ( string ( ) ) ] , prePopulateShippingAddress : [ 'pre_populate_shipping_address' , optional ( lazy ( ( ) => addressSchema ) ) , ] , redirectUrl : [ 'redirect_url' , optional ( string ( ) ) ] , order : [ 'order' , optional ( lazy ( ( ) => orderSchema ) ) ] , createdAt : [ 'created_at' , optional ( string ( ) ) ] , additionalRecipients : [ 'additional_recipients' , optional ( array ( lazy ( ( ) => additionalRecipientSchema ) ) ) , ] , } ) ;