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

Rust

let http = chilkat::Http::new();

// 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..."
// }
let json = chilkat::JsonObject::new();
let _ = json.update_string("payload", "2he28Ddhwj242he28Ddhwj...");

http.set_request_header("X-API-Key", "Your_API_key");

let resp = chilkat::HttpResponse::new();
if http.http_json("POST", "https://checkout-test.adyen.com/v41/payments/result", &json, "application/json", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let sb_response_body = chilkat::StringBuilder::new();
let _ = resp.get_body_sb(&sb_response_body);

let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);

let resp_status_code = resp.status_code();
println!("Status Code = {}", resp_status_code);
println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());

if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", resp.header());
    println!("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

let psp_reference = j_resp.string_of("pspReference").unwrap_or_default();
let result_code = j_resp.string_of("resultCode").unwrap_or_default();
let merchant_reference = j_resp.string_of("merchantReference").unwrap_or_default();
let payment_method = j_resp.string_of("paymentMethod").unwrap_or_default();
let shopper_locale = j_resp.string_of("shopperLocale").unwrap_or_default();