Skip to main content
Version: Lab (preview)

Hosted Fields

Hosted fields collect card, bank and cash details in Pay Theory iframes, so the payment data never touches your page. Add an empty div with the field's ID where the field goes, then call payTheoryFields to mount them.

To show each field as soon as it renders, watch iframeLoaded in the state observer.


Card fields​

A card payment needs the card number, expiration date and CVV.

It also needs the billing ZIP code. Mount the pay-theory-credit-card-zip field, or pass billingInfo to transact or tokenizePaymentMethod.

Separate card fields​

One field each for number, expiration and CVV.

<form>
...
<div id="pay-theory-credit-card-number"></div>
<div id="pay-theory-credit-card-exp"></div>
<div id="pay-theory-credit-card-cvv"></div>
...
</form>

Combined card field​

Number, expiration and CVV in one field.

<form>
...
<div id="pay-theory-credit-card"></div>
...
</form>

Billing detail fields​

Optional fields for the name on the card and the billing address.

<form>
...
<div id="pay-theory-credit-card-account-name"></div>
...
<div id="pay-theory-credit-card-address-1"></div>
<div id="pay-theory-credit-card-address-2"></div>
<div id="pay-theory-credit-card-city"></div>
<div id="pay-theory-credit-card-state"></div>
<div id="pay-theory-credit-card-zip"></div>
...
</form>

ACH fields​

All four fields are required for a US bank account.

<form>
...
<div id="pay-theory-ach-account-name"></div>
<div id="pay-theory-ach-account-number"></div>
<div id="pay-theory-ach-routing-number"></div>
<div id="pay-theory-ach-account-type"></div>
...
</form>

EFT fields​

All five fields are required for a Canadian bank account. Pass country: 'CAN' to payTheoryFields.

<form>
...
<div id="pay-theory-bank-account-name"></div>
<div id="pay-theory-bank-account-number"></div>
<div id="pay-theory-bank-institution-number"></div>
<div id="pay-theory-bank-transit-number"></div>
<div id="pay-theory-bank-account-type"></div>
</form>

Cash fields​

Both fields are required to create a cash barcode.

<form>
...
<div id="pay-theory-cash-name"></div>
<div id="pay-theory-cash-contact"></div>
...
</form>

Checkout button field​

button mounts its button here. The button opens a Pay Theory checkout page where the payor picks a payment method and pays.

<div id="pay-theory-checkout-button"></div>

QR code field​

qrCode mounts its QR code here. Scanning it opens a Pay Theory checkout page where the payor picks a payment method and pays.

<div id="pay-theory-checkout-qr"></div>

Styling hosted fields​

Style the container divs with your own CSS. Use it for the height, width and border of each container.

Make each pay-theory-credit-card-number container at least 340px wide, and the combined pay-theory-credit-card container 400px.

#pay-theory-credit-card-number,
#pay-theory-credit-card-exp,
#pay-theory-credit-card-cvv {
height: 1.75em;
border: solid 1px #ccc;
border-radius: 5px;
margin: 4px 0;
}

Styles object​

To style the inputs inside the iframes, pass a styles object to payTheoryFields. It accepts only the keys in the tables below and ignores any other property.

const STYLES = {
default: {
color: 'black',
fontSize: '14px',
fontFamily: 'Helvetica, Arial, sans-serif',
padding: '10px',
border: '1px solid #ccc',
borderRadius: '4px',
backgroundColor: '#ffffff',
},
success: {
color: '#5cb85c',
borderColor: '#5cb85c',
},
error: {
color: '#d9534f',
borderColor: '#d9534f',
},
radio: {
width: 18,
fill: 'blue',
stroke: 'grey',
text: {
fontSize: '14px',
color: 'grey',
fontFamily: 'Helvetica, Arial, sans-serif',
},
},
hidePlaceholder: false,
};
Keytypedescription
defaultField Style ObjectStyling applied to text inputs when not in success or error state.
successField Style ObjectStyling applied to text inputs that pass validation. Merged on top of default, so any property not set here keeps its default value.
errorField Style ObjectStyling applied to text inputs that fail validation. Merged on top of default the same way as success.
radioRadio ObjectStyling for the ACH account-type radio buttons.
hidePlaceholderBooleanWhen true, the placeholder text in the input fields is hidden. Defaults to false.

To style the hosted checkout button, pass style to button. See Style object.

Field style object​

The default, success, and error keys each accept the same 18 properties. All values are CSS strings.

Keytypedescription
colorStringText color. Accepts hex, rgb() / rgba(), hsl() / hsla(), named colors, CSS variables (var(--x)), transparent, inherit.
fontSizeStringFont size. Numeric + unit (px, em, rem, %, vh, vw, pt, pc, in, cm, mm, ex, ch, vmin, vmax), or calc(...), var(...), auto.
fontFamilyStringFont family stack. Capped at 100 characters.
lineHeightStringCSS line-height value.
paddingStringCSS padding shorthand. Same unit rules as fontSize.
marginStringCSS margin shorthand. Same unit rules as fontSize.
textAlignStringCSS text-align value (left, right, center, justify, start, end).
borderStringCSS border shorthand (e.g. '1px solid #ccc').
borderColorStringBorder color only. Same value rules as color.
borderRadiusStringCSS border-radius value.
backgroundColorStringBackground color. Same value rules as color.
boxShadowStringCSS box-shadow value.
outlineStringCSS outline shorthand.
widthStringCSS width. Same unit rules as fontSize.
heightStringCSS height. Same unit rules as fontSize.
transitionStringCSS transition shorthand.
opacityStringCSS opacity ('0'–'1').
webkitAppearanceStringCSS -webkit-appearance value.

Radio object​

Styles for the ACH account-type radio buttons.

Keytypedescription
widthIntWidth of the radio button, in pixels.
fillStringFill color of the selected indicator.
strokeStringColor of the radio outline.
textText ObjectStyling for the radio button labels.

Text object​

Styles for the radio button labels.

Keytypedescription
fontSizeStringFont size of the radio button labels.
colorStringColor of the radio button labels.
fontFamilyStringFont family of the radio button labels.
fontWeightStringFont weight of the radio button labels.