mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Remove customer profile and payment profile if we are not storing tokens in auth.net
This commit is contained in:
parent
7d106f997a
commit
45edf58cf1
@ -22,6 +22,10 @@ use App\Models\PaymentType;
|
|||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\PaymentDrivers\AuthorizePaymentDriver;
|
use App\PaymentDrivers\AuthorizePaymentDriver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
|
||||||
|
use net\authorize\api\contract\v1\DeleteCustomerProfileRequest;
|
||||||
|
use net\authorize\api\controller\DeleteCustomerPaymentProfileController;
|
||||||
|
use net\authorize\api\controller\DeleteCustomerProfileController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AuthorizeCreditCard.
|
* Class AuthorizeCreditCard.
|
||||||
@ -69,16 +73,54 @@ class AuthorizeCreditCard
|
|||||||
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
|
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
|
||||||
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
|
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
|
||||||
|
|
||||||
|
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
|
||||||
|
|
||||||
if ($request->has('store_card') && $request->input('store_card') === true) {
|
if ($request->has('store_card') && $request->input('store_card') === true) {
|
||||||
$authorise_payment_method->payment_method = GatewayType::CREDIT_CARD;
|
$authorise_payment_method->payment_method = GatewayType::CREDIT_CARD;
|
||||||
$client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference);
|
$client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
|
//remove the payment profile
|
||||||
|
$this->removePaymentProfile($gateway_customer_reference, $payment_profile_id);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->handleResponse($data, $request);
|
return $this->handleResponse($data, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function removePaymentProfile($customer_profile_id, $customer_payment_profile_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$request = new DeleteCustomerPaymentProfileRequest();
|
||||||
|
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
|
||||||
|
$request->setCustomerProfileId($customer_profile_id);
|
||||||
|
$request->setCustomerPaymentProfileId($customer_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("unable to delete profile {$customer_profile_id} with payment id {$customer_payment_profile_id}");
|
||||||
|
|
||||||
|
// Delete a customer profile
|
||||||
|
$request = new DeleteCustomerProfileRequest();
|
||||||
|
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
|
||||||
|
$request->setCustomerProfileId( $customer_profile_id );
|
||||||
|
|
||||||
|
$controller = new DeleteCustomerProfileController($request);
|
||||||
|
$response = $controller->executeWithApiResponse($this->authorize->mode());
|
||||||
|
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
|
||||||
|
{
|
||||||
|
nlog("SUCCESS: Delete Customer Payment Profile SUCCESS");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nlog("unable to delete profile {$customer_profile_id}");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function processTokenPayment($request)
|
private function processTokenPayment($request)
|
||||||
{
|
{
|
||||||
$client_gateway_token = ClientGatewayToken::query()
|
$client_gateway_token = ClientGatewayToken::query()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user