Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1461 posts 1883 karma points
    Nov 10, 2022 @ 11:10
    Gordon Saxby
    0

    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.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 10, 2022 @ 15:51
    Matt Brailsford
    100

    Hey Gordon,

    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.

Please Sign in or register to post replies

Write your reply to:

Draft