As of recently I noticed our system for creating reusable card payments through Square is broken. This feature was working fine as of two weeks ago when I last worked with it. My basic square payment flow is as follows:
Take the card details on the frontend with web payments sdk, tokenize and send to backend
Use card details to place a payment via the payments api
Pass this payment id as the source_id for the cards api alongside the original card details.
As of now I get a 400 error code response with reason being INVALID_CARD_DATA, and the field specified being “source_id”
Does anyone know, has square modified something regarding this. I’ve been trying to find a blog post or anything related specifying this change in behavior? It feels odd that something previously working is no longer functioning. Behavior seems to be replicable in both sandbox and prod
I am having this same issue creating a card on file using a payment id as the source_id for the createCardRequest as shown below(createCardRes->isSuccess() is false). For reference, I am using the PHP SDK here.
$card = new \Square\Models\Card();
$card->setCardholderName($_REQUEST['firstName'].' '.$_REQUEST['lastName']);
$card->setBillingAddress($billingAddress);
$card->setCustomerId($customer->getId());
$card->setReferenceId($_REQUEST['customerId']);
$createCardReq = new \Square\Models\CreateCardRequest(
$payment->getId(),
$payment->getId(),
$card
);
$createCardRes = $client->getCardsApi()->createCard($createCardReq);
if ($createCardRes->isSuccess()) {
$card = $createCardRes->getResult();
}
My application id is sandbox-sq0idb-UGQmnALynusAQq30iGglNg
Aha, thank you, seems like a silly mistake on my part!
I was using test card (VISA) 4111 1111 1111 1111, CVV - 111
I just tried (Mastercard) 5105 1051 0510 5100 CVV - 111 and now saving the customer is working fine!