How to grant User Points equal to the price of a Commerce Product? I would like to grant User Point to product owner in amount of product price after a product is sold.

For this I defined a rule as below:


Events: Completing the checkout process
Actions: Loop (commerce-order:commerce-line-items)


And I defined a Rules Component as below:


Conditions: Entity has field (Entity: commerce-line-item, Field: commerce_product)
Actions: Grant points to a user: (User: commerce-line-item:commerce-product:creator, Points: commerce-line-item:commerce-product:commerce-price:amount)


But when I save component it generates this Error message:


  Data selector commerce-line-item:commerce-product:commerce-price:amount for parameter points is invalid.


How I can do that?
At first I tried to answer your question using rules and userpoints module, but I saw that while adding Grant points to a user as action there is no such data selector for selecting the user who has created the product. I found the data selector for selecting the user who is the owner of order, but that is not your requirement. (That is why I clarified this in comments).

I found a module solution to your question. The module uses hook_commerce_checkout_complete(). From the hook page:


  Allows modules to perform business logic when an order completes
  checkout.
  
  This hook coincides with the "Customer completes checkout" event. Only
  business logic should be performed when this is invoked, such as
  updating the order status, assigning the order to a user account, or
  sending notification e-mails. Interaction with the user should instead
  occur through checkout panes on the checkout completion page.


This is the coding of the module I designed:

YOURMODULE.info file:

name = YOURMODULE
description = Module description
dependencies[] = commerce
dependencies[] = commerce_cart
dependencies[] = commerce_checkout
dependencies[] = userpoints
core = 7.x


UPDATE
As suggested by Clive, I have changed the module file so that this custom module will also work with multilingual sites.

YOURMODULE.module file:

/**                                                                             
 * Implements hook_commerce_checkout_complete().                                
 */                                                                             
function YOURMODULE_commerce_checkout_complete($order) {
  // Iterate through every commerce line item added in product.
  foreach (field_get_items('commerce_order', $order, 'commerce_line_items') as $line_item_id) {

    // Load commerce line item by line item id.
    $line_item = commerce_line_item_load($line_item_id['line_item_id']);

    // We do not want to include shipping cost in userpoints.
    if ($line_item-&gt;type != 'shipping') {
      // Load commerce product by product id.
      $product = commerce_product_load(field_get_items('commerce_line_item', $line_item, 'commerce_product')[0]['product_id']);

      // Create parameters.
      $params = array(
        'uid' =&gt; $product-&gt;uid,
        'points' =&gt; commerce_currency_amount_to_decimal(field_get_items('commerce_line_item', $line_item, 'commerce_total')[0]['amount'], field_get_items('commerce_line_item', $line_item, 'commerce_total')[0]['currency_code']),
      );

      // Grant userpoints programmatically.
      userpoints_userpointsapi($params);
    }
  }
}


Reference links:

userpoints_userpointsapi($params)

commerce_checkout API

commerce_line_item_load($line_item_id)

commerce_product_load($product_id)

Userpoints: deduct points programmatically

commerce_currency_amount_to_decimal()