API ReferenceIntegrationsKnowledge Base

Sample Code

Notes:

  • Amount must always be in currency subunits. We support payments in international currencies.
  • Time represented as Unix timestamp, which can be obtained using the Utils.ToUnixTimestamp method.

Initialization#

CopyRazorpayClient client = new RazorpayClient(key, secret);

Generate API Key#

  1. Log into your Dashboard with appropriate credentials.
  2. Select the mode (Test or Live) for which you want to generate the API key. Note:
    You have to generate separate API Keys for the test and live modes. No real money is used in test mode.
  3. Navigate to SettingsAPI KeysGenerate Key to generate key for the selected mode.

The Key Id and Key Secret appear in a pop-out window as shown below:

Note:
After generating the keys from the Dashboard, download and save them securely. If you do not remember your API Keys, you need to re-generate it from the Dashboard and replace it wherever required.

Enforce TLS#

Ensure that you enforce the appropriate TLS version in the app, as shown:

CopySystem.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Payments#

Note:
Refer to the API reference Guide for request parameters and an example request and response.

Capture a payment#

CopyDictionary<string, object> options = new Dictionary<string,object>(); options.Add("amount", amountToBeCaptured); options.Add ("currency", currency); Payment payment = payment.Capture(options);

Fetch Payments#

CopyDictionary<string, object> options = new Dictionary<string,object>(); options.Add("from", startTime); List<Payment> payments = client.Payment.All(options);

Fetch Payment by ID#

CopyPayment payment = client.Payment.Fetch(id);

Access Payment Attributes#

CopypaymentAmount = payment["amount"];
×