# Retrieve direct debit agreement PDF

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

This is applicable only for Direct Debit via SEPA, Bacs, Bg Autogiro, BECS (for both Australia and New Zealand) and PAD. For Direct Debit, the customer needs to accept an agreement that allows the merchant to debit their bank account. This agreement PDF allows you to easily display scheme-rules compliant Direct Debit mandates to your customers.

This API retrieves the redirect link to the corresponding agreement for customers. The agreement PDF can be your "Thank You" page or sent by email to customers. Communicating this PDF to your customers is mandatory.

Customer locale is used to generate the PDF in the required language. If a customer language is not supported, the PDF is generated in English. Checkout the [list of languages](https://developer.gocardless.com/api-reference/#mandate-pdfs-create-a-mandate-pdf) supported by GoCardless.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/retrieve_agreement_pdf \
     -u {site_api_key}:\
     -d payment_source_id="pm___test__KyVnHhSBWmKRg2uT"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.RetrieveAgreementPdf()
		.PaymentSourceId("pm___test__KyVnHhSBWmKRg2uT")
		.Request();

HostedPage hostedPage = result.HostedPage;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    hostedpageAction "github.com/chargebee/chargebee-go/v3/actions/hostedpage"
    "github.com/chargebee/chargebee-go/v3/models/hostedpage"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := hostedpageAction.RetrieveAgreementPdf(&hostedpage.RetrieveAgreementPdfRequestParams{
        PaymentSourceId : "pm___test__KyVnHhSBWmKRg2uT",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.HostedPageRetrieveAgreementPdfRequest{
    PaymentSourceId : "pm___test__KyVnHhSBWmKRg2uT",
}
  res, err := client.HostedPage.RetrieveAgreementPdf(req)
      if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = HostedPage.retrieveAgreementPdf()
            .paymentSourceId("pm___test__KyVnHhSBWmKRg2uT")
            .request();

        HostedPage hostedPage = result.hostedPage();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.hostedPage.HostedPage;
import com.chargebee.v4.models.hostedPage.params.HostedPageRetrieveAgreementPdfParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageRetrieveAgreementPdfResponse;

public class HostedPageRetrieveAgreementPdf {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        HostedPageRetrieveAgreementPdfParams params = HostedPageRetrieveAgreementPdfParams.builder()
            .paymentSourceId("pm___test__KyVnHhSBWmKRg2uT")
            .build();

        HostedPageRetrieveAgreementPdfResponse response = client.hostedPages().retrieveAgreementPdf(params);

        HostedPage hostedPage = response.getHostedPage();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.hostedPage.retrieveAgreementPdf({
        payment_source_id: "pm___test__KyVnHhSBWmKRg2uT"
    });

    console.log(result);
    const hostedPage = result.hosted_page;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->hostedPage()->retrieveAgreementPdf([
    "payment_source_id" => "pm___test__KyVnHhSBWmKRg2uT"
]);
$hostedPage = $result->hosted_page;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.HostedPage.retrieve_agreement_pdf(
    cb_client.HostedPage.RetrieveAgreementPdfParams(
        payment_source_id="pm___test__KyVnHhSBWmKRg2uT"
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::HostedPage.retrieve_agreement_pdf({
  :payment_source_id => "pm___test__KyVnHhSBWmKRg2uT"
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "created_at": 1517506018,
    "embed": false,
    "expires_at": 1520098018,
    "id": "__test__AUCK2LNxny5cXiA1JcdBQE9283e5McdvCC",
    "object": "hosted_page",
    "resource_version": 1517506018000,
    "state": "created",
    "type": "agreement_pfd",
    "updated_at": 1517506018,
    "url": "https://yourapp.chargebee.com/action_pages/__test__AUCK2LNxny5cXiA1JcdBQE9283e5McdvCC/agreement_pdf"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/hosted_pages/retrieve_agreement_pdf

## Input Parameters

- `payment_source_id` (required, string, max chars=40)
  Payment source to be used for this payment.

## Returns

- `hosted_page` (Hosted page object)
  Resource object representing hosted\_page
