mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 11:14:40 -04:00
Enable Mollie webhooks
This commit is contained in:
parent
29ba313086
commit
d40c222253
@ -618,6 +618,9 @@ class BasePaymentDriver
|
||||
$account = $this->account();
|
||||
$invitation = $this->invitation;
|
||||
$invoice = $this->invoice();
|
||||
if (! $invoice->canBePaid()) {
|
||||
return false;
|
||||
}
|
||||
$invoice->markSentIfUnsent();
|
||||
|
||||
$payment = Payment::createNew($invitation);
|
||||
|
@ -3,23 +3,59 @@
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
use Exception;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class MolliePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
{
|
||||
$data = parent::paymentDetails($paymentMethod);
|
||||
|
||||
// Enable webhooks
|
||||
$data['notifyUrl'] = url('/payment_hook/'. $this->account()->account_key . '/' . GATEWAY_MOLLIE);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function completeOffsitePurchase($input)
|
||||
{
|
||||
$details = $this->paymentDetails();
|
||||
|
||||
$details['transactionReference'] = $this->invitation->transaction_reference;
|
||||
|
||||
$response = $this->gateway()->fetchTransaction($details)->send();
|
||||
|
||||
if ($response->isCancelled()) {
|
||||
if ($response->isCancelled() || ! $response->isSuccessful()) {
|
||||
return false;
|
||||
} elseif (! $response->isSuccessful()) {
|
||||
throw new Exception($response->getMessage());
|
||||
}
|
||||
|
||||
return $this->createPayment($response->getTransactionReference());
|
||||
}
|
||||
|
||||
public function handleWebHook($input)
|
||||
{
|
||||
$ref = array_get($input, 'id');
|
||||
$invitation = Invitation::whereAccountId($this->accountGateway->account_id)
|
||||
->whereTransactionReference($ref)
|
||||
->first();
|
||||
|
||||
if ($invitation) {
|
||||
$this->invitation = $invitation;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'transactionReference' => $ref
|
||||
];
|
||||
$response = $this->gateway()->fetchTransaction($data)->send();
|
||||
|
||||
if ($response->isCancelled() || ! $response->isSuccessful()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->createPayment($ref);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user