# Class ApplePayHookResult

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.extensions.applepay.ApplePayHookResult](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md)

Result of a hook handling an Apple Pay request.

Use the constants in this type to indicate specific error reasons to be provided
to Apple Pay JS. For example, the following code creates a [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md)
that indicates the shipping contact information provided by Apple Pay is invalid:

```
var ApplePayHookResult = require('dw/extensions/applepay/ApplePayHookResult');
var Status = require('dw/system/Status');

var error = new Status(Status.ERROR);
error.addDetail(ApplePayHookResult.STATUS_REASON_DETAIL_KEY, ApplePayHookResult.REASON_SHIPPING_CONTACT);
```

If a specific error reason is not provided, the generic Apple Pay `STATUS_FAILURE`
reason will be used when necessary.

## Constant Summary

| Constant                                                                                                                                                                 | Description                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [REASON_BILLING_ADDRESS](#reason_billing_address): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidBillingPostalAddress"    | Error reason code representing an invalid billing address.                                                                                                                                   |
| [REASON_FAILURE](#reason_failure): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "Failure"                                        | Error reason code representing an error or failure not otherwise specified.                                                                                                                  |
| [REASON_PIN_INCORRECT](#reason_pin_incorrect): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINIncorrect"                       | Error reason code representing the PIN is incorrect.                                                                                                                                         |
| [REASON_PIN_LOCKOUT](#reason_pin_lockout): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINLockout"                             | Error reason code representing a PIN lockout.                                                                                                                                                |
| [REASON_PIN_REQUIRED](#reason_pin_required): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINRequired"                          | Error reason code representing a PIN is required.                                                                                                                                            |
| [REASON_SHIPPING_ADDRESS](#reason_shipping_address): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidShippingPostalAddress" | Error reason code representing an invalid shipping address.                                                                                                                                  |
| [REASON_SHIPPING_CONTACT](#reason_shipping_contact): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidShippingContact"       | Error reason code representing invalid shipping contact information.                                                                                                                         |
| [STATUS_REASON_DETAIL_KEY](#status_reason_detail_key): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "reason"                     | Key for the detail to be used in [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md) objects to indicate  the reason to communicate to Apple Pay for errors. |

## Property Summary

| Property                                                                                                                      | Description                                                           |
| ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [eventDetail](#eventdetail): [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md) `(read-only)` | Detail to the JS custom event to dispatch in response to this result. |
| [eventName](#eventname): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`     | Name of the JS custom event to dispatch in response to this result.   |
| [redirect](#redirect): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md) `(read-only)`               | URL to navigate to in response to this result.                        |
| [status](#status): [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md) `(read-only)`          | Status describing the outcome of this result.                         |

## Constructor Summary

| Constructor                                                                                                                                                                                                          | Description                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [ApplePayHookResult](#applepayhookresultstatus-url)([Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md), [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)) | Constructs a result with the given outcome information. |

## Method Summary

| Method                                                                                                                                                                                                                                                                                                       | Description                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| [getEventDetail](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#geteventdetail)()                                                                                                                                                                        | Detail to the JS custom event to dispatch in response to this result.                   |
| [getEventName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#geteventname)()                                                                                                                                                                            | Name of the JS custom event to dispatch in response to this result.                     |
| [getRedirect](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#getredirect)()                                                                                                                                                                              | URL to navigate to in response to this result.                                          |
| [getStatus](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#getstatus)()                                                                                                                                                                                  | Status describing the outcome of this result.                                           |
| [setEvent](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#seteventstring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                            | Sets the name of the JS custom event to dispatch in response to this result.            |
| [setEvent](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.extensions.applepay.ApplePayHookResult.md#seteventstring-object)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)) | Sets the name and detail of the JS custom event to dispatch in response to this result. |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Constant Details

### REASON_BILLING_ADDRESS

- REASON_BILLING_ADDRESS: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidBillingPostalAddress"
  - : Error reason code representing an invalid billing address.

***

### REASON_FAILURE

- REASON_FAILURE: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "Failure"
  - : Error reason code representing an error or failure not otherwise specified.

***

### REASON_PIN_INCORRECT

- REASON_PIN_INCORRECT: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINIncorrect"
  - : Error reason code representing the PIN is incorrect.

***

### REASON_PIN_LOCKOUT

- REASON_PIN_LOCKOUT: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINLockout"
  - : Error reason code representing a PIN lockout.

***

### REASON_PIN_REQUIRED

- REASON_PIN_REQUIRED: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "PINRequired"
  - : Error reason code representing a PIN is required.

***

### REASON_SHIPPING_ADDRESS

- REASON_SHIPPING_ADDRESS: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidShippingPostalAddress"
  - : Error reason code representing an invalid shipping address.

***

### REASON_SHIPPING_CONTACT

- REASON_SHIPPING_CONTACT: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "InvalidShippingContact"
  - : Error reason code representing invalid shipping contact information.

***

### STATUS_REASON_DETAIL_KEY

- STATUS_REASON_DETAIL_KEY: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) = "reason"
  - : Key for the detail to be used in [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md) objects to indicate
    the reason to communicate to Apple Pay for errors.

***

## Property Details

### eventDetail

- eventDetail: [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md) `(read-only)`
  - : Detail to the JS custom event to dispatch in response to this result.

***

### eventName

- eventName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Name of the JS custom event to dispatch in response to this result.

***

### redirect

- redirect: [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md) `(read-only)`
  - : URL to navigate to in response to this result.

***

### status

- status: [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md) `(read-only)`
  - : Status describing the outcome of this result.

***

## Constructor Details

### ApplePayHookResult(Status, URL)

- ApplePayHookResult(status: [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md), redirect: [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md))
  - : Constructs a result with the given outcome information.

    **Parameters:**

    - status - status of the result
    - redirect - optional URL to which to navigate to in response to this outcome

***

## Method Details

### getEventDetail()

- getEventDetail(): [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - : Detail to the JS custom event to dispatch in response to this result.

    **Returns:**

    - event detail

***

### getEventName()

- getEventName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Name of the JS custom event to dispatch in response to this result.

    **Returns:**

    - event name

***

### getRedirect()

- getRedirect(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : URL to navigate to in response to this result.

    **Returns:**

    - redirect URL

***

### getStatus()

- getStatus(): [Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md)
  - : Status describing the outcome of this result.

    **Returns:**

    - status of this result

***

### setEvent(String)

- setEvent(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): void
  - : Sets the name of the JS custom event to dispatch in response to this result.

    **Parameters:**

    - name - JS custom event name

***

### setEvent(String, Object)

- setEvent(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), detail: [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)): void
  - : Sets the name and detail of the JS custom event to dispatch in response to this result.

    **Parameters:**

    - name - JS custom event name
    - detail - JS custom event detail

***
