mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 05:14:30 -04:00
Working on Mollie webhooks
This commit is contained in:
parent
19d2e6aa61
commit
14e4b5121e
@ -4,6 +4,7 @@ namespace App\Ninja\PaymentDrivers;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use App\Models\Invitation;
|
use App\Models\Invitation;
|
||||||
|
use App\Models\Payment;
|
||||||
|
|
||||||
class MolliePaymentDriver extends BasePaymentDriver
|
class MolliePaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
@ -19,42 +20,38 @@ class MolliePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
public function completeOffsitePurchase($input)
|
public function completeOffsitePurchase($input)
|
||||||
{
|
{
|
||||||
$details = $this->paymentDetails();
|
// payment is created by the webhook
|
||||||
$details['transactionReference'] = $this->invitation->transaction_reference;
|
|
||||||
|
|
||||||
$response = $this->gateway()->fetchTransaction($details)->send();
|
|
||||||
|
|
||||||
if ($response->isCancelled() || ! $response->isSuccessful()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createPayment($response->getTransactionReference());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleWebHook($input)
|
public function handleWebHook($input)
|
||||||
{
|
{
|
||||||
$ref = array_get($input, 'id');
|
$ref = array_get($input, 'id');
|
||||||
$invitation = Invitation::whereAccountId($this->accountGateway->account_id)
|
|
||||||
->whereTransactionReference($ref)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($invitation) {
|
|
||||||
$this->invitation = $invitation;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'transactionReference' => $ref
|
'transactionReference' => $ref
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->gateway()->fetchTransaction($data)->send();
|
$response = $this->gateway()->fetchTransaction($data)->send();
|
||||||
|
|
||||||
if ($response->isCancelled() || ! $response->isSuccessful()) {
|
if ($response->isPaid() || $response->isPaidOut()) {
|
||||||
|
$invitation = Invitation::whereAccountId($this->accountGateway->account_id)
|
||||||
|
->whereTransactionReference($ref)
|
||||||
|
->first();
|
||||||
|
if ($invitation) {
|
||||||
|
$this->invitation = $invitation;
|
||||||
|
$this->createPayment($ref);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// check if payment has failed
|
||||||
|
$payment = Payment::whereAccountId($this->accountGateway->account_id)
|
||||||
|
->whereTransactionReference($ref)
|
||||||
|
->first();
|
||||||
|
if ($payment) {
|
||||||
|
$payment->markFailed($response->getStatus());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->createPayment($ref);
|
|
||||||
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user