PaymentReady

PaymentReady

This class represents a Payment Ready component produced by braintree-web.payment-ready.create. Instances provide methods for Payment Ready methods.

Constructor

new PaymentReady(options)

Do not use this constructor directly. Use braintree-web.payment-ready.create instead.

Parameters:
Name Type Description
options object

see payment-ready.create

Source:

Methods

createCustomerSession(options) → {Promise.<object>}

Creates a customer session using the Payment Ready API.

Parameters:
Name Type Description
options object

The options for creating a customer session.

Properties
Name Type Attributes Description
customer PaymentReady~Customer

The customer data object. At minimum, this object should contain either hashedEmail or hashedPhoneNumber field.

sessionId string <optional>

Optionally, specify a unique identifier for this customer session. It must be at least 36 characters, no more than 100 characters and match the following regex: [A-Za-z0-9-_.]+.

Source:
Throws:

If the specified sessionId has previously been used or has an invalid format.

Type
BraintreeError
Example
paymentReadyInstance.createCustomerSession({
  customer: {
    ... // Customer data
  }
}).then(function (sessionData) {
  // Handle the session data
  console.log(sessionData.sessionId);
}).catch(function (err) {
  // Handle errors
  console.error(err);
});

getCustomerRecommendations(options) → {Promise.<object>}

Generates customer payment recommendations using the Payment Ready API.

Parameters:
Name Type Description
options object

The options for generating customer recommendations.

Properties
Name Type Attributes Description
sessionId string

The ID of the session to get recommendations for.

customer PaymentReady~Customer <optional>

Optional customer data object.

domain string <optional>

Optional domain parameter.

purchaseUnits Array <optional>

Optional purchase units array.

Source:
Example
paymentReadyInstance.getCustomerRecommendations({
  sessionId: "session-abc-123",
  customer: {
    // Optional customer data
  },
  domain: "example.com",
  purchaseUnits: [
    // Purchase unit data
  ]
}).then(function (recommendations) {
  // Handle the recommendations data
  console.log(recommendations.paymentRecommendations);
}).catch(function (err) {
  // Handle errors
  console.error(err);
});

sendPresentedEvent(options) → {void}

Call this method when a payment button has been successfully displayed to the buyer. This method sends analytics to help improve the Shopper Insights feature experience.

Parameters:
Name Type Description
options object

The options for the event.

Properties
Name Type Attributes Description
buttonType string

Type of button presented to the user.

paymentReadySessionId string

The id of paymentReady session created with createCustomerSession method.

presentmentDetails object <optional>

Details of presentment. Includes experimentType, pageType, and buttonOrder.

Properties
Name Type Attributes Description
experimentType PaymentReady~EXPERIMENT_TYPE <optional>

Experiment type being used.

pageType PaymentReady~PAGE_TYPE <optional>

Page type where the SDK is being used.

buttonOrder PaymentReady~BUTTON_ORDER <optional>

Where in the list of buttons this button was presented.

Source:
Example
paymentReadyInstance.sendPresentedEvent({
  buttonType: "paypal",
  paymentReadySessionId: "SESSION_ID_123",
  presentmentDetails: {
    experimentType: "control",
    pageType: "checkout",
    buttonOrder: "second"
});

sendSelectedEvent(options) → {void}

Use PayPal Payment Ready to optimize your checkout experience by sending analytics events.

Parameters:
Name Type Description
options object

The options for the event

Properties
Name Type Description
paymentReadySessionId string

The ID of the session to update.

buttonType PaymentReady~BUTTON_TYPE

Type of button presented to the user.

Source:
Example

Sending analytics event

paymentReadyInstance.sendSelectedEvent({
  paymentReadySessionId: "session-abc-123",
  buttonType: "paypal"
});

updateCustomerSession(options) → {Promise.<object>}

Updates an existing customer session using the Payment Ready API.

Parameters:
Name Type Description
options object

The options for updating a customer session.

Properties
Name Type Description
sessionId string

The ID of the session to update.

customer PaymentReady~Customer

The updated customer data object.

Source:
Example
paymentReadyInstance.updateCustomerSession({
  sessionId: "session-abc-123",
  customer: {
    ... // Updated customer data
  }
}).then(function (sessionData) {
  // Handle the updated session data
  console.log(sessionData.sessionId);
}).catch(function (err) {
  // Handle errors
  console.error(err);
});

Type Definitions

BUTTON_ORDER

Properties:
Name Type Description
FIRST string

"first"

SECOND string

"second"

THIRD string

"third"

FOURTH string

"fourth"

FIFTH string

"fifth"

SIXTH string

"sixth"

SEVENTH string

"seventh"

EIGHT string

"eight"

OTHER string

"other"

Source:

BUTTON_TYPE

Properties:
Name Type Description
PAYPAL string

"paypal"

VENMO string

"venmo"

OTHER string

"other"

Source:

Customer :object

Payment Ready Customer data object.

Properties:
Name Type Attributes Description
deviceFingerprintId string <optional>

Unique device identifier

hashedEmail string <optional>

This field must contain a Hex-encoded SHA-256 hashed value of the actual email. The email address must be sanitized before hashing:

  • email address in lowercase
  • remove leading and trailing whitespace
hashedPhoneNumber string <optional>

This field must contain a Hex-encoded SHA-256 hashed value of the phone number; and the phone number must be in E.164 format.

  • E.164 format example 1: '+12345551234' where country code is '1', area code is '234' and subscriber number is '555-1234'
  • E.164 format example 2: '+6129876543X' where country code is '61', area code is '2' and subscriber number is '9876 543X'
paypalAppInstalled boolean <optional>

A flag indicating if customer device has paypal application installed.

venmoAppInstalled boolean <optional>

A flag indicating if customer device has venmo applicaition installed.

userAgent string <optional>

The user agent string of customer browser describing application, OS, vendor, and version of requesting user agent.

Source:

EXPERIMENT_TYPE

Properties:
Name Type Description
CONTROL string

"control"

TEST string

"test"

Source:

PAGE_TYPE

Properties:
Name Type Description
ABOUT string

"about"

CART string

"cart"

CHECKOUT string

"checkout"

HOMEPAGE string

"homepage"

MINICART string

"minicart"

ORDER_CONFIRMATION string

"order_confirmation"

ORDER_REVIEW string

"order_review"

PRODUCT_CATEGORY string

"product_category"

PRODUCT_DETAILS string

"product_details"

SEARCH string

"search"

OTHER string

"other"

Source: