1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Token and Refunding from eWay

This commit is contained in:
David Bomba 2021-07-27 15:41:31 +10:00
parent b061506091
commit 9ef77e8b53
2 changed files with 34 additions and 2 deletions

View File

@ -182,7 +182,6 @@ class User extends Authenticatable implements MustVerifyEmail
return $company_token->company;
}
// return false;
throw new \Exception('No Company Found');
//return Company::find(config('ninja.company_id'));

View File

@ -91,7 +91,40 @@ class EwayPaymentDriver extends BaseDriver
public function refund(Payment $payment, $amount, $return_client_response = false)
{
return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here
$refund = [
'Refund' => [
'TransactionID' => $payment->transaction_reference,
'TotalAmount' => $this->convertAmount($amount)
],
];
$response = $this->init()->eway->client->refund($refund);
$transaction_reference = '';
$refund_status = true;
$refund_message = '';
if ($response->TransactionStatus) {
$transaction_reference = $response->TransactionID;
} else {
if ($response->getErrors()) {
foreach ($response->getErrors() as $error) {
$refund_status = false;
$refund_message = \Eway\Rapid::getMessage($error);
}
} else {
$refund_status = false;
$refund_message 'Sorry, your refund failed';
}
}
return [
'transaction_reference' => $response->TransactionID,
'transaction_response' => json_encode($response),
'success' => $refund_status,
'description' => $refund_message,
'code' => '',
];
}
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)