# Create a Hosted payment page

To authorize a payment, make a call to the Hosted payment page endpoint. It will handle the authorization process by verifying payment details, checking funds, and meeting security requirements. Upon successful authorization, customer will redirect back to the merchant's website.

# 1. Create a HPP session

    Request Example
    • Shell
    • JavaScript
    curl -X POST \
      http://api.ompay.com/v1/merchants/w3z8dfhkzvfq0j9n/hosted-payment \
      -H 'authorization: Basic ODZidWQ0Y2JremlxOXZmYzoweHI1ZDkwOHo2bmo4a2h6' \
      -H 'content-type: application/json' \
      -d '
        {
            "intent": "sale",
            "payer": {
                "payment_type": "CC",
                "payer_info": {
                    "email": "TomHanks@gmail.com",
                    "billing_address": {
                        "line1": "18 Avenue",
                        "line2": "cassidy",
                        "city": "Rose-Hill",
                        "country_code": "mu",
                        "postal_code": "72101",
                        "state": "",
                        "phone": {
                            "country_code": "230",
                            "number": "57976041"
                        }
                    }
                }
            },
            "transaction": {
                "amount": {
                    "currency": "USD",
                    "total": "300"
                },
                "description": "purchase",
                "items": [
                    {
                        "sku": "100299S",
                        "name": "Ultrawatch",
                        "description": "Smart watch",
                        "quantity": "a0",
                        "price": "500",
                        "shipping": "20",
                        "currency": "USD",
                        "url": "",
                        "image": "",
                        "tangible": "true"
                    },
                    {
                        "sku": "100269S",
                        "name": "Drone",
                        "description": "drone x",
                        "quantity": "1",
                        "price": "500",
                        "shipping": "20",
                        "currency": "USD",
                        "url": "",
                        "image": "",
                        "tangible": "true"
                    }
                ],
                "invoice_number": "123455",
                "return_url": "https://ompay.om/returnUrl"
            },
            "metadata": {
                "customerip": "145.239.223.178"
            }
        }'
    
    Response example
    {
        "invoice_number": "123455",
        "session_id": "2440c62dce1f4e818fb3d44d5eaa4aa7",
        "hosted_page_link": "https://api.ompay.com/v1/merchants/ncr62b8u03hfj490/hosted-payment/page/2440c62dce1f4e818fb3d44d5eaa4aa7"
    }
    

    After successfully creating the Hosted Payment Page session, the payer is redirected to the hosted_page_link received in the above response, using either a server-side or client-side call.

    # 3. Payment completed

    After successfully completing the payment, the payer will be redirected to the return_url provided in the request. The hosted payment session Id is provided in hosted-payment-session-id query parameter included in the redirect URL.

    # Request

    # Header parameters

    The request require a Basic authentication in the header. For more information about HTTP request headers, see HTTP request headers.