> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gr4vy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Listing payment options

Next, you can use the payment options endpoint to determine which payment
options can be shown at checkout for the combination of `amount`, `currency`, `country`, `cart_items`
and `metadata` should be displayed in your checkout.

The [payment options API endpoint](/reference/payment-options/list-payment-options) makes it
easy to get a list of payment options.

<CodeGroup>
  ```csharp C# theme={"system"}
  using Gr4vy;
  using Gr4vy.Models.Components;

  var sdk = new Gr4vySDK(
      id: "example",
      server: SDKConfig.Server.Sandbox,
      bearerAuthSource: Auth.WithToken(privateKey),
      merchantAccountId: "default"
  );

  var res = await sdk.PaymentOptions.ListAsync(paymentOptionRequest: new PaymentOptionRequest() {});

  // handle response
  ```

  ```go Go theme={"system"}
  package main

  import(
  	"context"
  	gr4vygo "github.com/gr4vy/gr4vy-go"
  	"os"
  	"github.com/gr4vy/gr4vy-go/models/components"
  	"log"
  )

  func main() {
      ctx := context.Background()

      privateKey := "...."
  	withToken := gr4vy.WithToken(privateKey, []JWTScope{ReadAll, WriteAll}, 60)

  	s := gr4vy.New(
  		gr4vy.WithID("example"),
  		gr4vy.WithServer(gr4vy.ServerSandbox),
  		gr4vy.WithSecuritySource(withToken),
  		gr4vy.WithMerchantAccountID("default"),
  	)

      res, err := s.PaymentOptions.List(ctx, components.PaymentOptionRequest{})
      if err != nil {
          log.Fatal(err)
      }
      if res != nil {
          // handle response
      }
  }
  ```

  ```java Java theme={"system"}
  package hello.world;

  import java.lang.Exception;
  import com.gr4vy.sdk.BearerSecuritySource;
  import com.gr4vy.sdk.Gr4vy;
  import com.gr4vy.sdk.Gr4vy.AvailableServers;
  import org.openapis.openapi.models.components.PaymentOptionRequest;
  import org.openapis.openapi.models.errors.*;
  import org.openapis.openapi.models.operations.ListPaymentOptionsResponse;

  public class Application {

      public static void main(String[] args) throws Exception {

          Gr4vy sdk = Gr4vy.builder()
                  .id("example")
                  .server(AvailableServers.SANDBOX)
                  .merchantAccountId("default")
                  .securitySource(new BearerSecuritySource.Builder(privateKey).build())
              .build();

          ListPaymentOptionsResponse res = sdk.paymentOptions().list()
                  .paymentOptionRequest(PaymentOptionRequest.builder()
                      .build())
                  .call();

          if (res.paymentOptions().isPresent()) {
              // handle response
          }
      }
  }
  ```

  ```php PHP theme={"system"}
  declare(strict_types=1);

  require 'vendor/autoload.php';

  use Gr4vy;
  use Gr4vy\Auth;

  , 
  $privateKey = "..."; 

  $sdk = Gr4vy\SDK::builder()
      -\u003esetId('example')
      -\u003esetServer('sandbox')
      -\u003esetSecuritySource(Auth::withToken($privateKey))
      -\u003esetMerchantAccountId('default')
      -\u003ebuild();

  $paymentOptionRequest = new Gr4vy\PaymentOptionRequest();

  $response = $sdk->paymentOptions->list(
      paymentOptionRequest: $paymentOptionRequest
  );

  if ($response->paymentOptions !== null) {
      // handle response
  }
  ```

  ```python Python theme={"system"}
  from gr4vy import Gr4vy, auth
  import os


  with Gr4vy(
      id="example",
      server="production",
      merchant_account_id="default",
      bearer_auth=auth.with_token(open("./private_key.pem").read())
  ) as g_client:

      res = g_client.payment_options.list(locale="en")

      # Handle response
      print(res)
  ```

  ```ts TypeScript theme={"system"}
  import { Gr4vy } from "@gr4vy/sdk";

  const gr4vy = new Gr4vy({
      server: "sandbox",
      id: "example",
      bearerAuth: withToken({
        privateKey: fs.readFileSync("private_key.pem", "utf8"),
      }),
  });

  async function run() {
    const result = await gr4vy.paymentOptions.list({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Info>
  This API automatically uses your checkout Flow rules
  to limit these results.
</Info>

Each payment option includes the `method`, `icon_url`, `label` and other useful information
on supported features that you can use to display the options on your checkout.

<CodeGroup>
  ```bash Response theme={"system"}
  {
      "items": [
          {
              "type": "payment-option",
              "method": "card",
              "icon_url": "https://cdn.sandbox.example.gr4vy.app/assets/icons/payment-methods/card.svg",
              "mode": "card",
              "label": "Card",
              "can_store_payment_method": true,
              "can_delay_capture": true,
              "context": {
                  "approval_ui": {
                      "height": "589px",
                      "width": "500px"
                  },
                  "required_fields": {}
              }
          },
          {
              "type": "payment-option",
              "method": "paypal",
              "icon_url": "https://cdn.sandbox.example.gr4vy.app/assets/icons/payment-methods/paypal.svg",
              "mode": "redirect",
              "label": "PayPal",
              "can_store_payment_method": true,
              "can_delay_capture": true,
              "context": {
                  "approval_ui": {
                      "height": "589px",
                      "width": "500px"
                  },
                  "required_fields": {}
              }
          },
          {
              "type": "payment-option",
              "method": "alipay",
              "icon_url": "https://cdn.sandbox.example.gr4vy.app/assets/icons/payment-methods/alipay.svg",
              "mode": "redirect",
              "label": "Alipay",
              "can_store_payment_method": true,
              "can_delay_capture": false,
              "context": {
                  "approval_ui": {
                      "height": "589px",
                      "width": "500px"
                  },
                  "required_fields": {}
              }
          }
      ]
  }
  ```
</CodeGroup>

<Note>
  This API supports an optional `locale` that can be set to get the `label` in your local language.
</Note>

Your app can now display these payment options on your checkout page.
To display the available options and allow your customer to checkout, use each label and icon, and then handle
the transaction according to the next step.

<Warning>
  Using [Secure Fields](/guides/payments/secure-fields) when working with cards is recommended as it reduces the PCI scope of the integration. If intending to use the API directly for card payments without Secure Fields then a PCI-DSS level 1 certification is required.
</Warning>

By implementing the payment options in this way you can fully utilize payment orchestration
while having all the flexibility on the design and layout.

## Summary

In this step you:

* Called the payment options endpoint
* Displayed the payment options on your checkout
