mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Enable Mollie webhooks
This commit is contained in:
parent
ac8938eea9
commit
028b20fcdb
@ -3,6 +3,7 @@
|
|||||||
namespace App\Ninja\PaymentDrivers;
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use App\Models\Invitation;
|
||||||
|
|
||||||
class MolliePaymentDriver extends BasePaymentDriver
|
class MolliePaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
@ -10,9 +11,8 @@ class MolliePaymentDriver extends BasePaymentDriver
|
|||||||
{
|
{
|
||||||
$data = parent::paymentDetails($paymentMethod);
|
$data = parent::paymentDetails($paymentMethod);
|
||||||
|
|
||||||
// Enable the webhooks
|
// Enable webhooks
|
||||||
//$data['notifyUrl'] = $data['returnUrl'];
|
$data['notifyUrl'] = url('/payment_hook/'. $this->account()->account_key . '/' . GATEWAY_MOLLIE);
|
||||||
$data['notifyUrl'] = url('/payment_hook/'. $this->account->account_key . '/' . GATEWAY_MOLLIE);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -20,18 +20,12 @@ class MolliePaymentDriver extends BasePaymentDriver
|
|||||||
public function completeOffsitePurchase($input)
|
public function completeOffsitePurchase($input)
|
||||||
{
|
{
|
||||||
$details = $this->paymentDetails();
|
$details = $this->paymentDetails();
|
||||||
|
|
||||||
$details['transactionReference'] = $this->invitation->transaction_reference;
|
$details['transactionReference'] = $this->invitation->transaction_reference;
|
||||||
|
|
||||||
$response = $this->gateway()->fetchTransaction($details)->send();
|
$response = $this->gateway()->fetchTransaction($details)->send();
|
||||||
|
|
||||||
\Log::info('completeOffsitePurchase');
|
if ($response->isCancelled() || ! $response->isSuccessful()) {
|
||||||
\Log::info($response);
|
|
||||||
|
|
||||||
if ($response->isCancelled()) {
|
|
||||||
return false;
|
return false;
|
||||||
} elseif (! $response->isSuccessful()) {
|
|
||||||
throw new Exception($response->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createPayment($response->getTransactionReference());
|
return $this->createPayment($response->getTransactionReference());
|
||||||
@ -39,12 +33,29 @@ class MolliePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
public function handleWebHook($input)
|
public function handleWebHook($input)
|
||||||
{
|
{
|
||||||
//$paymentId = array_get($input, 'id');
|
$ref = array_get($input, 'id');
|
||||||
$response = $this->gateway()->fetchTransaction($input)->send();
|
$invitation = Invitation::whereAccountId($this->accountGateway->account_id)
|
||||||
|
->whereTransactionReference($ref)
|
||||||
|
->first();
|
||||||
|
|
||||||
\Log::info('handleWebHook');
|
if ($invitation) {
|
||||||
\Log::info($response);
|
$this->invitation = $invitation;
|
||||||
return 'Processed successfully';
|
} 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