I have an issue where an API key that is needed for the payment gateway to operate expires after 12 months.
You obtain the Api Key via an API call to which you pass the Api Key ID. The Api Key ID is one of the Payment Provider settings.
In code, I check to see if the Api Key has expired (or is about to) and create a new one, then delete the old one (procedure defined by the provider).
The issue is that the new Api Key will have a new Api Key ID. So, ideally, I want to update the value in the Payment Provider settings - can I do that? Otherwise, after 12 months, the call to get the Api Key using the Api Key ID will always fail with "404 - Key not found", which I can work around but is not ideal.
You can access payment methods in code sure, you can either get them straight off the VendrApi or inject the PaymentMethodService. Much like everything else, you can make it writable and then assign the property values you need to update.
Not sure when in code you are wanting to do this, but sounds like maybe a scheduled background task could work here.
Set Payment Provider setting via code
I have an issue where an API key that is needed for the payment gateway to operate expires after 12 months.
You obtain the Api Key via an API call to which you pass the Api Key ID. The Api Key ID is one of the Payment Provider settings.
In code, I check to see if the Api Key has expired (or is about to) and create a new one, then delete the old one (procedure defined by the provider).
The issue is that the new Api Key will have a new Api Key ID. So, ideally, I want to update the value in the Payment Provider settings - can I do that? Otherwise, after 12 months, the call to get the Api Key using the Api Key ID will always fail with "404 - Key not found", which I can work around but is not ideal.
Hey Gordon,
You can access payment methods in code sure, you can either get them straight off the
VendrApi
or inject thePaymentMethodService
. Much like everything else, you can make it writable and then assign the property values you need to update.Not sure when in code you are wanting to do this, but sounds like maybe a scheduled background task could work here.
is working on a reply...