====== PHP XML Secure Cards ====== The sample code below required the **{{:developer:sample_codes:gateway_xml_php_api.zip|PHP XML API}}**.\\ **Settings file (nuvei_account.inc):** ---- \\ **Secure Card registration:** SetDontCheckSecurity($dontCheckSecurity); if($cvv != "") $securereg->SetCvv($cvv); if($issueNo != "") $securereg->SetIssueNo($issueNo); $response = $securereg->ProcessRequestToGateway($secret,$testAccount,$gateway); unset($secureCardCardRef); if($response->IsError()){ echo 'AN ERROR OCCURED, Card details not registered. Error details: ' . $response->ErrorString(); } else { $merchantRef = $response->MerchantReference(); $expectedResponseHash = md5($terminalId.$response->MerchantReference().$response->CardReference().$response->DateTime().$secret); if($expectedResponseHash != $response->Hash()) { echo 'SECURECARD REGISTRATION FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if your card details were stored.'; if(isset($merchantRef)) { echo 'Please quote Nuvei Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $response->MerchantReference() . ' when mailling or calling.'; } } else { echo "SecureCard successfully stored."; } } ?> ---- \\ **SecureCard record update:** SetDontCheckSecurity($dontCheckSecurity); if($cvv != "") $secureupd->SetCvv($cvv); if($issueNo != "") $secureupd->SetIssueNo($issueNo); $response = $secureupd->ProcessRequestToGateway($secret,$testAccount,$gateway); if($response->IsError()) { echo 'AN ERROR OCCURED, Card details not updated. Error details: ' . $response->ErrorString(); } else { $expectedResponseHash = md5($terminalId.$response->MerchantReference().$response->CardReference().$response->DateTime().$secret); if($expectedResponseHash != $response->Hash()) { echo 'SECURECARD UPDATE FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if your card details were updated.'; $merchantRef = $response->MerchantReference(); if(isset($merchantRef)) { echo 'Please quote Nuvei Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $merchantRef . ' when mailling or calling.'; } } else { echo "SecureCard successfully updated."; } } ?> ---- \\ **SecureCard record deletion:** ProcessRequestToGateway($secret,$testAccount,$gateway); if($response->IsError()) { echo 'AN ERROR OCCURED, Card details not deleted. Error details: ' . $response->ErrorString(); } else { $expectedResponseHash = md5($terminalId.$response->MerchantReference().$response->DateTime().$secret); if($expectedResponseHash != $response->Hash()) { echo 'SECURECARD DELETION FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if your card details were updated.'; $merchantRef = $response->MerchantReference(); if(isset($merchantRef)) { echo 'Please quote Nuvei Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $response->MerchantReference() . ' when mailling or calling.'; } } else { echo "SecureCard successfully deleted."; } } ?> ---- \\ **SecureCard record search:** ProcessRequestToGateway($secret,$testAccount,$gateway); if($response->IsError()){ echo 'AN ERROR OCCURED, Card details not found. Error details: ' . $response->ErrorString(); } else { $expectedResponseHash = md5($terminalId.$response->MerchantReference().$response->CardReference().$response->CardType().$response->CardExpiry().$response->CardHolderName().$response->DateTime().$secret); if($expectedResponseHash != $response->Hash()) { echo 'SECURECARD SEARCH FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if your card details were stored.'; $getMerchantReference = $response->MerchantReference(); if(isset($getMerchantReference)) { echo 'Please quote Nuvei Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $response->MerchantReference() . ' when mailling or calling.'; } } else { # Use/Save $response->MerchantReference(), $response->CardReference(), $response->CardType(), $response->CardExpiry(), $response->CardHolderName(). echo "SecureCard successfull details found."; } } ?>