GoCardless Subscription process via API and redirect_flow

606 views Asked by At

I am successfully creating the customer and the subscription via the API using the redirect_flow method BUT:

  1. There are no payments being paid/setup as far as I can tell using this process
  2. If I don't add a start date it says the DD starts on the next available date and not when the DD has been set up (which is the next year as its a yearly DD).

I can't find in the API the actual process that's required to successfully set up this process. This is the subscription I send/setup:

            jData = ""
            jData = jData & "{"
            jData = jData & " ""subscriptions"": {"
            jData = jData & " ""amount"": 25.00,"
            jData = jData & " ""currency"": ""GBP"","
            jData = jData & " ""name"": ""Yearly Subscription"","
            jData = jData & " ""start_date"": ""2021-01-27"","
            jData = jData & " ""interval"": 1,"
            jData = jData & " ""interval_unit"": ""yearly"","
            jData = jData & " ""month"": ""january"","
            jData = jData & " ""day_of_month"": 20,"
            jData = jData & " ""metadata"": {"
            jData = jData & " ""account_id"": ""acc1234"""
            jData = jData & " },"
            jData = jData & " ""links"": {"
            jData = jData & " ""mandate"": ""theirmadateid"""
            jData = jData & " }"
            jData = jData & " }"
            jData = jData & "}"

I was hoping the start date would be the first payment. Do I need to setup the first payment in this process and then the DD will take the next one in 2022?

So the process being:

  1. setup the customer
  2. setup the first payment for the DD
  3. setup the DD

OR

  1. Set up the customer
  2. Setup the DD
  3. Setup the first payment for that DD

These are the JSON details in the GoCardless control panel with regards to the subscription:

{
  "id": "AD12345",
  "created_at": "2021-01-20T09:48:01.443Z",
  "amount": 2500,
  "currency": "GBP",
  "status": "active",
  "name": "Subscription of 25.00 GBP - Once per Year via Direct Debit",
  "start_date": "2021-01-27",
  "end_date": null,
  "interval": 1,
  "interval_unit": "yearly",
  "day_of_month": 20,
  "month": "january",
  "count": null,
  "metadata": {
    "account_id": "1234"
  },
  "payment_reference": null,
  "upcoming_payments": [
    {
      "charge_date": "2022-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2023-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2024-01-22",
      "amount": 2500
    },
    {
      "charge_date": "2025-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2026-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2027-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2028-01-20",
      "amount": 2500
    },
    {
      "charge_date": "2029-01-22",
      "amount": 2500
    },
    {
      "charge_date": "2030-01-21",
      "amount": 2500
    },
    {
      "charge_date": "2031-01-20",
      "amount": 2500
    }
  ],
  "app_fee": null,
  "links": {
    "mandate": "MD00001"
  },
  "retry_if_possible": false,
  "earliest_charge_date_after_resume": null,
  "app_name": null,
  "amount_can_be_updated": true,
  "fx": {
    "fx_currency": null,
    "fx_amount": null,
    "exchange_rate": null,
    "estimated_exchange_rate": null
  }
}

As you can see it's not starting to take a payment until 2022.

Any help appreciated?

2

There are 2 answers

0
srob On

You've set the "day_of_month":20 and "month":"january" which has already passed in this instance so the next 20th January is 2022.

You can remove this from the request and just use the start_date field, it will then be on or around the start date for future payments.

Alternatively if you want to set a different start date to the future transaction dates then you would need to make a create->payment call and then create->subscription to start in 2022.

0
Chunks On

As srob has said, you can't start the DD on the same day, so all I did was state the date of the DD to start as 7 days in the future and it all worked.