Skip to main content

 

Affirm Merchant Help

Exchange Checkout Object

The checkout object is the data payload that gets POSTed to the Affirm API to initialize checkout. 

affirm.checkout({
  "merchant": {
    "user_confirmation_url": "https://merchantsite.com/confirm",
    "user_cancel_url": "https://merchantsite.com/cancel",
    "user_confirmation_url_action": "POST",
    "name": "Your Customer-Facing Merchant Name",
    "exchange_lease_enabled": true,
  },
  "shipping": {
    "name": {
      "first": "Joe",
      "last": "Doe"
    },
    "address": {
      "line1": "633 Folsom St",
      "line2": "Floor 7",
      "city": "San Francisco",
      "state": "CA",
      "zipcode": "94107",
      "country": "USA",
    },
    "phone_number": "4153334567",
    "email": "joedoe@123fakestreet.com"
  },
  "billing": {
    "name": {
      "first": "Joe",
      "last": "Doe"
    },
    "address": {
      "line1": "633 Folsom St",
      "line2": "Floor 7",
      "city": "San Francisco",
      "state": "CA",
      "zipcode": "94107",
      "country": "USA",
    },
    "phone_number": "4153334567",
    "email": "joedoe@123fakestreet.com"
  },
  "items": [
    {
      "display_name": "Affirm Pants",
      "sku": "ABC-123",
      "unit_price": 1999,
      "qty": 3,
      "item_image_url": "https://merchantsite.com/images/affirm-pants.jpg",
      "item_url": "https://merchantsite.com/products/affirm-pants.html",
      "categories": [
        ["Home","Bedroom"],
        ["Home","Furniture","Bed"]
      ],
      "leasable": true
    }
  ],
  "discounts": {
    "DISCOUNT5": {
      "discount_amount": 500,
      "discount_display_name": "$5 discount"
    }
  },
  "metadata": {
    "platform_type": "Your Platform Name",
    "shipping_type": "UPS Ground"
    //webhook_session_id: "ABC123"
  },
  "order_id": "JKLMO4321",
  "shipping_amount": 1000,
  "tax_amount": 500,
  "total": 5997
});
merchant

required object.

Define the URLs for the two results of a checkout attempt and an optional external name.

shipping

required object.

Customer contact information.

billing

optional object.

Customer contact information.

items

required list.

A list of item objects.

discounts

optional hash.

A hash of coupon codes to discount objects. If discounts are passed, they must have a name and positive integer dollar amount.

metadata

optional object.

A hash of keys to values for any metadata to be passed into checkout and stored. 'entity_name' is a protected key, and will show up in your settlement reporting.

order_id

optional string.

Your internal order id. This is stored for your own future reference.

shipping_amount

required integer.

The total shipping amount; Defaults to 0.

tax_amount

required integer.

The total tax amount computed after all discounts have been applied; Defaults to 0.

total

required integer.

The total amount of the checkout. This determines the total amount charged to the user.

Note: We only use this value for the loan total; we do not calculate the total from the checkout object line items.