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

# Purchase a points product

> `Smile.pointsProducts.purchase(id, options?)`

This async method exchanges the currently logged-in customer's points for a specified reward.

## Parameters

<ParamField path="id" type="integer" required>
  The unique identifier of the points product to be purchased.
</ParamField>

<ParamField path="options" type="object">
  <Expandable title="properties">
    <ParamField path="pointsToSpend" type="integer">
      A positive integer representing the number of points that will be spent on behalf of the customer. Only applies when purchasing a points product whose `exchangeType` is variable, otherwise should be left blank.
    </ParamField>
  </Expandable>
</ParamField>

## Returns

This method returns a `Promise` that:

* On success, resolves with a [points purchase object](/js/resources/points-purchases/object).
* On failure, rejects with an [error object](/js/concepts/error-handling).

If the method is improperly invoked (e.g. missing required parameters) or no customer is currently logged in, the `Promise` will be rejected.

<Panel>
  ```javascript JavaScript lines theme={null}
  // Purchase a fixed points product
  Smile.pointsProducts.purchase(132456921).then(
    (pointsPurchase) => {
      // Handle the points purchase object
    }
  );

  // Purchase a variable points product
  Smile.pointsProducts.purchase(
    132456921,
    { pointsToSpend: 500 }
  ).then((pointsPurchase) => {
    // Handle the points purchase object
  });
  ```
</Panel>
