function getSubscriptionStatus($subscriptionId) { $merchantAuthentication = $this->authorize(); $refId = 'ref' . time(); $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSubscriptionId($subscriptionId); $controller = new AnetController\ARBGetSubscriptionStatusController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); if ($response != null && $response->getMessages()->getResultCode() == "Ok") { return $response->getStatus(); } else { echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " . $errorMessages[0]->getText() . "\n"; return false; } // end else return $response; }
<?php require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("556KThWQ6vf2"); $merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq"); $refId = 'ref' . time(); $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSubscriptionId("100748"); $controller = new AnetController\ARBGetSubscriptionStatusController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null && $response->getMessages()->getResultCode() == "Ok") { echo "SUCCESS: Subscription Status : " . $response->getStatus() . "\n"; } else { echo "ERROR : Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " . $response->getMessages()->getMessage()[0]->getText() . "\n"; }
public function getSubscriptionStatus($subscriptionId, $refId) { // Common Set Up for API Credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(config('subscription.API_LOGIN_ID')); $merchantAuthentication->setTransactionKey(config('subscription.TRANSACTION_KEY')); $request = new AnetAPI\ARBGetSubscriptionStatusRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setSubscriptionId($subscriptionId); $controller = new AnetController\ARBGetSubscriptionStatusController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null && $response->getMessages()->getResultCode() == "Ok") { echo "SUCCESS: Subscription Status : " . $response->getStatus() . "\n"; } else { echo "ERROR : Invalid response\n"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } return $response; }