1

I'm using PHP to setup a Direct Debit Mandate via the GoCardless API, but I cannot figure out how to automatically setup a subscription against that mandate.

First I create a billing request:

$br = $client->billingRequests()->create([
  "params" => [
    "mandate_request" => [
      "scheme" => "bacs",
      "currency" => "GBP",
    ]
  ]
]);

Then I create a Billing Request Flow:

$brf = $client->billingRequestFlows()->create([
  "params" => [
    "redirect_uri" => "http://localhost/success",
    "exit_uri" => "http://localhost/exit",
    "links" => [
      "billing_request" => $br->id
    ],
    "prefilled_customer" => [
          "email" => "alice@example.com",
          "given_name" => "Alice",
          "family_name" => "Smith",
    ],
  ]
]);

Then I redirect the customer to the authorization URL:

header("Location: " . $brf->authorisation_url);

The customer completes their details on the GoCardless hosted page, which sets up a mandate, but no payment is taken. I have to manually login to the dashboard to assign a subscription against the customer's mandate.

What I would like to do is create/assign the subscription at the same time as creating the mandate. This doesn't look to be possible, but I am wondering what other options are available. It seems strange to have to assign the subscription manually after the mandate is created.

MrCarrot
  • 2,546
  • 1
  • 23
  • 29

0 Answers0