question

pbuilder avatar image
pbuilder asked pbuilder commented

How to select one of multiple saved cards?

Via the clover API I have been able to charge customers via tokens as well as with a saved card.

Now I would like to save multiple cards to allow the customer to select which to use (as below)

1613069359109.png

I can add all cards to the customer record via the "PUT" customer update api call but I have no way of selecting the card. I tried using the card id with no success.

Any ideas? This is the json for the test customer from the customer record showing the 3 cards above.

"cards": {

"elements": [

{

"id": "5P21Y3AYMA5K6",

"first6": "222300",

"last4": "0010",

"cardType": "MC",

"tokenType": "CTOKEN",

"modifiedTime": 1613055956000,

"customer": {

"id": "P7N4HHDE48PY8"

}

},

{

"id": "FY7SVPDG30V6T",

"first6": "378282",

"last4": "0005",

"cardType": "AMEX",

"tokenType": "CTOKEN",

"modifiedTime": 1613054237000,

"customer": {

"id": "P7N4HHDE48PY8"

}

},

{

"id": "291DAMT24NTPR",

"first6": "411111",

"last4": "1111",

"cardType": "VISA",

"tokenType": "CTOKEN",

"modifiedTime": 1613051177000,

"customer": {

"id": "P7N4HHDE48PY8"

}

}

]

}

REST APIe-commerce api
1613069359109.png (15.9 KiB)
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered pbuilder commented

Ok, I looked at your merchant account. You aren't seeing the card tokens because you are using the improper access token. You have two access tokens, the one you are using is named SageConnector, and this token does not have the online payments permission. You need to be using the token you generated for the iframe which you named Clover eComm Iframe.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

pbuilder avatar image pbuilder commented ·

That was it!

Now everything makes more sense. Iframe was added later so the Token was not updated to use it.


Thanks for your help!

0 Likes 0 ·
David Marginian avatar image
David Marginian Deactivated answered pbuilder commented

You need to use the v3 endpoint to retrieve the customer expanding on cards:

/v3/merchants/{ {mid}}/customers/{customerId}}?expand=cards

Each card element in the response will have a token property which you will need to pass as the source when you make the payment.

9 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

pbuilder avatar image pbuilder commented ·

I unintentionally created an answer instead of commenting.. my apologies.

Here is my response once again as a comment this time:


I am using the v3 endpoint, more specifically:

https://sandbox.dev.clover.com/v3/merchants/{mid}/customers/P7N4HHDE48PY8?expand=emailAddresses&expand=cards

I am not sure what the "token property" is as what you see in the json provided is all I get.

If I attempt to use the ID of the card I get the error below

'{"message":"404 Not Found","error":{"type":"validation_error","code":"resource_missing","message":"Customer with id FY7SVPDG30V6T not found."}}'

I am using the V1 endpoint charge and it seems to only accept a customer id or token.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ pbuilder commented ·

"I can add all cards to the customer record via the "PUT" customer update api call"

What is your merchant id? Can you clarify what endpoint you are using to put the customer's card data?

What type of access token are you using (merchant or OAuth)? If OAuth what is your application id?

If I attempt to use the ID of the card I get the error below

Passing in the card id as the customer id doesn't make any sense at all, so abandon that idea.

0 Likes 0 ·
pbuilder avatar image pbuilder David Marginian ♦♦ commented ·

mid: N57J9TPNPMVR1

I update the customer card data with the v1 update customer endpoint (https://scl-sandbox.dev.clover.com/v1/customers/customerId ).

Merchant access token

0 Likes 0 ·
Show more comments
pbuilder avatar image
pbuilder answered

I am using the v3 endpoint, more specifically:

https://sandbox.dev.clover.com/v3/merchants/{mid}/customers/P7N4HHDE48PY8?expand=emailAddresses&expand=cards

I am not sure what the "token property" is as what you see in the json provided is all I get.

If I attempt to use the ID of the card I get the error below

'{"message":"404 Not Found","error":{"type":"validation_error","code":"resource_missing","message":"Customer with id FY7SVPDG30V6T not found."}}'

I am using the V1 endpoint charge and it seems to only accept a customer id or token.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community