Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

Adyen Verify Payment Result

See more Adyen Examples

Once a payment has completed, this verifies the result from your server with a /payments/result request.

Chilkat React Native Downloads

React Native
import { Http, HttpResponse, JsonObject, StringBuilder } from '@chilkat/react-native'

async function chilkatExample() {
  const http = new Http();

  // Use this online tool to generate the code from sample JSON:
  // Generate Code to Create JSON

  // The following JSON is sent in the request body.

  // {
  //   "payload": "2he28Ddhwj242he28Ddhwj..."
  // }
  const json = new JsonObject();
  json.updateString('payload', '2he28Ddhwj242he28Ddhwj...');

  http.setRequestHeader('X-API-Key', 'Your_API_key');

  const resp = new HttpResponse();
  try {
    await http.httpJsonAsync('POST', 'https://checkout-test.adyen.com/v41/payments/result', json, 'application/json', resp);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  const sbResponseBody = new StringBuilder();
  resp.getBodySb(sbResponseBody);

  const jResp = new JsonObject();
  jResp.loadSb(sbResponseBody);
  jResp.emitCompact = false;

  const respStatusCode = resp.statusCode;
  console.log(`Status Code = ${respStatusCode}`);
  console.log('Response Body:');
  console.log(jResp.emit());

  if (respStatusCode >= 400) {
    console.log('Response Header:');
    console.log(resp.header);
    console.log('Failed.');
    return;
  }

  // Sample JSON response:

  // {
  //   "pspReference": "851559480052382F",
  //   "resultCode": "Authorised",
  //   "merchantReference": "123",
  //   "paymentMethod": "ideal",
  //   "shopperLocale": "nl_NL"
  // }

  // Sample code for parsing the JSON response...
  // Use the following online tool to generate parsing code from sample JSON:
  // Generate Parsing Code from JSON

  const pspReference = jResp.stringOf('pspReference');
  const resultCode = jResp.stringOf('resultCode');
  const merchantReference = jResp.stringOf('merchantReference');
  const paymentMethod = jResp.stringOf('paymentMethod');
  const shopperLocale = jResp.stringOf('shopperLocale');
}