Sample code for 30+ languages & platforms
Dart 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 Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final http = CkHttp();

  // 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..."
  // }
  final json = CkJsonObject();
  json.updateString('payload', '2he28Ddhwj242he28Ddhwj...');

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

  final resp = CkHttpResponse();
  try {
    http.httpJson('POST', 'https://checkout-test.adyen.com/v41/payments/result', json, 'application/json', resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final sbResponseBody = CkStringBuilder();
  resp.getBodySb(sbResponseBody);

  final jResp = CkJsonObject();
  jResp.loadSb(sbResponseBody);
  jResp.emitCompact = false;

  final respStatusCode = resp.statusCode;
  print('Status Code = $respStatusCode');
  print('Response Body:');
  print(jResp.emit());

  if (respStatusCode >= 400) {
    print('Response Header:');
    print(resp.header);
    print('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

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