# Create a hosted page to view Boleto vouchers

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


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

Creates a `hosted_page` resource of type, `view_voucher` . When your end customers choose the Boleto payment method, you can generate a voucher for their pending invoice. Using this API, you can create a voucher\_detail hosted page for your customers and email them a link to this hosted page. Your customers can review the voucher details on the page by clicking the link in the email.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/view_voucher \
     -u {site_api_key}:\
     -d "payment_voucher[id]"="__test__KyVnHhSBWmCoF2tJ" \
     -d "customer[locale]"="fr-CA"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.ViewVoucher()
		.PaymentVoucherId("__test__KyVnHhSBWmCoF2tJ")
		.CustomerLocale("fr-CA")
		.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.ViewVoucher(&hostedpage.ViewVoucherRequestParams{
        PaymentVoucher : &hostedpage.ViewVoucherPaymentVoucherParams{
            Id : "__test__KyVnHhSBWmCoF2tJ",
        },
        Customer : &hostedpage.ViewVoucherCustomerParams{
            Locale : "fr-CA",
        },
    }).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.HostedPageViewVoucherRequest{
    PaymentVoucher : &chargebee.HostedPageViewVoucherPaymentVoucher{
        Id : "__test__KyVnHhSBWmCoF2tJ",
    },
    Customer : &chargebee.HostedPageViewVoucherCustomer{
        Locale : "fr-CA",
    },
}
  res, err := client.HostedPage.ViewVoucher(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.viewVoucher()
            .paymentVoucherId("__test__KyVnHhSBWmCoF2tJ")
            .customerLocale("fr-CA")
            .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.HostedPageViewVoucherParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageViewVoucherResponse;

public class HostedPageViewVoucher {

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

        HostedPageViewVoucherParams.PaymentVoucherParams paymentVoucherParams =
            HostedPageViewVoucherParams.PaymentVoucherParams.builder()
                .id("__test__KyVnHhSBWmCoF2tJ")
                .build();

        HostedPageViewVoucherParams.CustomerParams customerParams =
            HostedPageViewVoucherParams.CustomerParams.builder()
                .locale("fr-CA")
                .build();

        HostedPageViewVoucherParams params = HostedPageViewVoucherParams.builder()
            .paymentVoucher(paymentVoucherParams)
            .customer(customerParams)
            .build();

        HostedPageViewVoucherResponse response = client.hostedPages().viewVoucher(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.viewVoucher({
        payment_voucher: {
            id: "__test__KyVnHhSBWmCoF2tJ"
        },
        customer: {
            locale: "fr-CA"
        }
    });

    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()->viewVoucher([
    "payment_voucher" => [
        "id" => "__test__KyVnHhSBWmCoF2tJ"
    ],
    "customer" => [
        "locale" => "fr-CA"
    ]
]);
$hostedPage = $result->hosted_page;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.HostedPage.view_voucher(
    cb_client.HostedPage.ViewVoucherParams(
        payment_voucher=cb_client.HostedPage.ViewVoucherPaymentVoucherParams(
            id="__test__KyVnHhSBWmCoF2tJ"
        ),
        customer=cb_client.HostedPage.ViewVoucherCustomerParams(
            locale="fr-CA"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.view_voucher({
  :payment_voucher => {
    :id => "__test__KyVnHhSBWmCoF2tJ"
  },
  :customer => {
    :locale => "fr-CA"
  }
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "id": "__dev__6FL1CcdDKgO1Eui9ys7pkFDirQcu5twVhX",
    "type": "voucher_detail",
    "url": "https://yourapp.chargebee.com/pages/v3/__test__4cq9mwW1cuoD085nSBLh0KUMKdphVO5cC/view_voucher",
    "state": "created",
    "embed": false,
    "created_at": 1653044153,
    "expires_at": 1653047753,
    "object": "hosted_page"
  }
}
```

## URL Format

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

## Input Parameters

- `payment_voucher` (optional, string)
  Parameters for payment\_voucher
  - `id` (required, string, max chars=40)
    The unique [ID of the voucher](/docs/api/payment_vouchers/payment_voucher-object#id) which the customer wants to view.

- `customer` (optional, string)
  Parameters for customer
  - `locale` (optional, string, max chars=50)
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.

## Returns

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