The information is stored on the charge attempt
In case a token is created you can get the token information of a transaction in case the transaction is at least in the state authorised.
In order to do this you have to proceed as follows
- Get the charge attemptId for the transaction that you want to get the Token. This is done by the charge Attempt Id search. How this work is is described here.
- Once you have the charge attempt you can use the chargeAttempt Read service to get the labels.
This should return all the different labels on the charge attempt that you can display in your application.
Those labels (masked card number, expiry date, etc.) has different ID's to be identified.
With the following PHP SDK code you can get those labels out of transactions:
function getEntityQuery($counter) { $entityQueryFilterStatus = new EntityQueryFilter(['field_name' => 'state', 'operator' => CriteriaOperator::EQUALS, 'type' => EntityQueryFilterType::LEAF, 'value' => 'SUCCESSFUL']); $entityQuery = new EntityQuery(['filter' => $entityQueryFilterStatus, 'starting_entity' => 100, 'number_of_entities' => 100]); $entityQuery->setStartingEntity($counter); $orderBys = new EntityQueryOrderBy(['field_name' => 'charge.id', 'sorting' => EntityQueryOrderByType::DESC]); $entityQuery->setOrderBys([$orderBys]); $entityQuery->getNumberOfEntities(100); return $entityQuery; } $counter = 0; while (true) { $entityQuery = getEntityQuery($counter); $chargeAttempts = $apiClient->getChargeAttemptService()->search($spaceId, $entityQuery); $maskedCardNrId = 1456765125779; $refNoId = 1532425961677; $authCodeNrId = 1579287795628; foreach ($chargeAttempts as $chargeAttempt) { echo "\n-----------------\n" . "Transaktion ID: " . $chargeAttempt->getLinkedTransaction() . "\n-----------------\n"; foreach ($chargeAttempt->getLabels() as $label) { if ($label->getDescriptor()->getId() == $maskedCardNrId) { $panNo = $label->getContent()[0]; echo "\nPAN No: " . $panNo; } if ($label->getDescriptor()->getId() == $refNoId) { $refNo = $label->getContent()[0]; echo "\nRef No: " . $refNo; } if ($label->getDescriptor()->getId() == $authCodeNrId) { $authNo = $label->getContent()[0]; echo "\nAuth code: " . $authNo . "\n-----------------\n"; } // expiry date if ($label->getDescriptor()->getId() == 1456765711187) { $expiryDate = $label->getContentAsString(); echo "\nExpiry date: " . $expiryDate; } } } $counter += 100; }
Comments
0 comments
Please sign in to leave a comment.