diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 186c38fefc41..1ed3c9c00453 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -151,7 +151,8 @@ class PaymentMethodController extends Controller event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars())); $payment_method->delete(); } catch (Exception $e) { - Log::error(json_encode($e)); + + nlog($e->getMessage()); return back(); } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php index 1adfb93b9273..004f8bac26dd 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php @@ -87,6 +87,7 @@ class AuthorizeCreateCustomer $request = new GetCustomerProfileRequest(); $request->setMerchantAuthentication($this->authorize->merchant_authentication); $request->setCustomerProfileId($profileIdRequested); + $controller = new GetCustomerProfileController($request); $response = $controller->executeWithApiResponse($this->authorize->merchant_authentication); @@ -105,7 +106,7 @@ class AuthorizeCreateCustomer echo "List of subscriptions:"; foreach($response->getSubscriptionIds() as $subscriptionid) echo $subscriptionid . "\n"; - + } } } diff --git a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php index 05264768246f..f65501daf7aa 100644 --- a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php +++ b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php @@ -18,10 +18,12 @@ use App\PaymentDrivers\AuthorizePaymentDriver; use net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest; use net\authorize\api\contract\v1\CustomerAddressType; use net\authorize\api\contract\v1\CustomerPaymentProfileType; +use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest; use net\authorize\api\contract\v1\GetCustomerPaymentProfileRequest; use net\authorize\api\contract\v1\OpaqueDataType; use net\authorize\api\contract\v1\PaymentType; use net\authorize\api\controller\CreateCustomerPaymentProfileController; +use net\authorize\api\controller\DeleteCustomerPaymentProfileController; use net\authorize\api\controller\GetCustomerPaymentProfileController; use stdClass; @@ -246,4 +248,37 @@ class AuthorizePaymentMethod throw new GenericPaymentDriverFailure('Error communicating with Authorize.net'); } } + + public function deletePaymentProfile($gateway_customer_reference, $payment_profile_id) { + + error_reporting(E_ALL & ~E_DEPRECATED); + + $this->authorize->init(); + + // Set the transaction's refId + $refId = 'ref' . time(); + + // Use an existing payment profile ID for this Merchant name and Transaction key + + $request = new DeleteCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setCustomerProfileId($gateway_customer_reference); + $request->setCustomerPaymentProfileId($payment_profile_id); + $controller = new DeleteCustomerPaymentProfileController($request); + + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + nlog("SUCCESS: Delete Customer Payment Profile SUCCESS :"); + } + else + { + nlog("ERROR : Delete Customer Payment Profile: Invalid response\n"); + $errorMessages = $response->getMessages()->getMessage(); + nlog("Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"); + } + + return $response; + } + } diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 06204a156384..a802e5d59712 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -156,6 +156,6 @@ class AuthorizePaymentDriver extends BaseDriver */ public function detach(ClientGatewayToken $token) { - // Authorize.net doesn't support this feature. + return (new AuthorizePaymentMethod($this))->deletePaymentProfile($token->gateway_customer_reference, $token->token); } }