mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-11 15:34:21 -04:00
Update Checkout.com customer on successful payment
This commit is contained in:
parent
849a9dc113
commit
753c9c4239
@ -173,10 +173,6 @@ class CreditCard implements MethodInterface
|
|||||||
if ($request->has('token') && ! is_null($request->token) && ! empty($request->token)) {
|
if ($request->has('token') && ! is_null($request->token) && ! empty($request->token)) {
|
||||||
return $this->attemptPaymentUsingToken($request);
|
return $this->attemptPaymentUsingToken($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->checkout->company_gateway->update_details) {
|
|
||||||
$this->checkout->updateCustomer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->attemptPaymentUsingCreditCard($request);
|
return $this->attemptPaymentUsingCreditCard($request);
|
||||||
}
|
}
|
||||||
@ -235,8 +231,13 @@ class CreditCard implements MethodInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $this->checkout->gateway->getPaymentsClient()->requestPayment($paymentRequest);
|
$response = $this->checkout->gateway->getPaymentsClient()->requestPayment($paymentRequest);
|
||||||
|
|
||||||
|
if($this->checkout->company_gateway->update_details && isset($response['customer'])) {
|
||||||
|
$this->checkout->updateCustomer($response['customer']['id'] ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
if ($response['status'] == 'Authorized') {
|
if ($response['status'] == 'Authorized') {
|
||||||
|
|
||||||
return $this->processSuccessfulPayment($response);
|
return $this->processSuccessfulPayment($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,9 +329,11 @@ class CheckoutComPaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCustomer()
|
public function updateCustomer($customer_id = null)
|
||||||
{
|
{
|
||||||
nlog("merp");
|
|
||||||
|
if(!$customer_id)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -343,7 +345,9 @@ class CheckoutComPaymentDriver extends BaseDriver
|
|||||||
$request->name = $this->client->present()->name();
|
$request->name = $this->client->present()->name();
|
||||||
$request->phone = $phone;
|
$request->phone = $phone;
|
||||||
|
|
||||||
$response = $this->gateway->getCustomersClient()->update("customer_id", $request);
|
$response = $this->gateway->getCustomersClient()->update($customer_id, $request);
|
||||||
|
|
||||||
|
|
||||||
} catch (CheckoutApiException $e) {
|
} catch (CheckoutApiException $e) {
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
} catch (CheckoutAuthorizationException $e) {
|
} catch (CheckoutAuthorizationException $e) {
|
||||||
@ -384,10 +388,6 @@ class CheckoutComPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
if($this->company_gateway->update_details) {
|
|
||||||
$this->updateCustomer();
|
|
||||||
}
|
|
||||||
|
|
||||||
$paymentRequest = $this->bootTokenRequest($cgt->token);
|
$paymentRequest = $this->bootTokenRequest($cgt->token);
|
||||||
$paymentRequest->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode());
|
$paymentRequest->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode());
|
||||||
$paymentRequest->reference = '#'.$invoice->number.' - '.now();
|
$paymentRequest->reference = '#'.$invoice->number.' - '.now();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user