My application is used to buy journey tickets. The ticket price is different everytime. Can I use In-App Billing to make the user pay a custom price everytime? If so how? i.e. can I set the price which the user has to pay programmatically?
You cannot use Google Play In-App Billing to make the user pay a custom price.
Moreover you cannot use Google Play In-App Billing to sell physical goods and services like journey tickets:
You can use In-app Billing to sell only digital content. You cannot use In-app Billing to sell physical goods, personal services, or anything that requires physical delivery. Unlike with priced applications, once the user has purchased an in-app product there is no refund window.
http://developer.android.com/google/play/billing/billing_overview.html