Ik wil als betaalsysteem targetpay gaan gebruiken.
Ik heb de docu's gelezen en een class gemaakt.
Als ik de testmode op 1 zit.
Dus:
Dan geeft hij 000 OK weer.
Dan werkt het script lijkt mij?
Maar hoe kan ik nou checken of het script 100% werkt zonder die testmode op 1.
Dan zou ik dus de prijs zo laag modelijk moeten zetten en proberen met smsen of hij werkt?
Het script.
PHP
<?php
// Copyright: Youri van Mill
// Date: 2010
$settings['targetpay']['id'] = xxxxx;
$settings['targetpay']['country'] = 31;
$settings['targetpay']['shortcode'] = 3010;
$settings['targetpay']['keyword'] = 'BETAAL+AI';
$settings['targetpay']['testmode'] = 1;
class Sms_Targetpay
{
public $id;
public $country;
public $result;
public $testmode;
public function __construct($id, $country, $testmode)
{
$this->id = $id;
$this->country = $country;
$this->testmode = $testmode;
}
public function startPay($code, $shortcode, $keyword)
{
$this->result = file_get_contents('https://www.targetpay.com/api/sms-pincode' .
'?rtlo=' . $this->id . '&code=' . $code . '&shortcode=' . $shortcode .
'&keyword=' . $keyword . '&country=' . $this->country . '&test=' . $this->
testmode);
if ($this->result == '000 OK') {
return true;
} else {
return false;
}
}
}
$sms = new Sms_Targetpay($settings['targetpay']['id'], $settings['targetpay']['country'],
$settings['targetpay']['testmode']);
if (isset($_POST['submit'])) {
if (empty($_POST['code'])) {
echo 'Je hebt geen code ingevoert.';
} elseif (!ctype_digit($_POST['code'])) {
echo 'De code die je hebt ingevult is niet nummeriek.';
} else {
if (!$sms->startPay($_POST['code'], $settings['targetpay']['shortcode'], $settings['targetpay']['keyword'])) {
echo 'Er is iets fout gegaan tijdens het betalen.' . PHP_EOL;
echo '<!--' . $sms->result . '-->';
} else {
echo 'Betaling gelukt.';
echo '<!--' . $sms->result . '-->';
}
}
} else {
?>
<table>
<form action="/test.php" method="post">
<tr>
<td>Code</td>
<td><input type="text" name="code"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit"></td>
<td> </td>
</tr>
</form>
</table>
<?php
}
?>
Toon Meer
Online voorbeeld.
http://messinagame.nl/test.php
Kan iemand me helpen?