Drupal commerce: how to force user to pay with specific payment method? I Have written a shipping method (name:X) and a payment method(name:Y) for drupal commerce. the problem is that I want to force user to pay with Y if he selects X and I want to disable other payment methods on this condition.

it can manually be done with rules! but I want to programmatically add this limit.
how can I do it? is there a hook or something else?
You've already realized that you need a rules condition, since the available payment methods are determined through rules.

The selected shipping method is stored on the order entity ($order->shipping_rates), so you can just check that.
You might need to write a custom Rules condition (which is just a PHP function declared by an implementation of hook_rules_condition_info()).