Create a payment using 'Shared cards on File' gets NOT_FOUND "Payment on file not found" error

I’m using Share cards between merchants accounts to make payments and I follow this tutorial - shared cards in the step 3 I search for a customer in the seller merchant account and I could retrieve it if that was created it before.
it looks like this (Example response from client.customersApi.searchCustomers (this is a dummy data)

`const response = {"cards":[
{"billingAddress":{"postalCode":"33000"},"cardBrand":"VISA","expMonth":"12","expYear":"2020","id":"ccof:CA1SEBMN-SvNDZ_1W9ImmB4Y5SUoPQ","last4":"0076"},
{"billingAddress":{"postalCode":"33000"},"cardBrand":"VISA","expMonth":"12","expYear":"2020","id":"ccof:CA1SEERe4cfvZDKAA1XGwPo1JkUoPQ","last4":"0076"},
{"billingAddress":{"postalCode":"33000"},"cardBrand":"MASTERCARD","expMonth":"03","expYear":"2026","id":"ccof:CA1SEJ_j7rlPQSmcJP9k6AN_5LYoPQ","last4":"2059"}],"createdAt":"2023-10-26T05:16:49.41Z","creationSource":"THIRD_PARTY","emailAddress":"[email protected]","givenName":"Tester","id":"OO8AT623CRDL1J64KA86LH94AL","note":"ccof:CA1SEERe4cfvZDKAA1XGwPo1JkUoPQ","preferences":{"emailUnsubscribed":false},"segmentIds":["MLTC1N74JA1SG.CARDS_ON_FILE","MLTC1N74JA1SG.CHURN_RISK","MLTC1N74JA1SG.REACHABLE","gv2:864Z0EZZQ93KD5N0R7NX0A39W0"],"updatedAt":"2023-10-26T09:10:56Z","version":"2"};`

otherwise I created a new one, and I make a payment

`const response = await client.paymentsApi.createPayment({
    sourceId: 'ccof:uIbfJXhXETSP197M3GB',
    idempotencyKey: '{UNIQUE_KEY}',
    amountMoney: {
      amount: 200,
      currency: 'USD'
    },
    autocomplete: true,
    customerId: '{CUSTOMER_ID_FROM_SELLER}',
    locationId: 'XK3DBG77NJBFX',
    referenceId: '123456'
  });`

using the customer ID from the seller, however I’m not sure what should I use in the source ID since I got 3 different source ID, If I use the original one from the main account I got “Payment on file not found” What source ID should I use in this case

Sorry for the delay. When you charge the stored the card on file you’ll need to use the card_id that you stored on your account. You won’t use any of the cards on file that are stored in the sellers account. :slightly_smiling_face:

1 Like

it’s a little confusing - referencing the documentation below.

Step 4: Create a payment in the seller account using the shared card

Use a seller account OAuth access token to create a payment in the seller account, referencing the customer_id from step 3 (the customer in the seller account) and the shared card on file as the source_id value from step 2.

if I used the shared card on file from the main account as a source_id and the customer_id from the seller account I got this error

{
“code”: “NOT_FOUND”,
“detail”: “Payment on file not found”,
“category”: “INVALID_REQUEST_ERROR”
}

If I use the card_id from the main account as a source_id I assume I should use the customer_id from the main account as well, instead of customer_id in the seller account, even when the documentation suggests to use the customer_id in the seller account, is that correct?

Is this in sandbox or in production? :slightly_smiling_face:

it’s production environment, this is not happening for all of our users, we used to use the card api alpha for a while and we moved to Square Node sdk, no sure if this could be related it

I’ve recently tested this in production. If you save the card to the main account using your access token and create a customer in the sellers account using there OAuth access token you’ll be able to charge the card on file with there access token. You’ll also need to make sure that the OAuth access token has the PAYMENTS_WRITE_SHARED_ONFILE permission. :slightly_smiling_face:

The possible solution will be make sure the ‘PAYMENTS_WRITE_SHARED_ONFILE’ permission is enabled in the seller access token OAuth and make sure, and the correct request will be like this example below.

const response = await client.paymentsApi.createPayment({
    sourceId: '{CARD_ID_FROM_MAIN_ACCOUNT}',
    idempotencyKey: '{UNIQUE_KEY}',
    amountMoney: {
      amount: 200,
      currency: 'USD'
    },
    autocomplete: true,
    customerId: '{CUSTOMER_ID_FROM_SELLER}',
    locationId: 'XK3DBG77NJBFX',
    referenceId: '123456'
  });

is it right?

You got it! That’s it! :slightly_smiling_face:

1 Like