createPaymentRequest: userIP not known in Console
smetje opened this issue · 4 comments
Performing a gateway request doesn't work in Console.
I'm extending the Multisafepay plugin to work with webhooks.
When a payment is made with Bancontact Mobile 2 requests from MSP are made at the same time, because of that a success Transaction can be added twice. This results in adding the payment twice.
To make sure this can't happen I want to add the webhooks to the queue and ensure a success transaction can't be created twice.
The 'createRequest' (in base/Gateway.php), who is used for every request possible, always performs 'createPaymentRequest'. (sidenote: is this always necessary?)
The 'createPaymentRequest' requires a 'clientIp' and gets it from Craft::$app->getRequest()->userIP
. This is where we get an error when using Console (read queue jobs). The userIP isn't known in the Console request.
A simple fix could be:
'clientIp' => (property_exists(Craft::$app->getRequest(), 'userIP')? Craft::$app->getRequest()->userIP : ''),
@andris-sevcenko any news on this?
If you could submit a pull request, we’d appreciate it!
Just released 2.0.1 with the fix for this.
Thanks!