import { areAddressesEquivalent } from '@broadleaf/payment-js';
const areEqual = areAddressesEquivalent(address1, address2);
JS utilities provided by @broadleaf/payment-js
.
Compares two addresses for equivalency. Addresses can have additional attributes that are not relevant when considering equality. This is particularly useful when detecting if the selected address or the address on the cart are the same as a saved address.
Utility that can find a matching CustomerAddress
for the given Address
.
CustomerAddresses
add some additional info to a base Address
that aren’t necessarily used in a Billing or Shipping address form.
Parameter | Type | Required? | Description |
---|---|---|---|
|
Array of saved CustomerAddresses |
✅ |
The saved addresses to find a match within |
|
❌ |
The address to find a matching saved (customer) address for. |
The CustomerAddress with the same address info as the given Address.
Parses a passthrough payment token created with createPassthroughPaymentToken.
Parameter | Type | Required? | Description |
---|---|---|---|
|
|
✅ |
The name of the cardholder. |
|
|
✅ |
The credit card number. |
|
|
✅ |
The expiration month. |
|
|
✅ |
The expiration year. |
|
|
✅ |
The type of credit card, e.g., VISA, AMEX, MASTERCARD. |
Creates a passthrough payment token to enable passthrough payment gateway testing. This token is a stringification of the payment info object and then base 64 encoded. It simulates a payment token from a real provider like Stripe.
Parameter | Type | Required? | Description |
---|---|---|---|
|
|
✅ |
The name of the cardholder. |
|
|
✅ |
The credit card number. |
|
|
✅ |
The expiration month. |
|
|
✅ |
The expiration year. |
|
|
✅ |
The type of credit card, e.g., VISA, AMEX, MASTERCARD. |
Returns the matching card type for the given card number. This uses regex to match standard patterns for card issuers.
The matching CardType.
Gets the month and year options for card expiration date selectors.
Parameter | Type | Required? | Description |
---|---|---|---|
|
|
✅ |
The list of month values and labels. See getCardExpirationMonths |
|
|
✅ |
The list of year values and labels. See getCardExpirationYears |
Gets the year options for a card expiration date selector.
Takes a FulfillmentGroup
and returns an object containing the total adjustments amount including item adjustments and currency for that group.
Parameter | Type | Required? | Description |
---|---|---|---|
|
✅ |
The fulfillment group for which to get the total adjustments including items. |