Saved Cards API¶
This section describes how to manage cards saved by customer.
Creating a Customer Session¶
When you want to let the customer manage their saved cards, for instance in a profile page on your webshop. You need to use a token that is scoped to the role merchant-customer. This token is meant to be used on the frontend by passing it to saved cards frontend sdk
To create a customer session use the newCustomerSession mutation:
Parameter |
Description |
|---|---|
country |
The country where any save card requests will take place. Defaults to the merchant’s default country. Example: SE, DK, NO, IS, FI |
currency |
The currency which when customer requests to save card, the zero amount auth takes place in. Defaults to the merchant’s default currency. |
customerReference |
Unique reference for your customer. This should be the same reference that is sent in PaymentSessionAdditionalData.customerReference. Max length: 64. |
expiresAt |
The latest point in time (ISO8601) that the session is usable at. Must be between 0 and 24 hours into the future. |
idempotencyKey |
Idempotency key is required to prevent double processing a request. See also Idempotency keys. |
language |
Language the session should use. Only languages in two-letter ISO-639-1 format are recognized. Example: SV, DA, NO, IS, EN. |
merchantReference |
Merchant’s internal reference that may help the merchant in identifying this customer session. |
The token in the response can be now be used to view, edit, delete saved cards. See Authentication on how to use the token in your requests.
Viewing Saved Cards¶
When you want to show a logged in customer their saved cards, the following query can be used with the customer session token obtained above.
Parameter |
Description |
|---|---|
id |
The unique identifier for this saved card. This can be passed to identify the card in editSavedCard and deleteSavedCard mutations. |
maskedCard |
The masked PAN of the saved card. |
cardType |
The scheme of the card. It’s an enum whose values are defined at https://kronor-io.github.io/kronor/#definition-CreditCardSchemeEnum |
nickname |
The card’s nickname that the customer has set. |
isDefault |
Is true if the customer has marked this card to be their default payment card. |
expiryMonth |
The month of card expiry. |
expiryYear |
The year of card expiry. |
lastUsedAt |
The timestamp in UTC when the card was last used. |
If you want to instead query the saved cards on behalf of a customer in your backend service, you can use the merchant-backend token you have and pass the customer reference in the saved query.
Editing a Saved Card¶
When you want to allow a logged in customer to edit their saved card, the following query can be used with the customer session token obtained above.
Parameter |
Description |
|---|---|
cardId |
The id of the card to be edited. The id can be obtained from customerCards GraphQL query. |
cardNickname |
The nickname customer wants to use to remember this card with. Only alphanumeric characters, spaces and _, -, !, ‘, and . are allowed. Max length: 20. |
idempotencyKey |
Idempotency key is required to prevent double processing a request. |
setCardAsDefault |
Should this card be set as the default? |
If you want to instead edit a saved card on behalf of a customer in your backend service, you can use the merchant-backend token you have and just pass an additional variable customerReference which is the customer reference of the user you want to edit the saved card.
Deleting a Saved Card¶
When you want to allow a logged in customer to delete their saved card, the following query can be used with the customer session token obtained above.
Parameter |
Description |
|---|---|
cardId |
The id of the card to be deleted. The id can be obtained from customerCards GraphQL query. |
idempotencyKey |
Idempotency key is required to prevent double processing a request. |
If you want to instead delete a saved card on behalf of a customer in your backend service, you can use the merchant-backend token you have and just pass an additional variable customerReference which is the customer reference of the user you want to delete the card for.