UnionPay

UnionPay

This class represents a UnionPay component. Instances of this class have methods for fetching capabilities of UnionPay cards, enrolling a UnionPay card, and tokenizing a UnionPay card.

Constructor

new UnionPay(options)

You cannot use this constructor directly. Use braintree-web.unionpay.create instead.

Parameters:
Name Type Description
options object

See unionpay.create.

Source:

Methods

enroll(options, callbackopt) → {void}

Enrolls a UnionPay card. Use fetchCapabilities to determine if the SMS enrollment process is required.

Parameters:
Name Type Attributes Description
options object

UnionPay enrollment options:

Properties
Name Type Attributes Description
card object <optional>

The card to enroll. Required if you are not using the hostedFields option.

Properties
Name Type Attributes Description
number string

The card number.

expirationDate string <optional>

The card's expiration date. May be in the form MM/YY or MM/YYYY. When defined expirationMonth and expirationYear are ignored.

expirationMonth string <optional>

The card's expiration month. This should be used with the expirationYear parameter. When expirationDate is defined this parameter is ignored.

expirationYear string <optional>

The card's expiration year. This should be used with the expirationMonth parameter. When expirationDate is defined this parameter is ignored.

hostedFields HostedFields <optional>

The Hosted Fields instance used to collect card data. Required if you are not using the card option.

mobile object

The mobile information collected from the customer.

Properties
Name Type Description
countryCode string

The country code of the customer's mobile phone number.

number string

The customer's mobile phone number.

callback callback <optional>

The second argument, data, is a enrollPayload. If no callback is provided, enroll returns a promise that resolves with enrollPayload.

Source:

fetchCapabilities(options, callbackopt) → {Promise|void}

Fetches the capabilities of a card, including whether or not the SMS enrollment process is required.

Parameters:
Name Type Attributes Description
options object

UnionPay fetchCapabilities options

Properties
Name Type Attributes Description
card object <optional>

The card from which to fetch capabilities. Note that this will only have one property, number. Required if you are not using the hostedFields option.

Properties
Name Type Description
number string

Card number.

hostedFields HostedFields <optional>

The Hosted Fields instance used to collect card data. Required if you are not using the card option.

callback callback <optional>

The second argument, data, is a fetchCapabilitiesPayload. If no callback is provided, fetchCapabilities returns a promise that resolves with a fetchCapabilitiesPayload.

Source:

teardown(callbackopt) → {Promise|void}

Cleanly remove anything set up by create. This only needs to be called when using UnionPay with Hosted Fields.

Parameters:
Name Type Attributes Description
callback callback <optional>

Called on completion. If no callback is provided, returns a promise.

Source:
Example
unionpayInstance.teardown();

tokenize(options, callbackopt) → {Promise|void}

Tokenizes a UnionPay card and returns a nonce payload.

Parameters:
Name Type Attributes Description
options object

UnionPay tokenization options:

Properties
Name Type Attributes Description
card object <optional>

The card to enroll. Required if you are not using the hostedFields option.

Properties
Name Type Attributes Description
number string

The card number.

expirationDate string <optional>

The card's expiration date. May be in the form MM/YY or MM/YYYY. When defined expirationMonth and expirationYear are ignored.

expirationMonth string <optional>

The card's expiration month. This should be used with the expirationYear parameter. When expirationDate is defined this parameter is ignored.

expirationYear string <optional>

The card's expiration year. This should be used with the expirationMonth parameter. When expirationDate is defined this parameter is ignored.

cvv string <optional>

The card's security number.

hostedFields HostedFields <optional>

The Hosted Fields instance used to collect card data. Required if you are not using the card option.

enrollmentId string

The enrollment ID from UnionPay#enroll.

smsCode string <optional>

The SMS code received from the user if UnionPay#enroll payload have smsCodeRequired. if smsCodeRequired is false, smsCode should not be passed.

callback callback <optional>

The second argument, data, is a tokenizePayload. If no callback is provided, tokenize returns a promise that resolves with a tokenizePayload.

Source:

Type Definitions

enrollPayload :object

Properties:
Name Type Description
enrollmentId string

UnionPay enrollment ID. This value should be passed to tokenize.

smsCodeRequired boolean

UnionPay smsCodeRequired flag.

true - the user will receive an SMS code that needs to be supplied for tokenization.

false - the card can be immediately tokenized.

Source:

fetchCapabilitiesPayload :object

Properties:
Name Type Description
isUnionPay boolean

Determines if this card is a UnionPay card.

isDebit boolean

Determines if this card is a debit card. This property is only present if isUnionPay is true.

unionPay object

UnionPay specific properties. This property is only present if isUnionPay is true.

Properties
Name Type Description
supportsTwoStepAuthAndCapture boolean

Determines if the card allows for an authorization, but settling the transaction later.

isSupported boolean

Determines if Braintree can process this UnionPay card. When false, Braintree cannot process this card and the user should use a different card.

Source:

tokenizePayload :object

Properties:
Name Type Description
nonce string

The payment method nonce.

type string

Always CreditCard.

details object

Additional account details:

Properties
Name Type Description
cardType string

Type of card, ex: Visa, MasterCard.

lastFour string

Last four digits of card number.

lastTwo string

Last two digits of card number.

description string

A human-readable description.

Source: