Customers Resource (Shop API 15.6)

Summary

Http Method Resource Description
POST /Customers/Auth Obtains a new JWT (JSON Web Token) for a guest or registered customer. Tokens are returned as a HTTP Authorization:Bearer response header entry. These kinds of request are supported, as specified by the type:
  • Type guest - creates a new guest (non-authenticated) customer and returns a token for the customer.
  • Type credentials - authenticates credentials passed in the HTTP Authorization:Basic request header, returning a token for a successfully authenticated customer otherwise results in an AuthenticationFailedException.
  • Type refresh - examines the token passed in the HTTP Authorization:Bearer request header and when valid returns a new token with an updated expiry time.
For a request of type credentials:
  • Updates profile attributes for the customer (for example, "last-visited").
  • Handles the maximum number of failed login attempts.

About JWT

The token contains 3 sections:
  • the header section (specifies token type and algorithm used)
  • the payload section (contains customer information, client id, issue and expiration time)
  • finally the signature section records the token signature.
A token is created and returned to the client whenever a registered customer logs in (type "credentials") or a guest customer requests it (type "guest"). The token is returned in the response header as

Authorization: Bearer --token--

The client has to include the token in the request header as

Authorization: Bearer --token--

in any follow up request. The server declines any follow up requests without a token or which cannot be verified based on the token signature or expiration time. A token nearing its expiration time should be exchanged for a new one (type "refresh").

See "API Usage > JWT" for more details on using JWT as an authentication mechanism.
GET /Customers/{Customer_id}/Addresses Returns a sorted pageable list of all customer addresses in the address book. The default page size is 10 customer addresses. The addresses are sorted so that the preferred address is always sorted first. The remaining addresses are sorted alphabetically by ID.
GET /Customers/{Customer_id}/Baskets Gets the baskets of a customer.
GET /Customers/{Customer_id}/Orders Returns a pageable list of all customer's orders. The default page size is 10.
GET /Customers/{Customer_id}/Payment_instruments Gets customer payment instruments for an customer.

Can be limited to a specific payment method by providing query parameter payment_method_id.
POST /Customers/{Customer_id}/Payment_instruments Adds a payment instrument to a customer information.
GET /Customers/{Customer_id}/Payment_instruments/{Payment_instrument_id} Retrieves a customer's payment instrument by its id.
DELETE /Customers/{Customer_id}/Payment_instruments/{Payment_instrument_id} Deletes a customer's payment instrument.

Get or Refresh Customer JWT (JSON Web Token)

Obtains a new JWT (JSON Web Token) for a guest or registered customer. Tokens are returned as a HTTP Authorization:Bearer response header entry. These kinds of request are supported, as specified by the type:

For a request of type credentials:

About JWT

The token contains 3 sections: A token is created and returned to the client whenever a registered customer logs in (type "credentials") or a guest customer requests it (type "guest"). The token is returned in the response header as

Authorization: Bearer --token--

The client has to include the token in the request header as

Authorization: Bearer --token--

in any follow up request. The server declines any follow up requests without a token or which cannot be verified based on the token signature or expiration time. A token nearing its expiration time should be exchanged for a new one (type "refresh").

See "API Usage > JWT" for more details on using JWT as an authentication mechanism.

Url

POST https://hostname:port/dw/shop/v15_6/customers/auth

Formats

json, xml

Authentication

Name Description
None No authentication.

Request Document

AuthRequest

Response Document

Customer

Header Parameters

Parameter Type Description Constraints
Authorization String
  • Authorization:Basic for type credentials
  • Authorization:Bearer for type refresh
 

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 AuthorizationBasicMissingException   Indicates that no HTTP Authorization:Basic header was provided.
401 AuthenticationFailedException

credentialType (String)

Indicates that the username is unknown or the password does not match.

Sample

# Request type guest : obtain a token for a guest customer

REQUEST:
POST /dw/shop/v15_6/customers/auth?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Content-Type: application/json

{
  "type" : "guest"
}

# Request type credentials : obtain a token for a registered customer
# Credentials are passed as HTTP Basic in base 64 in the form username:password

REQUEST:
POST /dw/shop/v15_6/customers/auth?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{
  "type" : "credentials"
}

# Request type refresh : obtain a token in exchange for a token nearing expiration time
# Same mechanism used for guest and registered customer. Client ID needs to
# be provided and is checked against the id embedded in the token being refreshed.

REQUEST:
POST /dw/shop/v15_6/customers/auth?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Host: example.com
Content-Type: application/json

{
  "type" : "refresh"
}


# in case of success, token returned in response header Authorization:Bearer
# "auth_type" is one of "guest" or "registered"

RESPONSE:
HTTP/1.1 200 OK
Content-Length:124 
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "customer",
   "auth_type" : "guest",
   "customer_id" : "abdtkZzH6sqInJGIHNR1yUw90A",
   "preferred_locale" : "default"
}

# in case attempt to refresh an expired token:

RESPONSE:
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "ExpiredTokenException",
      "message" : "The provided token has expired."
   }
}

# in case no Authorization Basic provided for type "credentials"

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "AuthorizationBasicMissingException",
      "message" : "Missing credentials: Add a Authorization:Basic header with base64 encoded username:password."
   }
}

# in case missing or wrong username/password for type "credentials"

RESPONSE:
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "AuthenticationFailedException",
      "message" : "Failed to authenticate credentials provided in Authorization:Basic header."
   }
}

Get All Customer Addresses

Returns a sorted pageable list of all customer addresses in the address book. The default page size is 10 customer addresses. The addresses are sorted so that the preferred address is always sorted first. The remaining addresses are sorted alphabetically by ID.

Url

GET https://hostname:port/dw/shop/v15_6/customers/{customer_id}/addresses?start={Integer}&count={Integer}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Response Document

CustomerAddressResult

Path Parameters

Parameter Type Description Constraints
customer_id String The customer uuid minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer The maximum number of instances per request. Default value is 25. maxIntegerValue=200, minIntegerValue=1
start Integer The result set index to return the first instance for. Default value is 0. maxIntegerValue=999, minIntegerValue=0

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   If customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.
404 CustomerNotFoundException

customerId (String)

Indicates that the customer with the given customer id is unknown for the site.

Sample

# Request, no paging details

REQUEST:
GET /dw//shop/v15_6/customers/abdlkQCKV1aEqUQoeFOwAOeD4U/addresses?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json;charset=UTF-8

# Request, with paging details

REQUEST:
GET /dw//shop/v15_6/customers/abdlkQCKV1aEqUQoeFOwAOeD4U/addresses?start=0&count=1&client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json;charset=UTF-8


# in case of success
# note: "next" and / or "previous" links only exist when appropriate, and only if paging details were provided

RESPONSE:
HTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "customer_address_result",
   "count" : 1,
   "data" : 
   [
      
      {
         "_type" : "customer_address",
         "address1" : "10 Free Way",
         "address_id" : "private",
         "city" : "Woburn",
         "country_code" : "US",
         "etag" : "0d715f5b688ff38c1f3394d56b84ddc40ca787b1adc6d62953713923b94f9cda",
         "first_name" : "James",
         "full_name" : "James Last",
         "last_name" : "Last",
         "postal_code" : "01801",
         "salutation" : "Mr.",
         "state_code" : "MA"
      }
   ],
   "next" : "https://.../s/.../dw/shop/v15_6/customers/abdlkQCKV1aEqUQoeFOwAOeD4U/addresses?count=1&start=1&client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
   "start" : 0,
   "total" : 2
}


Get Basket

Gets the baskets of a customer.

Url

GET https://hostname:port/dw/shop/v15_6/customers/{customer_id}/baskets

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Response Document

BasketsResult

Path Parameters

Parameter Type Description Constraints
customer_id String the id of the customer to retrieve the baskets for minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   if customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.
404 CustomerNotFoundException

customerId (String)

Indicates that the customer with the given customer id is unknown for the site.

Sample

# Request

REQUEST:
GET /dw//shop/v15_6/customers/abdlkQCKV1aEqUQoeFOwAOeD4U/baskets?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json;charset=UTF-8

# in case of success

RESPONSE:
HTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "baskets_result",
   "baskets" : 
   [
      {
         "_type" : "basket",
          "basket_id" : "bccO1aOjgEnuIaaadk7pYO2rFE",
 ...      
      },
      
      {
         "_type" : "basket",
         "basket_id" : "bcs5vaOjgEQ9Uaaadk9zQIrXE6",
...            
      }
   ],
   "total" : 2
}

Get Orders of Customer

Returns a pageable list of all customer's orders. The default page size is 10.

Url

GET https://hostname:port/dw/shop/v15_6/customers/{customer_id}/orders?start={Integer}&count={Integer}&cross-sites={Boolean}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Response Document

CustomerOrderResult

Path Parameters

Parameter Type Description Constraints
customer_id String the customer uuid minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer the maximum number of instances per request; default value is 10 maxIntegerValue=200, minIntegerValue=1
cross-sites Boolean the flag whether all sites should be searched; ignored in case of JWT; default value is false  
start Integer the result set index to return the first instance for; default value is 0 minIntegerValue=0

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   Indicates that the customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.
404 CustomerNotFoundException

customerId (String)

Indicates that the customer with the given customer id is unknown for the site.

Sample

# Request, no paging details

REQUEST:
GET /dw/shop/v15_6/customers/cevGs1bS2Xac8fpwe6GHJEzYlg/orders?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json

# Request, with paging details

REQUEST:
GET /dw/shop/v15_6/customers/bczhcasxVFpLdxtF05OIPEb25u/orders?start=0&count=1&client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX 
Content-Type:application/json


# in case of success
# note: "next" and / or "previous" links only exist when appropriate, and only if paging details were provided

RESPONSE:
HTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "customer_order_result",
   "count" : 1,
   "data" : 
   [
      
      {
         "_type" : "order",
         "adjusted_merchandize_total_tax" : 5.00,
         "adjusted_shipping_total_tax" : 0.00,
         ...
         "customer_info" : 
         {
            "_type" : "customer_info",
            "customer_id" : "bczhcasxVFpLdxtF05OIPEb25u",
            "customer_name" : "John Smith",
            "email" : "[email protected]"
         },
         ...
         "order_no" : "00001228",
         ...
         "payment_instruments" : 
         [
         ...            
         ],
         "product_items" : 
         [
         ...            
         ],
         "product_sub_total" : 15.69,
         "product_total" : 15.69,
         "shipments" : 
         [
         ...
         ],
         "shipping_items" : 
         [
         ...
         ],
         "shipping_total" : 0.01,
         "shipping_total_tax" : 0.00,
         "status" : "created",
         "taxation" : "net",
         "tax_total" : 5.00,
         ...
      }
   ],
   "next" : "https://.../.../.../dw/shop/v15_6/customers/bczhcasxVFpLdxtF05OIPEb25u/orders?count=1&start=1&client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
   "start" : 0,
   "total" : 3
}


# in case of validation failure - example response in case of registered customer scenario when the customer id does not match the authenticated customer id:

RESPONSE:
HTTP/1.1 400 BAD REQUEST
Cache-Control: no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "InvalidCustomerException",
      "message" : "Invalid customer."
   }
}

Get Customer Payment Instruments

Gets customer payment instruments for an customer.

Can be limited to a specific payment method by providing query parameter payment_method_id.

Url

GET https://hostname:port/dw/shop/v15_6/customers/{customer_id}/payment_instruments?payment_method_id={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Response Document

CustomerPaymentInstrumentResult

Path Parameters

Parameter Type Description Constraints
customer_id String the id of the customer to retrieve the payment instruments for minLength=1

Query Parameters

Parameter Type Description Constraints
payment_method_id String the id of the payment method, if null - all payment instruments are retrieved  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   Indicates that the customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.

Sample

REQUEST:
GET /s/SiteGenesis/dw/shop/v15_6/customers/acE9xUWs5ea75qwTh0Svi2XfRY/payment_instruments
Host: example.com
Authorization: Bearer cd669706-3638-4dd1-a8b2-310ab900ca53
Content-Type: application/json

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
Content-Type: application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "customer_payment_instrument_result",
   "count" : 2,
   "data" : 
   [
      
      {
         "_type" : "customer_payment_instrument",
         "payment_bank_account" : 
         {
            "_type" : "payment_bank_account"
         },
         "payment_card" : 
         {
            "_type" : "payment_card",
            "card_type" : "Visa",
            "credit_card_expired" : false,
            "expiration_month" : 2,
            "expiration_year" : 2022,
            "holder" : "TestPerson2",
            "masked_number" : "***********ber2",
            "number_last_digits" : "ber2"
         },
         "payment_method_id" : "CREDIT_CARD",
         "payment_instrument_id" : "cdlPgiWbN6LM2aaadkcia6MgbA",
         "c_disabled" : "false"
      },
      
      {
         "_type" : "customer_payment_instrument",
         "bank_routing_number" : "bankrouting3446",
         "gift_certificate_code_masked" : "*****code",
         "payment_bank_account" : 
         {
            "_type" : "payment_bank_account",
            "drivers_license_last_digits" : "e111",
            "drivers_license_state_code" : "MA",
            "holder" : "Joe Doe",
            "masked_drivers_license" : "**********e111",
            "masked_number" : "**********t111",
            "number_last_digits" : "t111"
         },
         "payment_card" : 
         {
            "_type" : "payment_card",
            "credit_card_expired" : false
         },
         "payment_method_id" : "CREDIT_CARD",
         "payment_instrument_id" : "cdTsgiWbN6DFEaaadkbia6MgbA",
         "c_disabled" : "false"
      }
   ],
   "total" : 2
}

# in case of validation failure - example response in case of registered customer scenario when the customer id does not match the authenticated customer id:

RESPONSE:
HTTP/1.1 400 BAD REQUEST
Cache-Control: no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "InvalidCustomerException",
      "message" : "Invalid customer."
   }
}

Add Payment Instrument for Customer

Adds a payment instrument to a customer information.

Url

POST https://hostname:port/dw/shop/v15_6/customers/{customer_id}/payment_instruments

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Request Document

CustomerPaymentInstrumentRequest

Response Document

CustomerPaymentInstrument

Path Parameters

Parameter Type Description Constraints
customer_id String the id of the customer minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   Indicates that the customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.
404 NotFoundException   Indicates that the customer with the given customer id is unknown.

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.customer.afterPostPaymentInstrument

afterPostPaymentInstrument (customer : Customer , paymentInstrument : CustomerPaymentInstrumentRequest ) : Status

The function is called after a payment instrument was added to a customer.

Parameters:
customer - the customer for whom to add the payment instrument
paymentInstrument - the payment instrument which was added
Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.customer.beforePostPaymentInstrument

beforePostPaymentInstrument (customer : Customer , paymentInstrument : CustomerPaymentInstrumentRequest ) : Status

The function is called before a payment instrument is added to a customer.

Parameters:
customer - the customer for whom to add the payment instrument
paymentInstrument - the payment instrument to be added
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
POST /s/SiteGenesis/dw/shop/v15_6/customers/acE9xUWs5ea75qwTh0Svi2XfRY/payment_instruments
Host: example.com
Authorization: Bearer cd669706-3638-4dd1-a8b2-310ab900ca53
Content-Type: application/json; charset=UTF-8
{
  "payment_card":{
                   "expiration_year":2027,
                   "expiration_month":7,
                   "valid_from_month":8,
                   "valid_from_year":2007,
                   "issue_number":"i117",
                   "number":"1234567",
                   "holder":"Joe Doe",
                   "card_type":"Master"
                  },
  "gift_certificate_code": "gift_code7",
  "payment_method_id": "CREDITCARD",
  "bank_routing_number":"bankrouting3776",
  "c_disabled":"true"
}

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
{
   "_v" : "15.6",
   "_type" : "customer_payment_instrument",
   "bank_routing_number" : "bankrouting3776",
   "gift_certificate_code_masked" : "******ode7",
   "payment_bank_account" : 
   {
      "_type" : "payment_bank_account"
   },
   "payment_card" : 
   {
      "_type" : "payment_card",
      "card_type" : "Master",
      "credit_card_expired" : false,
      "expiration_month" : 7,
      "expiration_year" : 2027,
      "holder" : "Joe Doe",
      "issue_number" : "i117",
      "masked_number" : "***4567",
      "number_last_digits" : "4567",
      "valid_from_month" : 8,
      "valid_from_year" : 2007
   },
   "payment_method_id" : "CREDITCARD",
   "payment_instrument_id" : "cdOLciWbOsYl6aaadkwcsx9xHH",
   "c_disabled":"true"
}


# in case of validation failure - example response when the customer is not found:

RESPONSE:
HTTP/1.1 404 NOT FOUND
Cache-Control: no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "NotFoundException",
      "message" : "No customer with id 'acE9xUWs5ea75qwTh0Svi2XfRY' found."
   }
}

Get Customer Payment Instrument

Retrieves a customer's payment instrument by its id.

Url

GET https://hostname:port/dw/shop/v15_6/customers/{customer_id}/payment_instruments/{payment_instrument_id}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Response Document

CustomerPaymentInstrument

Path Parameters

Parameter Type Description Constraints
customer_id String the id of the customer to retrieve the payment instrument for minLength=1
payment_instrument_id String the id of the payment instrument to be retrieved minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   Indicates that the customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.
404 NotFoundException   Indicates that the payment instrument with the given id is unknown for the customer with the given customer id.

Sample

REQUEST:
GET /s/SiteGenesis/dw/shop/v15_6/customers/acE9xUWs5ea75qwTh0Svi2XfRY/payment_instruments/eg5hEiWbPdcaQaaaekty3fqx1o
Host: example.com
Authorization: Bearer cd669706-3638-4dd1-a8b2-310ab900ca53
Content-Type: application/json

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
Content-Type: application/json;charset=UTF-8

{
   "_v" : "15.6",
   "_type" : "customer_payment_instrument",
   "payment_bank_account" : 
   {
      "_type" : "payment_bank_account"
   },
   "payment_card" : 
   {
      "_type" : "payment_card",
      "card_type" : "Visa",
      "credit_card_expired" : false,
      "expiration_month" : 3,
      "expiration_year" : 2023,
      "holder" : "TestPerson3",
      "masked_number" : "***********ber3",
      "number_last_digits" : "ber3"
   },
   "payment_method_id" : "CREDIT_CARD",
   "payment_instrument_id" : "eg5hEiWbPdcaQaaaekty3fqx1o",
   "c_disabled" : "false"
}

# in case of validation failure - example response in case of unknown customer payment intrument:

RESPONSE:
HTTP/1.1 404 NOT FOUND
Cache-Control: no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "NotFoundException",
      "message" : "The payment instrument with uuid 'cdmh6iWbObcXUaaadkPA7ydxnr' was not found."
   }
}

Delete Customer Payment Instrument

Deletes a customer's payment instrument.

Url

DELETE https://hostname:port/dw/shop/v15_6/customers/{customer_id}/payment_instruments/{payment_instrument_id}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
OAuth Authentication via OAuth token.

Path Parameters

Parameter Type Description Constraints
customer_id String the id of the customer to delete the payment instrument for minLength=1
payment_instrument_id String the id of the payment instrument to be deleted minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 InvalidCustomerException   Indicates that the customerId URL parameter does not match the verified customer represented by the JWT token, not relevant when using OAuth.

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.customer.afterDeletePaymentInstrument

afterDeletePaymentInstrument (customer : Customer , paymentInstrumentId : String ) : Status

The function is called after removing a payment instrument of a customer.

Parameters:
customer - the customer for whom to delete the payment instrument
paymentInstrumentId - the id of the payment instrument which was deleted
Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.customer.beforeDeletePaymentInstrument

beforeDeletePaymentInstrument (customer : Customer , paymentInstrumentId : String ) : Status

The function is called before removing a payment instrument of a customer.

Parameters:
customer - the customer for whom to delete the payment instrument
paymentInstrumentId - the id of the payment instrument to be deleted
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
DELETE /s/SiteGenesis/dw/shop/v15_6/customers/acE9xUWs5ea75qwTh0Svi2XfRY/payment_instruments/cdmh6iWbObcXUaaadkPA7ydxnr
Host: example.com
Authorization: Bearer cd669706-3638-4dd1-a8b2-310ab900ca53
Content-Type: application/json

# in case of success:

RESPONSE:
HTTP/1.1 204 NO CONTENT


# in case of validation failure - example response in case of registered customer scenario when the customer id does not match the authenticated customer id:

RESPONSE:
HTTP/1.1 400 BAD REQUEST
Cache-Control: no-cache,no-store,must-revalidate
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
{
   "_v" : "15.6",
   "fault" : 
   {
      "type" : "InvalidCustomerException",
      "message" : "Invalid customer."
   }
}