mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-21 00:41:34 +02:00
checkout token billing
This commit is contained in:
parent
d7277b7c6d
commit
8bbfbbb9e1
@ -55,7 +55,7 @@ trait Utilities
|
||||
return round($amount * 100);
|
||||
}
|
||||
|
||||
private function processSuccessfulPayment(Payment $_payment, $return_payment = false)
|
||||
private function processSuccessfulPayment(Payment $_payment)
|
||||
{
|
||||
if ($this->getParent()->payment_hash->data->store_card) {
|
||||
$this->storePaymentMethod($_payment);
|
||||
@ -78,10 +78,6 @@ trait Utilities
|
||||
$this->getParent()->client
|
||||
);
|
||||
|
||||
if ($return_payment) {
|
||||
return $payment;
|
||||
}
|
||||
|
||||
return redirect()->route('client.payments.show', ['payment' => $this->getParent()->encodePrimaryKey($payment->id)]);
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,9 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||
|
||||
$request = new PaymentResponseRequest();
|
||||
$request->setMethod('POST');
|
||||
$request->request->add(['payment_hash' => $payment_hash]);
|
||||
$request->request->add(['payment_hash' => $payment_hash->hash]);
|
||||
|
||||
$this->setPaymentHash($payment_hash);
|
||||
|
||||
try {
|
||||
$response = $this->gateway->payments()->request($payment);
|
||||
@ -221,7 +223,24 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||
if ($response->status == 'Authorized') {
|
||||
$this->confirmGatewayFee($request);
|
||||
|
||||
return $this->processSuccessfulPayment($response, true);
|
||||
$data = [
|
||||
'payment_method' => $response->source['id'],
|
||||
'payment_type' => PaymentType::parseCardType(strtolower($response->source['scheme'])),
|
||||
'amount' => $amount,
|
||||
'transaction_reference' => $response->id,
|
||||
];
|
||||
|
||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => $response, 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_CHECKOUT,
|
||||
$this->client
|
||||
);
|
||||
|
||||
return $payment;
|
||||
}
|
||||
|
||||
if ($response->status == 'Declined') {
|
||||
@ -230,17 +249,46 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||
PaymentFailureMailer::dispatch(
|
||||
$this->client, $response->response_summary,
|
||||
$this->client->company,
|
||||
$this->payment_hash->data->value
|
||||
$amount
|
||||
);
|
||||
|
||||
$this->processUnsuccessfulPayment($response, false);
|
||||
PaymentFailureMailer::dispatch(
|
||||
$this->client,
|
||||
$response,
|
||||
$this->client->company,
|
||||
$amount
|
||||
);
|
||||
|
||||
$message = [
|
||||
'server_response' => $response,
|
||||
'data' => $payment_hash->data,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$message,
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_CHECKOUT,
|
||||
$this->client
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception | CheckoutHttpException $e) {
|
||||
$this->unWindGatewayFees($payment_hash);
|
||||
$message = $e instanceof CheckoutHttpException
|
||||
? $e->getBody()
|
||||
: $e->getMessage();
|
||||
|
||||
// ..
|
||||
$data = [
|
||||
'status' => '',
|
||||
'error_type' => '',
|
||||
'error_code' => $e->getCode(),
|
||||
'param' => '',
|
||||
'message' => $message,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_CHECKOUT, $this->client);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user