Skip to main content

Accepting a Payment

In the simplest version, payment acceptance with PayU is based on sending a request to create a new order and redirecting the buyer to the PayU payment page. In this variant, we assume that you do not retrieve individual payment methods from the PayU backend during the purchase process, but only display one general payment option - PayU.

Order Authentication

Before creating a new payment request, you need to authenticate yourself within the scope of the selected point of sale. To do this, you will need to retrieve the client_id and client_secret from the point of sale where the funds will be deposited upon completion of the transaction.

Creating OAuth Token Request Example
curl -X POST https://secure.snd.payu.com/pl/standard/user/oauth/authorize \
-d 'grant_type=client_credentials' \
-d 'client_id=460718' \
-d 'client_secret=22f4175da9f0f72bcce976dd8bd7504f'

In the response, you will receive an OAuth token that you should use to authenticate the request.

Response to an OAuth Token Generation Request
{
"access_token": "3e5cac39-7e38-4139-8fd6-30adc06a61bd",
"token_type": "bearer",
"expires_in": 43199, //expiration time in seconds
"grant_type": "client_credentials"
}

To learn more about authentication, please refer to Authorizing Request or the Authorize section of the PayU API Reference.

Creating a Payment Request

Once you have obtained a valid OAuth token, you can proceed to create a new transaction with PayU. To do this, you will need to send a request containing the details of the transaction to the endpoint: https://secure.payu.com/api/v2_1/orders.

Using this API endpoint, you can pass the necessary transaction information to PayU, and the system will process the request to create a new transaction for you.

Please make sure to include all the required transaction details and authentication with the OAuth token in the request to ensure a successful creation of the transaction with PayU.

Creating a New Order Request Example
curl -X POST https://secure.payu.com/api/v2_1/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 3e5cac39-7e38-4139-8fd6-30adc06a61bd" \
-d '{
"customerIp": "127.0.0.1",
"merchantPosId": "145227",
"description": "RTV market",
"currencyCode": "PLN",
"totalAmount": "21000",
"products": [
{
"name": "Wireless Mouse for Laptop",
"unitPrice": "21000",
"quantity": "1"
}
]
}'

In the response to the order, you will receive detailed information about the transaction, including the redirectURI parameter. The redirectUri parameter contains the URL of the PayU payment page to which you should redirect the payer to complete the payment.

Response to the Request to Create a New Order
{
"status": {
"statusCode": "SUCCESS"
},
"redirectUri": "{payment_summary_redirection_url}",
"orderId": "WZHF5FFDRJ140731GUEST000P01",
"extOrderId": "{YOUR_EXT_ORDER_ID}"
}

If you want to learn more about creating a new order, see Creating a New Order section and the Create an Order section in the PayU API Reference.

Once redirected to the PayU payment page, the buyer will be able to choose the payment method that suits them. Once the payment is made, the funds will be added to the balance of the shop containing the point of sale which credentials you used to authenticate the request.

Payment Page Example

By cicking the button below you will be redirected to the PayU hosted payment page for sandbox environment.

That's it! If you want to make the checkout process easier and faster for your customers Create Your Own Payment Page.