Gerrit1958
Gebruiker
- Lid geworden
- 13 feb 2010
- Berichten
- 27
Hallo ik heb de volgende vraag. Ik heb een rit prijs module ik plak hem hier onder even bij
Wat ik nu wil is de uitkomst het bedrag dus by ideal $amount in laten vullen ik kom er niet uit hoe ik dat doe of moet ik
dan heb ik hier de ideal script heb mijn gegeven even verijwderd
Wat ik nu wil is de uitkomst het bedrag dus by ideal $amount in laten vullen ik kom er niet uit hoe ik dat doe of moet ik
HTML:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>ADL Taxi ritprijs bereken module</title>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Bereken uw ritprijs vanuit onze website">
<meta name="keywords" content="afstand, berekening, kosten, twee, plaatsen, postcode, tabel, distance, calculation">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://maps.google.nl/maps?file=api&v=2&key=ABQIAAAA5Q874pfLQnJG5Ykmh4ApzBRybvMzcJj-UG0qwB6UJI1T93XHuxSv0tgrGOMAdvxJIVXmNCZwTFPaLw
" type="text/javascript"></script>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
// nieuw object ZONDER parameters, want we willen nl. geen geschreven route EN geen map tonen....
// [url]http://code.google.com/apis/maps/documentation/reference.html#GDirections[/url]
gdir = new GDirections();
GEvent.addListener(gdir,"load", set_distance);
}
}
function setDirections(fromAddress, toAddress, locale)
{
// [url]http://code.google.com/apis/maps/documentation/reference.html#GDirectionsOptions[/url]
gdir.load("from: " + fromAddress + " to: " + toAddress, {locale: locale, travelMode:G_TRAVEL_MODE_DRIVING,avoidHighways: false} );
}
function set_distance()
{
// extra: foutafhandeling, kan handig zijn!!!
handleErrors();
// document.getElementById("afstand").innerHTML = (gdir.getDistance().meters);
var adl_afstand = gdir.getDistance().meters
var prijsOnafgerond = (((adl_afstand/1000)-2)*2.2)+7.5
prijs = Math.round(prijsOnafgerond * 100) / 100
prijsEuro = 'Uw ritprijs op de taximeter bedraagt: € ' + prijs.toFixed(2)
document.getElementById("ritprijs").innerHTML = prijsEuro;
}
// aantal kilometers - 2 *2.2+7.5= prijs
function handleErrors()
{
// [url]http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode[/url]
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY || gdir.getStatus().code == G_GEO_MISSING_ADDRESS)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNAVAILABLE_ADDRESS)
alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS)
alert("The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_TOO_MANY_QUERIES)
alert("The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.\n Error code: " + gdir.getStatus().code);
}
</script>
<style type="text/css">
body {
background-color: #5f5f5f;
color: #fff;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
line-height: 18px;
}
#rittabel {
border: 1px dashed #fff;
}
#ritprijs {
font-weight: bold;
font-size: 14px;
color: #fff;
}
#euro {
text-align: right;
font-size: 13px;
}
#tableprijs {
padding-top: 15px;
}
#rights {
font-size: 9px;
color: #ccc;
}
h1 {
font-size: 16px;
font-weight: bold;
}
</style>
</head>
<body onload="initialize()" onunload="GUnload()">
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, 'nl'); return false">
<table id="rittabel" cellspacing="5" cellpadding="5">
<tr>
<td colspan="2">
<h1>Prijs overige bestemmingen berekenen</h1>
</td>
</tr>
<tr>
<td colspan="2">
Via het onderstaande formulier kunt u een berekening maken van de kosten voor het gebruik van onze diensten. Voer uw gegevens in en bereken uw ritprijs. De prijs is gebaseerd op een luxe voertuig met 4 zitplaaten. Indien u gebruik wilt maken van een minivan (tot 8 pers.), rekenen wij een toeslag van 15%.
</td>
</tr>
<tr>
<td colspan="2" style="height: 20px;">
</td>
</tr>
<tr>
<td>Voer uw postcode, adres of plaats van vertrek in: </td>
<td valign="top"><input type="text" size="30" id="fromAddress" name="from" value="bijv.: Europaweg, Haarlem" onblur="if(this.value=='') this.value='bijv.: Europaweg, Haarlem';" onFocus="if(this.value=='bijv.: Europaweg, Haarlem') this.value='';"/></td>
</tr>
<tr>
<td colspan="2" style="height: 20px;">
</td>
</tr>
<tr>
<td>Voer uw postcode, adres of plaats van aankomst in: </td>
<td valign="top"><input type="text" size="30" id="toAddress" name="to" value="bijv.: 2011 LM, 64" onblur="if(this.value=='') this.value='bijv.: Schiphol';" onFocus="if(this.value=='bijv.: 2011 LM, 64') this.value='';"/></td>
</tr>
<tr>
<td> </td>
<td><input tabindex="1" name="submit" type="submit" value="Bereken ritprijs!" /></td>
</tr>
<tr>
<td colspan="2" style="height: 20px;">
<table border="0" width="100%" id="tableprijs">
<tr>
<td><div id="ritprijs"></div></td>
</tr>
<tr>
<td id="rights">Aan deze prijsschatting kunnen geen rechten worden ontleend.</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
dan heb ik hier de ideal script heb mijn gegeven even verijwderd
PHP:
<?php
require_once('ideal.class.php');
$partner_id = '****'; // Uw mollie partner ID
//dus omdeze gaat het daar moet ik dus de uitkomst krijgen van de ritprijs berekening
$amount = 118; // Het af te rekenen bedrag in centen (!!!)
$description = 'Testbetaling'; // Beschrijving die consument op zijn/haar afschrift ziet.
$return_url = 'http://www.uwdoamin.nl.nl/return.php'; // URL waarnaar de consument teruggestuurd wordt na de betaling
$report_url = 'http://www.uwdomain.nl.nl/report.php'; // URL die Mollie aanvraagt (op de achtergrond) na de betaling om de status naar op te sturen
if (!in_array('ssl', stream_get_transports()))
{
echo "<h1>Foutmelding</h1>";
echo "<p>Uw PHP installatie heeft geen SSL ondersteuning. SSL is nodig voor de communicatie met de Mollie iDEAL API.</p>";
exit;
}
$iDEAL = new iDEAL_Payment ($partner_id);
//$iDEAL->setTestMode();
if (isset($_POST['bank_id']) and !empty($_POST['bank_id']))
{
if ($iDEAL->createPayment($_POST['bank_id'], $amount, $description, $return_url, $report_url))
{
/* Hier kunt u de aangemaakte betaling opslaan in uw database, bijv. met het unieke transactie_id
Het transactie_id kunt u aanvragen door $iDEAL->getTransactionId() te gebruiken. Hierna wordt
de consument automatisch doorgestuurd naar de gekozen bank. */
header("Location: " . $iDEAL->getBankURL());
exit;
}
else
{
/* Er is iets mis gegaan bij het aanmaken bij de betaling. U kunt meer informatie
vinden over waarom het mis is gegaan door $iDEAL->getErrorMessage() en/of
$iDEAL->getErrorCode() te gebruiken. */
echo '<p>De betaling kon niet aangemaakt worden.</p>';
echo '<p><strong>Foutmelding:</strong> ', $iDEAL->getErrorMessage(), '</p>';
exit;
}
}
/*
Hier worden de mogelijke banken opgehaald en getoont aan de consument.
*/
$bank_array = $iDEAL->getBanks();
if ($bank_array == false)
{
echo '<p>Er is een fout opgetreden bij het ophalen van de banklijst: ', $iDEAL->getErrorMessage(), '</p>';
exit;
}
?>
<form method="post">
<select name="bank_id">
<option value=''>Kies uw bank</option>
<?php foreach ($bank_array as $bank_id => $bank_name) { ?>
<option value="<?php echo $bank_id ?>"><?php echo $bank_name ?></option>
<?php } ?>
</select>
<input type="submit" name="submit" value="Betaal via iDEAL" />
</form>
Laatst bewerkt door een moderator: