---
title: "PayBright for API only"
description: "Add PayBright to an existing API-only integration."
url: "https://docs.adyen.com/payment-methods/paybright/api-only"
source_url: "https://docs.adyen.com/payment-methods/paybright/api-only.md"
canonical: "https://docs.adyen.com/payment-methods/paybright/api-only"
last_modified: "2026-06-01T15:33:15+02:00"
language: "en"
---

# PayBright for API only

Add PayBright to an existing API-only integration.

[View source](/payment-methods/paybright/api-only.md)

PayBright has been acquired by [Affirm](/payment-methods/affirm). Adyen will not accept new PayBright integrations.

Accept PayBright payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page.

When making an PayBright payment, you also need to:

1. Collect shopper details, and specify these [in your payment request](#make-a-payment). PayBright uses these for risk checks.
2. Provide information about the purchased items by specifying `lineItems` [in your payment request](#make-a-payment).
3. [Handle the redirect result](#handle-the-redirect) after the shopper returns to your website.

## Requirements

| Requirement          | Description                                                                                                                                          |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Integration type** | Make sure that you have built an [API-only integration](/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=API%20only). |
| **Setup steps**      | Before you begin, [add PayBright in your test Customer Area](/payment-methods/add-payment-methods).                                                  |

## Build your payment form for PayBright

If you are using [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) to show which payment methods are available to the shopper,\
specify the following combinations of [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) and [amount.currency](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-amount) in your request:

| Country/region | `countryCode` | `amount.currency` |
| -------------- | ------------- | ----------------- |
| Canada         | **CA**        | **CAD**           |

We provide a PayBright logo which you can use on your payment form. For more information, refer to [Downloading logos](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#downloading-logos).

To perform risk checks, PayBright requires you to collect the following shopper details:

* Full name
* Date of birth
* Email address
* Phone number
* Billing address and delivery address.

## Make a payment

Make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request from your server, specifying:

* `paymentMethod`: **paybright**
* [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperName): The shopper's full name.
* [dateOfBirth](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-dateOfBirth): The shopper's date of birth.
* [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperEmail): The shopper's email address.
* [telephoneNumber](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-telephoneNumber): The shopper's phone number.
* [shopperLocale](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/payments__reqParam_shopperLocale)

  Optional

  : A combination of language code and country code to define which language should be used in the PayBright checkout page.
* [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-countryCode): The shopper's country. For example, `CA`.
* [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-billingAddress): The postal address to be included on the invoice.
* [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-deliveryAddress): The postal address where the purchased items will be shipped.
* [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems): Price and product information about the purchased items.
* [returnUrl](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-returnUrl): The URL where the shopper is redirected back to after completing the payment.

#### curl

```bash
curl https://checkout-test.adyen.com/v68/payments \
-H 'x-api-key: ADYEN_API_KEY' \
-H 'content-type: application/json' \
-d '{
    "merchantAccount": "ADYEN_MERCHANT_ACCOUNT",
    "reference": "YOUR_ORDER_REFERENCE",
    "paymentMethod": {
        "type": "paybright"
    },
    "amount": {
        "value": 6000,
        "currency": "CAD"
    },
    "shopperLocale": "en_CA",
    "countryCode": "CA",
    "telephoneNumber": "+16478491378",
    "shopperEmail": "s.hopper@adyen.com",
    "dateOfBirth": "1970-07-10",
    "shopperName": {
        "firstName": "Simon",
        "lastName": "Hopper"
    },
    "billingAddress": {
        "city": "Toronto",
        "country": "CA",
        "houseNumberOrName": "240",
        "postalCode": "M5V 2C5",
        "street": "Richmond St W",
        "stateOrProvince": "ON"
    },
    "deliveryAddress": {
        "city": "Toronto",
        "country": "CA",
        "houseNumberOrName": "240",
        "postalCode": "M5V 2C5",
        "street": "Richmond St W",
        "stateOrProvince": "ON"
    },
    "lineItems": [
        {
            "description": "Shoes",
            "quantity": "1",
            "amountIncludingTax": "4000",
            "amountExcludingTax": "3310",
            "taxCategory": "Low"
        },
        {
            "description": "Socks",
            "quantity": "2",
            "amountIncludingTax": "3000",
            "amountExcludingTax": "2480",
            "taxCategory": "Low"
        },
        {
            "description": "Discount",
            "amountExcludingTax": "-1000",
            "amountIncludingTax": "-1000",
            "quantity": "1",
            "taxCategory": "Low"
        }
    ],
    "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.."
}'
```

#### Java

```java
// Adyen Java API Library v27.0.0
import com.adyen.Client;
import com.adyen.enums.Environment;
import com.adyen.model.checkout.*;
import java.time.OffsetDateTime;
import java.util.*;
import com.adyen.model.RequestOptions;
import com.adyen.service.checkout.*;

// For the live environment, additionally include your liveEndpointUrlPrefix.
Client client = new Client("ADYEN_API_KEY", Environment.TEST);

// Create the request object(s)
Amount amount = new Amount()
  .currency("CAD")
  .value(6000L);

LineItem lineItem1 = new LineItem()
  .quantity(1L)
  .amountExcludingTax(3310L)
  .description("Shoes")
  .amountIncludingTax(4000L);

LineItem lineItem2 = new LineItem()
  .quantity(2L)
  .amountExcludingTax(2480L)
  .description("Socks")
  .amountIncludingTax(3000L);

LineItem lineItem3 = new LineItem()
  .quantity(1L)
  .amountExcludingTax(-1000L)
  .description("Discount")
  .amountIncludingTax(-1000L);

Name name = new Name()
  .firstName("Simon")
  .lastName("Hopper");

DeliveryAddress deliveryAddress = new DeliveryAddress()
  .country("CA")
  .stateOrProvince("ON")
  .city("Toronto")
  .houseNumberOrName("240")
  .street("Richmond St W")
  .postalCode("M5V 2C5");

PaymentDetails paymentDetails = new PaymentDetails()
  .type(PaymentDetails.TypeEnum.PAYBRIGHT);

BillingAddress billingAddress = new BillingAddress()
  .country("CA")
  .stateOrProvince("ON")
  .city("Toronto")
  .houseNumberOrName("240")
  .street("Richmond St W")
  .postalCode("M5V 2C5");

PaymentRequest paymentRequest = new PaymentRequest()
  .amount(amount)
  .telephoneNumber("+16478491378")
  .shopperEmail("s.hopper@adyen.com")
  .dateOfBirth(OffsetDateTime.parse("1970-07-10"))
  .reference("YOUR_ORDER_REFERENCE")
  .lineItems(Arrays.asList(lineItem1, lineItem2, lineItem3))
  .shopperName(name)
  .merchantAccount("ADYEN_MERCHANT_ACCOUNT")
  .deliveryAddress(deliveryAddress)
  .countryCode("CA")
  .paymentMethod(new CheckoutPaymentMethod(paymentDetails))
  .shopperLocale("en_CA")
  .billingAddress(billingAddress)
  .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..");

// Send the request
PaymentsApi service = new PaymentsApi(client);
PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID"));
```

#### PHP

```php
// Adyen PHP API Library v19.0.0
use Adyen\Client;
use Adyen\Environment;
use Adyen\Model\Checkout\Amount;
use Adyen\Model\Checkout\LineItem;
use Adyen\Model\Checkout\Name;
use Adyen\Model\Checkout\DeliveryAddress;
use Adyen\Model\Checkout\CheckoutPaymentMethod;
use Adyen\Model\Checkout\BillingAddress;
use Adyen\Model\Checkout\PaymentRequest;
use Adyen\Service\Checkout\PaymentsApi;

$client = new Client();
$client->setXApiKey("ADYEN_API_KEY");
// For the live environment, additionally include your liveEndpointUrlPrefix.
$client->setEnvironment(Environment::TEST);


// Create the request object(s)
$amount = new Amount();
$amount
  ->setCurrency("CAD")
  ->setValue(6000);

$lineItem1 = new LineItem();
$lineItem1
  ->setQuantity(1)
  ->setAmountExcludingTax(3310)
  ->setDescription("Shoes")
  ->setAmountIncludingTax(4000);

$lineItem2 = new LineItem();
$lineItem2
  ->setQuantity(2)
  ->setAmountExcludingTax(2480)
  ->setDescription("Socks")
  ->setAmountIncludingTax(3000);

$lineItem3 = new LineItem();
$lineItem3
  ->setQuantity(1)
  ->setAmountExcludingTax(-1000)
  ->setDescription("Discount")
  ->setAmountIncludingTax(-1000);

$name = new Name();
$name
  ->setFirstName("Simon")
  ->setLastName("Hopper");

$deliveryAddress = new DeliveryAddress();
$deliveryAddress
  ->setCountry("CA")
  ->setStateOrProvince("ON")
  ->setCity("Toronto")
  ->setHouseNumberOrName("240")
  ->setStreet("Richmond St W")
  ->setPostalCode("M5V 2C5");

$checkoutPaymentMethod = new CheckoutPaymentMethod();
$checkoutPaymentMethod
  ->setType("paybright");

$billingAddress = new BillingAddress();
$billingAddress
  ->setCountry("CA")
  ->setStateOrProvince("ON")
  ->setCity("Toronto")
  ->setHouseNumberOrName("240")
  ->setStreet("Richmond St W")
  ->setPostalCode("M5V 2C5");

$paymentRequest = new PaymentRequest();
$paymentRequest
  ->setAmount($amount)
  ->setTelephoneNumber("+16478491378")
  ->setShopperEmail("s.hopper@adyen.com")
  ->setDateOfBirth("1970-07-10")
  ->setReference("YOUR_ORDER_REFERENCE")
  ->setLineItems(array($lineItem1, $lineItem2, $lineItem3))
  ->setShopperName($name)
  ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT")
  ->setDeliveryAddress($deliveryAddress)
  ->setCountryCode("CA")
  ->setPaymentMethod($checkoutPaymentMethod)
  ->setShopperLocale("en_CA")
  ->setBillingAddress($billingAddress)
  ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..");

$requestOptions['idempotencyKey'] = 'UUID';

// Send the request
$service = new PaymentsApi($client);
$response = $service->payments($paymentRequest, $requestOptions);
```

#### C\#

```cs
// Adyen .net API Library v17.0.0
using Adyen;
using Environment = Adyen.Model.Environment;
using Adyen.Model;
using Adyen.Model.Checkout;
using Adyen.Service.Checkout;

// For the live environment, additionally include your liveEndpointUrlPrefix.
var config = new Config()
{
    XApiKey = "ADYEN_API_KEY",
    Environment = Environment.Test
};
var client = new Client(config);

// Create the request object(s)
Amount amount = new Amount
{
  Currency = "CAD",
  Value = 6000
};

LineItem lineItem1 = new LineItem
{
  Quantity = 1,
  AmountExcludingTax = 3310,
  Description = "Shoes",
  AmountIncludingTax = 4000
};

LineItem lineItem2 = new LineItem
{
  Quantity = 2,
  AmountExcludingTax = 2480,
  Description = "Socks",
  AmountIncludingTax = 3000
};

LineItem lineItem3 = new LineItem
{
  Quantity = 1,
  AmountExcludingTax = -1000,
  Description = "Discount",
  AmountIncludingTax = -1000
};

Name name = new Name
{
  FirstName = "Simon",
  LastName = "Hopper"
};

DeliveryAddress deliveryAddress = new DeliveryAddress
{
  Country = "CA",
  StateOrProvince = "ON",
  City = "Toronto",
  HouseNumberOrName = "240",
  Street = "Richmond St W",
  PostalCode = "M5V 2C5"
};

PaymentDetails paymentDetails = new PaymentDetails
{
  Type = PaymentDetails.TypeEnum.Paybright
};

BillingAddress billingAddress = new BillingAddress
{
  Country = "CA",
  StateOrProvince = "ON",
  City = "Toronto",
  HouseNumberOrName = "240",
  Street = "Richmond St W",
  PostalCode = "M5V 2C5"
};

PaymentRequest paymentRequest = new PaymentRequest
{
  Amount = amount,
  TelephoneNumber = "+16478491378",
  ShopperEmail = "s.hopper@adyen.com",
  DateOfBirth = DateTime.Parse("1970-07-10"),
  Reference = "YOUR_ORDER_REFERENCE",
  LineItems = new List<LineItem>{ lineItem1, lineItem2, lineItem3 },
  ShopperName = name,
  MerchantAccount = "ADYEN_MERCHANT_ACCOUNT",
  DeliveryAddress = deliveryAddress,
  CountryCode = "CA",
  PaymentMethod = new CheckoutPaymentMethod(paymentDetails),
  ShopperLocale = "en_CA",
  BillingAddress = billingAddress,
  ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy.."
};

// Send the request
var service = new PaymentsService(client);
var response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"});
```

#### NodeJS (JavaScript)

```js
// Adyen Node API Library v18.0.0
// Require the parts of the module you want to use
const { Client, CheckoutAPI } = require('@adyen/api-library');
// Initialize the client object
// For the live environment, additionally include your liveEndpointUrlPrefix.
const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

// Create the request object(s)
const paymentRequest = {
  merchantAccount: "ADYEN_MERCHANT_ACCOUNT",
  reference: "YOUR_ORDER_REFERENCE",
  paymentMethod: {
    type: "paybright"
  },
  amount: {
    value: 6000,
    currency: "CAD"
  },
  shopperLocale: "en_CA",
  countryCode: "CA",
  telephoneNumber: "+16478491378",
  shopperEmail: "s.hopper@adyen.com",
  dateOfBirth: new Date("1970-07-10"),
  shopperName: {
    firstName: "Simon",
    lastName: "Hopper"
  },
  billingAddress: {
    city: "Toronto",
    country: "CA",
    houseNumberOrName: "240",
    postalCode: "M5V 2C5",
    street: "Richmond St W",
    stateOrProvince: "ON"
  },
  deliveryAddress: {
    city: "Toronto",
    country: "CA",
    houseNumberOrName: "240",
    postalCode: "M5V 2C5",
    street: "Richmond St W",
    stateOrProvince: "ON"
  },
  lineItems: [ {
    description: "Shoes",
    quantity: "1",
    amountIncludingTax: "4000",
    amountExcludingTax: "3310",
    taxCategory: "Low"
  }, {
    description: "Socks",
    quantity: "2",
    amountIncludingTax: "3000",
    amountExcludingTax: "2480",
    taxCategory: "Low"
  }, {
    description: "Discount",
    amountExcludingTax: "-1000",
    amountIncludingTax: "-1000",
    quantity: "1",
    taxCategory: "Low"
  } ],
  returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.."
}

// Send the request
const checkoutAPI = new CheckoutAPI(client);
const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
```

#### Go

```go
// Adyen Go API Library v10.4.0
import (
  "context"
  "time"
  "github.com/adyen/adyen-go-api-library/v9/src/common"
  "github.com/adyen/adyen-go-api-library/v9/src/adyen"
  "github.com/adyen/adyen-go-api-library/v9/src/checkout"
)
// For the live environment, additionally include your liveEndpointUrlPrefix.
client := adyen.NewClient(&common.Config{
  ApiKey:      "ADYEN_API_KEY",
  Environment: common.TestEnv,
})

// Create the request object(s)
amount := checkout.Amount{
  Currency: "CAD",
  Value: 6000,
}

lineItem1 := checkout.LineItem{
  Quantity: common.PtrInt64(1),
  AmountExcludingTax: common.PtrInt64(3310),
  Description: common.PtrString("Shoes"),
  AmountIncludingTax: common.PtrInt64(4000),
}

lineItem2 := checkout.LineItem{
  Quantity: common.PtrInt64(2),
  AmountExcludingTax: common.PtrInt64(2480),
  Description: common.PtrString("Socks"),
  AmountIncludingTax: common.PtrInt64(3000),
}

lineItem3 := checkout.LineItem{
  Quantity: common.PtrInt64(1),
  AmountExcludingTax: common.PtrInt64(-1000),
  Description: common.PtrString("Discount"),
  AmountIncludingTax: common.PtrInt64(-1000),
}

name := checkout.Name{
  FirstName: "Simon",
  LastName: "Hopper",
}

deliveryAddress := checkout.DeliveryAddress{
  Country: "CA",
  StateOrProvince: common.PtrString("ON"),
  City: "Toronto",
  HouseNumberOrName: "240",
  Street: "Richmond St W",
  PostalCode: "M5V 2C5",
}

paymentDetails := checkout.PaymentDetails{
  Type: common.PtrString("paybright"),
}

billingAddress := checkout.BillingAddress{
  Country: "CA",
  StateOrProvince: common.PtrString("ON"),
  City: "Toronto",
  HouseNumberOrName: "240",
  Street: "Richmond St W",
  PostalCode: "M5V 2C5",
}

paymentRequest := checkout.PaymentRequest{
  Amount: amount,
  TelephoneNumber: common.PtrString("+16478491378"),
  ShopperEmail: common.PtrString("s.hopper@adyen.com"),
  DateOfBirth:  func() *time.Time { t, _ := time.Parse(time.RFC3339, "1970-07-10"); return &t }(),
  Reference: "YOUR_ORDER_REFERENCE",
  LineItems: []checkout.LineItem{
      lineItem1, lineItem2, lineItem3,
  },
  ShopperName: &name,
  MerchantAccount: "ADYEN_MERCHANT_ACCOUNT",
  DeliveryAddress: &deliveryAddress,
  CountryCode: common.PtrString("CA"),
  PaymentMethod: checkout.PaymentDetailsAsCheckoutPaymentMethod(&paymentDetails),
  ShopperLocale: common.PtrString("en_CA"),
  BillingAddress: &billingAddress,
  ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..",
}

// Send the request
service := client.Checkout()
req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest)
res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)
```

#### Python

```py
# Adyen Python API Library v12.5.1
import Adyen

adyen = Adyen.Adyen()
adyen.client.xapikey = "ADYEN_API_KEY"
# For the live environment, additionally include your liveEndpointUrlPrefix.
adyen.client.platform = "test" # The environment to use library in.

# Create the request object(s)
json_request = {
  "merchantAccount": "ADYEN_MERCHANT_ACCOUNT",
  "reference": "YOUR_ORDER_REFERENCE",
  "paymentMethod": {
    "type": "paybright"
  },
  "amount": {
    "value": 6000,
    "currency": "CAD"
  },
  "shopperLocale": "en_CA",
  "countryCode": "CA",
  "telephoneNumber": "+16478491378",
  "shopperEmail": "s.hopper@adyen.com",
  "dateOfBirth": "1970-07-10",
  "shopperName": {
    "firstName": "Simon",
    "lastName": "Hopper"
  },
  "billingAddress": {
    "city": "Toronto",
    "country": "CA",
    "houseNumberOrName": "240",
    "postalCode": "M5V 2C5",
    "street": "Richmond St W",
    "stateOrProvince": "ON"
  },
  "deliveryAddress": {
    "city": "Toronto",
    "country": "CA",
    "houseNumberOrName": "240",
    "postalCode": "M5V 2C5",
    "street": "Richmond St W",
    "stateOrProvince": "ON"
  },
  "lineItems": [ {
    "description": "Shoes",
    "quantity": "1",
    "amountIncludingTax": "4000",
    "amountExcludingTax": "3310",
    "taxCategory": "Low"
  }, {
    "description": "Socks",
    "quantity": "2",
    "amountIncludingTax": "3000",
    "amountExcludingTax": "2480",
    "taxCategory": "Low"
  }, {
    "description": "Discount",
    "amountExcludingTax": "-1000",
    "amountIncludingTax": "-1000",
    "quantity": "1",
    "taxCategory": "Low"
  } ],
  "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.."
}

# Send the request
result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID")
```

#### Ruby

```rb
# Adyen Ruby API Library v9.5.1
require "adyen-ruby-api-library"

adyen = Adyen::Client.new
adyen.api_key = 'ADYEN_API_KEY'
# For the live environment, additionally include your liveEndpointUrlPrefix.
adyen.env = :test # Set to "live" for live environment

# Create the request object(s)
request_body = {
  :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT',
  :reference => 'YOUR_ORDER_REFERENCE',
  :paymentMethod => {
    :type => 'paybright'
  },
  :amount => {
    :value => 6000,
    :currency => 'CAD'
  },
  :shopperLocale => 'en_CA',
  :countryCode => 'CA',
  :telephoneNumber => '+16478491378',
  :shopperEmail => 's.hopper@adyen.com',
  :dateOfBirth => '1970-07-10',
  :shopperName => {
    :firstName => 'Simon',
    :lastName => 'Hopper'
  },
  :billingAddress => {
    :city => 'Toronto',
    :country => 'CA',
    :houseNumberOrName => '240',
    :postalCode => 'M5V 2C5',
    :street => 'Richmond St W',
    :stateOrProvince => 'ON'
  },
  :deliveryAddress => {
    :city => 'Toronto',
    :country => 'CA',
    :houseNumberOrName => '240',
    :postalCode => 'M5V 2C5',
    :street => 'Richmond St W',
    :stateOrProvince => 'ON'
  },
  :lineItems => [ {
    :description => 'Shoes',
    :quantity => '1',
    :amountIncludingTax => '4000',
    :amountExcludingTax => '3310',
    :taxCategory => 'Low'
  }, {
    :description => 'Socks',
    :quantity => '2',
    :amountIncludingTax => '3000',
    :amountExcludingTax => '2480',
    :taxCategory => 'Low'
  }, {
    :description => 'Discount',
    :amountExcludingTax => '-1000',
    :amountIncludingTax => '-1000',
    :quantity => '1',
    :taxCategory => 'Low'
  } ],
  :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..'
}

# Send the request
result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' })
```

#### NodeJS (TypeScript)

```ts
// Adyen Node API Library v18.0.0
// Require the parts of the module you want to use
import { Client, CheckoutAPI, Types } from "@adyen/api-library";
// Initialize the client object
// For the live environment, additionally include your liveEndpointUrlPrefix.
const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

// Create the request object(s)
const amount: Types.checkout.Amount = {
  currency: "CAD",
  value: 6000
};

const lineItem1: Types.checkout.LineItem = {
  quantity: 1,
  amountExcludingTax: 3310,
  description: "Shoes",
  amountIncludingTax: 4000
};

const lineItem2: Types.checkout.LineItem = {
  quantity: 2,
  amountExcludingTax: 2480,
  description: "Socks",
  amountIncludingTax: 3000
};

const lineItem3: Types.checkout.LineItem = {
  quantity: 1,
  amountExcludingTax: -1000,
  description: "Discount",
  amountIncludingTax: -1000
};

const name: Types.checkout.Name = {
  firstName: "Simon",
  lastName: "Hopper"
};

const deliveryAddress: Types.checkout.DeliveryAddress = {
  country: "CA",
  stateOrProvince: "ON",
  city: "Toronto",
  houseNumberOrName: "240",
  street: "Richmond St W",
  postalCode: "M5V 2C5"
};

const paymentDetails: Types.checkout.PaymentDetails = {
  type: Types.checkout.PaymentDetails.TypeEnum.Paybright
};

const billingAddress: Types.checkout.BillingAddress = {
  country: "CA",
  stateOrProvince: "ON",
  city: "Toronto",
  houseNumberOrName: "240",
  street: "Richmond St W",
  postalCode: "M5V 2C5"
};

const paymentRequest: Types.checkout.PaymentRequest = {
  amount: amount,
  telephoneNumber: "+16478491378",
  shopperEmail: "s.hopper@adyen.com",
  dateOfBirth: new Date("1970-07-10"),
  reference: "YOUR_ORDER_REFERENCE",
  lineItems: [lineItem1, lineItem2, lineItem3],
  shopperName: name,
  merchantAccount: "ADYEN_MERCHANT_ACCOUNT",
  deliveryAddress: deliveryAddress,
  countryCode: "CA",
  paymentMethod: paymentDetails,
  shopperLocale: "en_CA",
  billingAddress: billingAddress,
  returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.."
};

// Send the request
const checkoutAPI = new CheckoutAPI(client);
const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
```

In the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response, check the `action` object for the information that you must use to redirect the shopper.

**/payments response**

```json
{
  "resultCode":"RedirectShopper",
  "action":{
    "paymentMethodType":"paybright",
    "method":"GET",
    "url":"https://checkoutshopper-test.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=...",
    "type":"redirect"
  }
}
```

## Handle the redirect

1. To complete the payment, redirect the shopper to the `action.url` returned in the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response, taking into account the following recommendations:

   * **When using the HTTP GET method:**\
     For security reasons, when showing the redirect in the app, we recommend that you use [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) for iOS or [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) for Android, instead of WebView objects. Also refer to the [security best practices](https://developer.android.com/topic/security/best-practices#webview) for WebView.

   * **Redirection for mobile integrations:**\
     For mobile integrations, we strongly recommended that you redirect the shopper to the default browser of their device. Redirecting to the default browser ensures the best compatibility, handling of multi-factor authentication, app-to-app redirection, and error handling.

2. After the shopper is redirected back to your website, check the payment result by making a POST [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) request, specifying:

   * `details`: object that contains the URL-decoded `redirectResult` returned when the shopper was redirected back to your site.

   **/payments/details request**

   ```bash
   curl https://checkout-test.adyen.com/v72/payments/details \
   -H 'x-api-key: ADYEN_API_KEY' \
   -H 'content-type: application/json' \
   -d '{
      "details": {
         "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
      }
   }'
   ```

3. In the response note the following:

   * `resultCode`: use this to present the result to your shopper.
   * `pspReference`: our unique identifier for the transaction.

   **/payments/details response**

   ```json
   {
      "resultCode": "Authorised",
      "pspReference": "V4HZ4RBFJGXXGN82"
   }
   ```

## Present the payment result

Use the `resultCode` that you received in the [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response to present the payment result to your shopper.

The `resultCode` values you can receive for PayBright are:

| resultCode     | Description                           | Action to take                                                                                                  |
| -------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| **Authorised** | The payment was successful.           | Inform the shopper that the payment was successful.                                                             |
| **Cancelled**  | The shopper cancelled the payment.    | Ask the shopper whether they want to continue with the order, or ask them to select a different payment method. |
| **Refused**    | The payment was refused by PayBright. | Ask the shopper to try the payment again using a different payment method.                                      |

[]()If the shopper failed to return to your website or app, wait for webhooks to know the outcome of the payment:

| eventCode         | success field | Description                                     | Action to take                                                                      |
| ----------------- | ------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------- |
| **AUTHORISATION** | **false**     | The transaction failed.                         | Cancel the order and inform the shopper that the payment failed.                    |
| **AUTHORISATION** | **true**      | The shopper successfully completed the payment. | Inform the shopper that the payment has been successful and proceed with the order. |

## Capture the payment

By default, all PayBright payments are [captured automatically](/online-payments/capture) after authorisation.

If you prefer to capture the payment after the goods have been sent, or when you want to partially capture payments, you need to set up a [capture delay](/online-payments/capture#delayed-automatic-capture) or use [manual capture](/online-payments/capture#manual-capture).

When you capture the payment, the shopper is charged for the first installment.

### Partial captures

Partial captures are not available if you enabled [automatic capture](/online-payments/capture) in your [Customer Area](https://ca-test.adyen.com/).

To [partially capture](/online-payments/capture) a PayBright payment, specify in your [/capture](https://docs.adyen.com/api-explorer/#/Payment/capture) request:

* `modificationAmount`: The amount that the shopper should pay. 
* `additionalData.openinvoicedata`:

  Optional

  Price and product information for the items that the shopper should pay for.

Although the field names are different, the information in `additionalData.openinvoicedata` is the same as what you provided in `lineItems` when making a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request:

| openinvoicedata | lineItems            | Description                                                                                       |
| --------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
| `itemAmount`    | `amountExcludingTax` | The price for one item, without the tax, in [minor units](/development-resources/currency-codes). |
| `itemVatAmount` | `taxAmount`          | The tax amount for one item, in minor units.                                                      |

The following example shows how to make a partial capture request if the shopper only kept one pair of socks from the two included in the original payment request.

**/capture request**

```json
{
   "originalReference":"COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "modificationAmount":{
      "currency":"CAD",
      "value":"4500"
   },
   "additionalData":{
      "openinvoicedata.numberOfLines":"2",
      "openinvoicedata.line1.currencyCode":"CAD",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"3310",
      "openinvoicedata.line1.itemVatAmount":"690",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line2.currencyCode":"CAD",
      "openinvoicedata.line2.description":"Socks",
      "openinvoicedata.line2.itemAmount":"1240",
      "openinvoicedata.line2.itemVatAmount":"260",
      "openinvoicedata.line2.numberOfItems":"1",
   },
   "reference":"YOUR_CAPTURE_REFERENCE"
}
```

Any unclaimed amount that is left over after partially capturing a payment is automatically cancelled. When your account is enabled for *multiple* partial captures, the unclaimed amount after an initial capture is not automatically cancelled.

To set up multiple partial captures, contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other). Multiple partial captures will create a new invoice for each capture. 

## Refunds and cancellations

If a payment has not yet been captured, you can [cancel](/online-payments/cancel) it. If the PayBright payment has already been captured and you want to return the funds to the shopper, you need to [refund](/online-payments/refund) it.

### Partial refunds

To [partially refund](/online-payments/refund) a payment, specify in your [/payments/{paymentPspReference}/refunds](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/\(paymentPspReference\)/refunds) request:

* `modificationAmount`: The amount to be refunded to the shopper.
* `additionalData.openinvoicedata`:

  Optional

  Price and product information about the returned items.

Providing `additionalData.openinvoicedata` is optional, and although the field names are different, the information is the same as what you provided in `lineItems` when making a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request:

| openinvoicedata | lineItems            | Description                                                                                       |
| --------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
| `itemAmount`    | `amountExcludingTax` | The price for one item, without the tax, in [minor units](/development-resources/currency-codes). |
| `itemVatAmount` | `taxAmount`          | The tax amount for one item, in minor units.                                                      |

The following example shows how to make a partial refund request if the shopper returned the shoes included in the original payment request.

**/refund request**

```json
{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "originalReference":"COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
   "modificationAmount":{
      "currency":"CAD",
      "value":"4000"
   },
   "additionalData":{
      "openinvoicedata.numberOfLines":"1",
      "openinvoicedata.line1.currencyCode":"CAD",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"3310",
      "openinvoicedata.line1.itemVatAmount":"690",
      "openinvoicedata.line1.numberOfItems":"1"
   },
   "reference":"YOUR_REFUND_REFERENCE"
}
```

## Test and go live

To test PayBright payments, use the test details provided in the [PayBright developer documentation](https://developer.paybright.com/docs/testing-resources-completed-pending-failed).

You can check the status of test payments in your [Customer Area](https://ca-test.adyen.com/) > **Transactions** > **Payments**.

Before you can accept live PayBright payments, you need to [submit a request for PayBright](/payment-methods/add-payment-methods) in your [live Customer Area](https://ca-live.adyen.com/).

## See also

* [API-only integration guide](/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=API%20only)
* [Webhooks](/development-resources/webhooks)
* [API Explorer](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/overview)
