Constructor
new PaymentReady(options)
Do not use this constructor directly. Use braintree-web.payment-ready.create instead.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object |
- 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
|
- Source:
Throws:
-
If the specified
sessionIdhas 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
|
- 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
|
- 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
|
- 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
|
- 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:
|
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.
|
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: