Broadleaf Microservices
  • v1.0.0-latest-prod

Customer Saved Payment Methods

Customers may wish to store payment methods within the system. The following operations allow you to read, update, and delete customer payment methods.

Note

To operate on the customer’s saved payment methods, the customer must be authenticated and their access token must be provided to the function call.

List Customer Saved Payment Methods

Operation

SavedPaymentMethodClient#listSavedPaymentMethods(owningUserType, owningUserId, options);

Parameters

Parameter Type Required? Description

owningUserType

string

Provide the type of the owning user that owns the saved payment methods you want to fetch. i.e. BLC_CUSTOMER

owningUserId

string

Provide the id of the owning user that owns the saved payment methods you want to fetch. i.e. customerId

options

PageableClientCallOptions

Options passed to the HTTP request call to customize the request configuration. Including paging related options.

Response

This function returns a list of SavedPaymentMethodSummaries.

Example

Example of retrieving a customer’s saved payment methods
const savedPayments = await savedPaymentMethodClient.listSavedPaymentMethods(
  'BLC_CUSTOMER',
  'CUSTOMER_ID',
  { accessToken }
);

console.log(savedPayments);

Get Customer Saved Payment Method

Operation

SavedPaymentMethodClient#getSavedPaymentMethod(owningUserType, owningUserId, savedPaymentMethodId, options);

Parameters

Parameter Type Required? Description

owningUserType

string

Provide the type of the owning user that owns the saved payment methods you want to fetch. i.e. BLC_CUSTOMER

owningUserId

string

Provide the id of the owning user that owns the saved payment methods you want to fetch. i.e. customerId

savedPaymentMethodId

string

Provide the saved payment method id to retrieve.

options

ClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a SavedPaymentMethodSummary.

Example

Example of retrieving a customer’s saved payment method by its id
const savedPayment = await savedPaymentMethodClient.getSavedPaymentMethod(
  'BLC_CUSTOMER',
  'CUSTOMER_ID',
  'SAVED_PAYMENT_ID',
  { accessToken }
);

console.log(savedPayment);

Add Customer Saved Payment Method

Operation

SavedPaymentMethodClient#addSavedPaymentMethod(createSavedPaymentMethodRequest, options);

Parameters

Parameter Type Required? Description

createSavedPaymentMethodRequest

CreateSavedPaymentMethodRequest

Provide the saved payment method data to add.

options

ClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a SavedPaymentMethodSummary.

Example

Example of adding a new saved payment method for a customer
const createRequest: CreateSavedPaymentMethodRequest = {
      id: '123',
      name: 'VISA',
      defaultForOwner: false,
      owningUserType: 'BLC_CUSTOMER',
      owningUserId: 'MOCK_CUSTOMER',
      type: 'CREDIT_CARD',
      gatewayType: 'PASSTHROUGH',
      visibleToChildren: 'NO',
      billingAddress: {
        addressLine1: '123 Street Drive',
        city: 'Dallas',
        fullName: 'Customer',
        postalCode: '12345',
        stateProvinceRegion: 'TX',
        country: 'US'
      },
      displayAttributes: {
        nameOnAccount: 'Test Test',
        expirationMonth: '1',
        expirationYear: '2023'
      }
};

const savedPayment = await savedPaymentMethodClient.addSavedPaymentMethod(
  createRequest,
  { accessToken }
);

console.log(savedPayment);

Update Customer Saved Payment Method

Operation

SavedPaymentMethodClient#updateSavedPaymentMethod(owningUserType, owningUserId, updateSavedPaymentMethodRequest, options);

Parameters

Parameter Type Required? Description

owningUserType

string

Provide the type of the owning user that owns the saved payment methods you want to fetch. i.e. BLC_CUSTOMER

owningUserId

string

Provide the id of the owning user that owns the saved payment methods you want to fetch. i.e. customerId

updateSavedPaymentMethodRequest

updateSavedPaymentMethodRequest

Provide the saved payment method data to update.

options

SavedPaymentMethodClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a SavedPaymentMethodSummary.

Example

Example of updating a saved payment method for a customer
const updateRequest: UpdateSavedPaymentMethodRequest = {
      savedPaymentMethodId: '123',
      name: 'VISA',
      defaultForOwner: false,
      type: 'CREDIT_CARD',
      gatewayType: 'PASSTHROUGH',
      visibleToChildren: 'NO',
      billingAddress: {
        addressLine1: '123 Street Drive',
        city: 'Dallas',
        fullName: 'Customer',
        postalCode: '12345',
        stateProvinceRegion: 'TX',
        country: 'US'
      },
      displayAttributes: {
        nameOnAccount: 'Test Test',
        expirationMonth: '1',
        expirationYear: '2023'
      },
      version: 0
};

const savedPayment = await savedPaymentMethodClient.updateSavedPaymentMethod(
  'BLC_CUSTOMER'
  'CUSTOMER_ID',
  updateRequest,
  {
    accessToken,
    version: 0
  }
);

console.log(savedPayment);

Delete Customer Saved Payment Method

Operation

SavedPaymentMethodClient#deleteSavedPaymentMethod(owningUserType, owningUserId, savedPaymentMethodId, options);

Parameters

Parameter Type Required? Description

owningUserType

string

Provide the type of the owning user that owns the saved payment methods you want to fetch. i.e. BLC_CUSTOMER

owningUserId

string

Provide the id of the owning user that owns the saved payment methods you want to fetch. i.e. customerId

savedPaymentMethodId

string

Provide the customer saved payment method id to delete.

options

SavedPaymentMethodClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns void.

Example

Example of deleting a saved payment method for a customer
await savedPaymentMethodClient.deleteSavedPaymentMethod(
  'BLC_CUSTOMER',
  'CUSTOMER_ID',
  'SAVED_PAYMENT_ID',
  {
    accessToken,
    version: 0
  }
);