Skip to main content

Create Payment

The Create Payment API allows merchants to initiate a payment request. This process involves generating a payment ID that can be used to query the payment.

Endpoint

Request URL: https://apihit.net/api/payment/create

Request Headers

Header NameValue
Content-Type"application/json"
Accept"application/json"
X-SignatureThe HMAC signature used for verification.

Request Parameters

PropertyPresenceTypeDescription
modeMandatoryString"URL_REDIRECT"
midMandatoryStringProvided by creedo during onboarding.
payment_methodMandatoryStringThis parameter indicates the method of payment. For NAGAD_P2P, the value of this parameter should be "NAGAD_P2P".
merchant_payment_idMandatoryStringUnique invoice number used on the merchant side for this specific payment. Max length is 25 characters. Special characters "<", ">" and "&" are not allowed.
payment_amountMandatoryIntegerAmount of the payment to be made.
payment_currencyMandatoryStringCurrency of the mentioned amount. For NAGAD_P2P, the value of this parameter should be "BDT".
ipn_urlMandatoryStringURL where creedo sends Instant Payment Notification. It must accept POST request from creedo.
success_urlMandatoryStringRedirects to this URL after the user submits payment information.
failed_urlMandatoryStringRedirects to this URL after the user cancel payment.
customer_idOptionalStringUnique user ID on the merchant's side.
customer_nameOptionalStringFull name of the user on the merchant's side.
customer_phone_numberOptionalStringRegistered phone number of the user on the merchant's side.
customer_emailOptionalStringRegistered email address of the user on the merchant's side.
customer_typeOptionalStringType of the user. Possible values: Trusted, FTD, MTD, YTD, Others.
customer_ipOptionalStringCurrent IP address of the user.
btagOptionalStringBtag identifier of the customer.
additional_info_1OptionalStringAdditional information.
additional_info_2OptionalStringAdditional information.

Success Response Parameters

PropertyTypeDescription
gateway_statusString"accepted"
payment_urlStringRedirect user to payment page
creedo_payment_idStringCreedo-generated payment ID for this payment creation request. This payment ID can be used later to track the payment and in other payment-related APIs.

- A payment ID will expire after 1 hour. If a merchant tries to reuse a payment ID after 1 hour, they will receive an error. Additionally, the merchant will receive an expired callback after 1 hour.
- A payment ID is valid for one execution only. After the customer enters the transaction ID, account number, and the merchant calls the execute API with that payment ID and receives a successful response, they cannot reuse the same payment ID for another execution.

Error Response Parameters

PropertyTypeDescription
gateway_statusString"rejected"
messageStringError message here.

Signature Generation

The signature (X-Signature) is generated using HMAC with SHA-256. It uses the secret_key and a secret_string as inputs. All inputs should be in string format:

secret_string = mid:mode:merchant_payment_id:payment_method:payment_currency:payment_amount

Request Body

POST /api/payment/create HTTP/1.1
Host: https://apihit.net
Content-Type: application/json
Accept: application/json
X-Signature: <hash_str>

{
"mode": "URL_REDIRECT",
"mid": "Your Merchant Public Key Here",
"payment_method": "NAGAD_P2P",
"merchant_payment_id": "hap54hzxq0u",
"payment_amount": 400,
"payment_currency": "BDT",
"ipn_url": "https://example.com/ipn-handler",
"success_url": "http://example.com/payment-status/successful",
"failed_url": "http://example.com/payment-status/failed",
"customer_id": "USER12345", // Optional
"customer_name": "John Doe", // Optional
"customer_phone_number": "+88017XXXXXXXX", // Optional
"customer_email": "johndoe@example.com", // Optional
"customer_type": "Trusted", // Optional
"customer_ip": "192.168.1.1", // Optional
"btag": "BTAG001", // Optional
"additional_info_1": "Loyal customer", // Optional
"additional_info_2": "" // Optional
}

Success Response

A successful response will return a JSON object containing:

{
"gateway_status": "accepted",
"creedo_payment_id": "3C8HL0MHX9",
"payment_url": "https://api.creedo.capital/pay/OTk5NTI5NzI1NTEz/"
}

Error Response

In case of an error, the API will return a JSON object with error details:

{
"gateway_status": "rejected",
"message": "Unknown error occurred."
}

Notes

  • The merchant_payment_id must be unique for each transaction to prevent duplication.