<?php
include_once("../../includes/env.php");

// Fetching JSON
$req_url = 'https://v6.exchangerate-api.com/v6/' . $SDRTOUSDAPIKEY . '/latest/XDR';
$response_json = file_get_contents($req_url);

// Continuing if we got a result
if (false !== $response_json) {

	// Try/catch for json_decode operation
	try {

		// Decoding
		$response = json_decode($response_json);

		// Check for success
		if ('success' === $response->result) {

			// YOUR APPLICATION CODE HERE, e.g.
			$base_price = 12; // Your price in USD
			$SDRTOUSDRATE = round($response->conversion_rates->USD, 2);
		}
	} catch (Exception $e) {
		$SDRTOUSDRATE = 0;
	}
}
