Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expiration date property for payments #60

Closed
MatthiasBrodelet opened this issue Sep 25, 2024 · 2 comments
Closed

Add expiration date property for payments #60

MatthiasBrodelet opened this issue Sep 25, 2024 · 2 comments

Comments

@MatthiasBrodelet
Copy link

I want to change the default expire time of the SEPA bank transfers.
By default this is 14 days. (https://docs.mollie.com/docs/bank-transfer)

Mollie has a property with which you can set the expire date for the payment called expiresAt. (https://docs.mollie.com/reference/create-payment)
Unfortunately it does not seem like this plugin lets me edit this property.

I found the EVENT_BEFORE_SEND_PAYMENT_REQUEST event in the omnipay plugin which I used to do the following.

        Event::on(
            \craft\commerce\omnipay\base\Gateway::class,
            \craft\commerce\omnipay\base\Gateway::EVENT_BEFORE_SEND_PAYMENT_REQUEST,
            function(SendPaymentRequestEvent $event) {
                $event->modifiedRequestData = $event->requestData;
                $event->modifiedRequestData['expiresAt'] = "2024-09-28T09:28:37+00:00";
            }
        );

However this does not work.
The description property is editable but not the expiresAt property.
Can this be added please?

Copy link

linear bot commented Sep 25, 2024

@nfourtythree
Copy link
Contributor

Hi @MatthiasBrodelet

Thank you for your feedback.

We have just released version 4.2.0 of the commerce-omnipay library which this plugin uses.

In that release we have included a new event EVENT_BUILD_GATEWAY_REQUEST. This falls in line with other gateway plugin and gives developers the opportunity to modify the request data that will be sent to the payment provider.

You should be able to run composer update in your project to get the latest version of the library.

With that you will be able to adjust your code as follows:

Event::on(
    \craft\commerce\omnipay\base\Gateway::class,
    \craft\commerce\omnipay\base\Gateway::EVENT_BUILD_GATEWAY_REQUEST,
    function(\craft\commerce\omnipay\events\BuildGatewayRequestEvent $event) {
        $event->request['expiresAt'] = "2024-09-28T09:28:37+00:00";
    }
);

Hope this helps, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants