Search

Are you looking for test card numbers?

Would you like to contact support?

Payment-method icon

PayBright for API only

Add PayBright to an existing API-only integration.

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. PayBright uses these for risk checks.
  2. Provide information about the purchased items by specifying lineItems in your payment request.
  3. Handle the redirect result after the shopper returns to your website.

Before you begin

These instructions explain how to add PayBright to your existing API-only integration. The API-only integration works the same way for all payment methods. If you haven't done this integration yet, refer to our API-only integration guide.

Before starting your integration:

  1. Make sure that you have set up your back end implementation.
  2. Add PayBright in your test Customer Area.

Build your payment form for PayBright

If you're using /paymentMethods to show which payment methods are available to the shopper,
specify the following combinations of countryCode and amount.currency in your request:

Country 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.

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 request from your server, specifying:

  • paymentMethod: paybright
  • shopperName: The shopper's full name.
  • dateOfBirth: The shopper's date of birth.
  • shopperEmail: The shopper's email address.
  • telephoneNumber: The shopper's phone number.
  • shopperLocaleOptional: A combination of language code and country code to define which language should be used in the PayBright checkout page.
  • countryCode: The shopper's country. For example, CA.
  • billingAddress: The postal address to be included on the invoice.
  • deliveryAddress: The postal address where the purchased items will be shipped.
  • lineItems: Price and product information about the purchased items.
  • returnUrl: The URL where the shopper is redirected back to after completing the payment.
curl https://checkout-test.adyen.com/v67/payments \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
    "merchantAccount": "YOUR_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.com/checkout?shopperOrder=12xy.."
}'
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.env = :test
adyen.api_key = "YOUR_X-API-KEY"

response = adyen.checkout.payments({
  :merchantAccount => "YOUR_MERCHANT_ACCOUNT",
  :countryCode => "CA",
  :shopperLocale => "en_US",
  :amount => {
    :currency => "CAD",
    :value => 6000
  },
  :shopperReference => "YOUR_UNIQUE_SHOPPER_ID",
  :reference => "YOUR_ORDER_NUMBER",
  :channel =>  "Web",
  :paymentMethod => {
    :type => "paybright"
  },
  :shopperName => {
       :firstName => "Simone",
       :lastName => "Hopper"
  },
  :telephoneNumber => "+16478491378",
  :shopperEmail => "s.hopper@adyen.com",
  :dateOfBirth => "1970-07-10",
  :billingAddress => {
     :street => "Richmond St W",
     :houseNumberOrName => "240",
     :city => "Toronto",
     :postalCode => "M5V 2C5",
     :country => "CA"
  },
  :deliveryAddress => {
     :street => "Richmond St W",
     :houseNumberOrName => "240",
     :city => "Toronto",
     :postalCode => "M5V 2C5",
     :country => "CA"
  },
  :lineItems => [
    {
      :quantity => "1",
      :amountExcludingTax => "3310",
      :description => "Shoes",
      :amountIncludingTax => "4000",
      :taxCategory => "Low"
    },
    {
      :quantity => "2",
      :amountExcludingTax => "2480",
      :description => "Socks",
      :amountIncludingTax => "3000",
      :taxCategory => "Low"
    },
    {
      :quantity => "1",
      :amountExcludingTax => "-1000",
      :description => "Discount",
      :amountIncludingTax => "-1000",
      :taxCategory => "Low"
    }
  ],
  :returnUrl => "https://your-company.com/checkout?shopperOrder=12xy.."
})
// Create a Client to establish a connection to our services with your API Key from the Customer Area.
Client client = new Client("YOUR_API_KEY", Environment.TEST);

Checkout checkout = new Checkout(client);

PaymentsRequest paymentsRequest = new PaymentsRequest();

paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setReference("YOUR_ORDER_REFERENCE");

PaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails();
paymentMethodDetails.setType("paybright");

paymentsRequest.setPaymentMethod(paymentMethodDetails);

Amount amount = new Amount();
amount.setCurrency("CAD");
amount.setValue(6000L);

paymentsRequest.setAmount(amount);
paymentsRequest.setShopperLocale("en_CA");
paymentsRequest.setCountryCode("CA");
paymentsRequest.setTelephoneNumber("+16478491378");
paymentsRequest.setShopperEmail("s.hopper@adyen.com");

Name shopperDetails = new Name();
shopperDetails.setFirstName("Simon");
shopperDetails.setGender(Name.GenderEnum.UNKNOWN);
shopperDetails.setLastName("Hopper");

paymentsRequest.setShopperName(shopperDetails);
paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID");

Address billingAddress = new Address();
billingAddress.setCity("Toronto");
billingAddress.setCountry("CA");
billingAddress.setHouseNumberOrName("240");
billingAddress.setPostalCode("M5V 2C5");
billingAddress.setStreet("Richmond St W");

paymentsRequest.setBillingAddress(billingAddress);

Address deliveryAddress = new Address();
deliveryAddress.setCity("Toronto");
deliveryAddress.setCountry("CA");
deliveryAddress.setHouseNumberOrName("240");
deliveryAddress.setPostalCode("M5V 2C5");
deliveryAddress.setStreet("Richmond St W");

paymentsRequest.setdeliveryAddress(deliveryAddress);
paymentsRequest.setReturnUrl("");

List<LineItem> lineItems = new ArrayList<>();
lineItems.add(
        new LineItem()
                .quantity(1L)
                .amountExcludingTax(3310L)
                .description("Shoes")
                .amountIncludingTax(4000L)
                .taxCategory("Low")
);
lineItems.add(
        new LineItem()
                .quantity(2L)
                .amountExcludingTax(2480L)
                .description("Socks")
                .amountIncludingTax(3000L)
                .taxCategory("Low")
);
lineItems.add(
        new LineItem()
                .quantity(1L)
                .amountExcludingTax(1000L)
                .description("Discount")
                .amountIncludingTax(1000L)
                .taxCategory("Low")
);

paymentsRequest.setLineItems(lineItems);

paymentsRequest.setAdditionalData(additionalData);

PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);

$params = [
  "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
  "countryCode" => "CA",
  "shopperLocale" => "en_CA",
  "amount" => [
     "currency" => "CAD",
     "value" => 6000
  ],
  "shopperReference" => "YOUR_UNIQUE_SHOPPER_ID",
  "reference" => "YOUR_ORDER_NUMBER",
  "channel" => "Web",
  "paymentMethod" => [
     "type" => "paybright"
  ],
   "shopperName" => [
       "firstName" => "Simone",
       "lastName" => "Hopper"
   ],
   "telephoneNumber" => "+16478491378",
   "shopperEmail" => "s.hopper@adyen.com",
   "dateOfBirth" => "1970-07-10",
   "billingAddress" => [
         "street" => "Richmond St W",
         "houseNumberOrName" => "240",
         "city" => "Toronto",
         "postalCode" => "M5V 2C5",
         "country" => "CA"
      ],
    "deliveryAddress" => [
            "street" => "Richmond St W",
            "houseNumberOrName" => "240",
            "city" => "Toronto",
            "postalCode" => "M5V 2C5",
            "country" => "CA"
         ],
  "lineItems" => [
     [
        "quantity" => "1",
        "amountExcludingTax" => "3310",
        "description" => "Shoes",
        "amountIncludingTax" => "4000",
        "taxCategory" => "Low"
     ],
     [
        "quantity" => "2",
        "amountExcludingTax" => "2480",
        "description" => "Socks",
        "amountIncludingTax" => "3000",
        "taxCategory" => "Low"
     ],
     [
        "quantity" => "1",
        "amountExcludingTax" => "-1000",
        "description" => "Discount",
        "amountIncludingTax" => "-1000",
        "taxCategory" => "Low"
     ]
  ],
  "returnUrl" => "https://your-company.com/checkout?shopperOrder=12xy.."
];

$result = $service->payments($params);

// Check if further action is needed
if (array_key_exists("action", $result)){
   // Pass the action object to your frontend.
   // $result["action"]
}
else {
   // No further action needed, pass the resultCode to your front end
   // $result['resultCode']
}
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.client.xapikey = 'YOUR_X-API-KEY'

result = adyen.checkout.payments({
  "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
  "countryCode": "CA",
  "shopperLocale":"en_CA",
  "amount": {
      "currency": "CAD",
      "value": 6000
   },
   "shopperReference": "YOUR_UNIQUE_SHOPPER_ID",
   "reference": "YOUR_ORDER_NUMBER",
   "channel": "Web",
   "paymentMethod": {
      "type":"paybright"
   },
   "shopperName": {
     "firstName": "Simone",
     "lastName": "Hopper"
     },
   "telephoneNumber": "+16478491378",
   "shopperEmail":"s.hopper@adyen.com",
   "dateOfBirth":"1970-07-10",
   "billingAddress": {
         "street":"Richmond St W",
         "houseNumberOrName":"240",
         "city":"Toronto",
         "postalCode":"M5V 2C5",
         "country":"CA"
    },
    "deliveryAddress": {
      "street":"Richmond St W",
      "houseNumberOrName":"240",
      "city":"Toronto",
      "postalCode":"M5V 2C5",
      "country":"CA"
   },
   "lineItems":[
      {
        "description": "Shoes",
        "quantity": "1",
        "amountIncludingTax": "4000",
        "amountExcludingTax": "3310",
        "taxCategory": "Low"
      },
      {
        "description": "Socks",
        "quantity": "2",
        "amountIncludingTax": "3000",
        "amountExcludingTax": "2480",
        "taxCategory": "Low"
      },
      {
        "description": "Discount",
        "quantity": "1",
        "amountIncludingTax": "-1000",
        "amountExcludingTax": "-1000",
        "taxCategory": "Low"
      }
   ],
   "returnUrl":"https://your-company.com/checkout?shopperOrder=12xy.."
})
var paymentRequest = new Adyen.Model.Checkout.PaymentRequest
{
    MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
    Amount = new Adyen.Model.Checkout.Amount("CAD", 6000),
    ShopperReference = "YOUR_UNIQUE_SHOPPER_ID",
    Reference = "YOUR_ORDER_NUMBER",
    Channel = Adyen.Model.Checkout.PaymentRequest.ChannelEnum.Web,
    TelephoneNumber = "+16478491378",
    ShopperEmail = "s.hopper@adyen.com",
    ShopperLocale = "en_CA",
    CountryCode = "CA",
    DateOfBirth = new DateTime(1970,07,10),

    LineItems = new List<LineItem>
    {
        new LineItem(AmountIncludingTax: 4000, AmountExcludingTax: 3310, Quantity: 1, Description: "Shoes", TaxCategory: LineItem.TaxCategoryEnum.Low),
        new LineItem(AmountIncludingTax: 3000, AmountExcludingTax: 2480, Quantity: 2, Description: "Socks", TaxCategory: LineItem.TaxCategoryEnum.Low),
        new LineItem(AmountIncludingTax: -1000, AmountExcludingTax: -1000, Quantity: 1, Description: "Discount", TaxCategory: LineItem.TaxCategoryEnum.Low)
    },
    PaymentMethod = new DefaultPaymentMethodDetails
    {
        Type = "paybright",

        BillingAddress = new Address(Country: "CA")
        {
            Street = "Richmond St W",
            HouseNumberOrName = "240",
            City = "Toronto",
            PostalCode = "M5V 2C5"
        },
        DeliveryAddress = new Address
        {
            Street = "Richmond St W",
            HouseNumberOrName = "240",
            City = "Toronto",
            PostalCode = "M5V 2C5"
        },
    },
    ShopperName = new Name
    {
        FirstName = "Simon",
        LastName = "Hopper"
    },
    ReturnUrl = "https://your-company.com/checkout?shopperOrder=12xy.."
};
// Set your X-API-KEY with the API key from the Customer Area.
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
// Set your X-API-KEY with the API key from the Customer Area.
config.apiKey = '[API_KEY]';
config.merchantAccount = '[MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
  merchantAccount: "YOUR_MERCHANT_ACCOUNT",
  countryCode:"CA",
  shopperLocale: "en_CA",
  amount: {
     currency: "CAD",
     value: "6000"
  },
  shopperReference: "YOUR_UNIQUE_SHOPPER_ID",
  reference: "YOUR_ORDER_NUMBER",
  channel: "Web",
  paymentMethod: {
     type: "paybright"
   },
   shopperName: {
     firstName: "Simon",
     lastName: "Hopper"
   },
   telephoneNumber: "+16478491378",
   shopperEmail: "s.hopper@adyen.com",
   dateOfBirth: "1970-07-10",
   billingAddress: {
         street: "Richmond St W",
         houseNumberOrName: "240",
         city: "Toronto",
         postalCode: "M5V 2C5",
         country: "CA"
   },
   deliveryAddress: {
         street: "Richmond St W",
         houseNumberOrName: "240",
         city: "Toronto",
         postalCode: "M5V 2C5",
         country: "CA"
   },
  lineItems: [
     {
        quantity: "1",
        amountExcludingTax: "3310",
        description: "Shoes",
        amountIncludingTax: "4000",
        taxCategory: "Low"
     },
     {
        quantity: "2",
        amountExcludingTax: "2480",
        description: "Socks",
        amountIncludingTax: "3000",
        taxCategory: "Low"
     },
     {
        quantity: "1",
        amountExcludingTax: "-1000",
        description: "Discount",
        amountIncludingTax: "-1000",
        taxCategory: "Low"
     }
  ],
  returnUrl: "https://your-company.com/checkout?shopperOrder=12xy.."
}).then(res => res);

The /payments response contains an action object with the information needed to redirect the shopper.

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

Handle the redirect {handle-redirect}

  1. To complete the payment, redirect the shopper to the action.url returned in the /payments response.
    When using the HTTP GET method:
    For security reasons, when displaying the redirect in the app, we recommend that you use SFSafariViewController for iOS or Chrome Custom Tabs for Android, instead of WebView objects. Also refer to the security best practices for WebView.
  2. After the shopper is redirected back to your website, check the payment result by making a 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
    curl https://checkout-test.adyen.com/v67/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
       "details": {
         "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
     }
    }'

You receive a response containing:

  • resultCode: Use this to present the result to your shopper.
  • pspReference: Our unique identifier for the transaction.
    /payments/details response
    {
     "resultCode": "Authorised",
     "pspReference": "88154795347618C"
    }

Present the payment result

Use the resultCode that you received in the /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 notification 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 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 or use 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 in your Customer Area.

To partially capture a PayBright payment, specify in your /payments/{paymentPspReference}/captures 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 request:

openinvoicedata lineItems Description
itemAmount amountExcludingTax The price for one item, without the tax, in minor units.
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
{
   "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. 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 it. If the PayBright payment has already been captured and you want to return the funds to the shopper, you need to refund it.

Partial refunds

To partially refund a payment, specify in your /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 request:

openinvoicedata lineItems Description
itemAmount amountExcludingTax The price for one item, without the tax, in minor units.
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
{
   "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.
You can check the status of test payments in your Customer Area > Transactions > Payments.
Before you can accept live PayBright payments, you need to submit a request for PayBright in your live Customer Area.

See also