How to intersect api request data and option set – APIs


Hello everyone,

I’m a bit stuck with integrating subscription plans into my app. Could you please help?

Unfortunately, I can’t use Stripe (it would have been much easier). I am using a different payment gateway via an API.

I have several paid plans. They differ in price and duration. I have added each plan to Option Sets.
image

For the payment, I provide the amount and the description. In return, I receive the amount, the description, and the payment date.

{
    "body": {
        "type": "notification",
        "event": "payment.succeeded",
        "object": {
            "id": "2dc4ba82-000f-5000-9000-13c2",
            "status": "succeeded",
            "amount": {
                "value": "299.00",
                "currency": "USD"
            },
            "income_amount": {
                "value": "288.53",
                "currency": "USD"
            },
            "description": "Starter",
            "recipient": {
                "account_id": "378602",
                "gateway_id": "2238509"
            },
            "captured_at": "2024-05-01T20:32:15.518Z",
            "created_at": "2024-05-01T20:32:02.299Z",
            "test": true,

How can I match the data from the payment system’s response by the description of the plan in order to add the correct number of days to the duration of the plan? Like “captured_at”+days in option expiry value

after you make sure the ‘captured at’ is received as a date (or UNIX time), You should separate to two actions, on the first one you set the plan according to the description received by the api. On the second one, make changes to the subscription plan you created (result of step 1) and:
Expiry date = captured at: plus days: this subscription plan's Plan name's Expiry



Source link

Leave a Comment