Witam,
Do mojego sklepu wykonałem prosty skrypt integracji płatności.
Oto kod:
<?php
# Definicja modulów
$GATEWAYMODULE["allpayname"]="allpay";
$GATEWAYMODULE["allpayvisiblename"]="All Pay";
$GATEWAYMODULE["allpaytype"]="Invoices";
function allpay_activate() {
defineGatewayField("allpay","text","id","15630","id","10","Your Allpay ID");
}
function allpay_link($params) {
# Definicja zmiennej Numeru Klienta w ALLPAY
$id = $params['id'];
# Zmienne z faktury
$opis = $params["invoiceid"];
$kwota = $params['amount'];
$duedate = $params['duedate'];
$invoiceid = $params['invoiceid'];
# Dane klienta
$forename = $params['clientdetails']['firstname'];
$surname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$street = $params['clientdetails']['address1'];
$streen_nl = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phone'];
# Systemowy
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$waluta = $params['currency'];
# End of Variables
$code = '<form action="https://ssl.allpay.eu" method="post" >
<input name="id" type="hidden" value="'.$id.'"/>
<input name="opis" type="hidden" value="'.$opis.'"/>
<input name="forename" type="hidden" value="'.$forename.'"/>
<input name="surname" type="hidden" value="'.$surname.'"/>
<input name="kwota" type="hidden" value="'.$kwota.'"/>
<input name="email" type="hidden" value="'.$email.'"/>
<input name="street" type="hidden" value="'.$street.'"/>
<input name="city" type="hidden" value="'.$city.'"/>
<input name="postcode" type="hidden" value="'.$postcode.'"/>
<input name="phone" type="hidden" value="'.$phone.'"/>
<input name="waluta" type="hidden" value="'.$waluta.'"/>
<input name="control" type="hidden" value="'.$invoiceid.'"/>
<input name="URLC" type="hidden" value="URL=http://sklep.pl/modules/gateways/callback/allpay_back.php"/>
<input type="submit" value="Zaplac"/></form>';
return $code;
}
?>
allpay_back.php
<?php
$_POST['control'];
$_POST['t_id'];
$url = "http://www.sklep.pl/includes/api.php";
$username = "admin";
$password = "hasło admina";
$postfields["username"] = $username;
$postfields["password"] = md5($password); $postfields["action"] = "addinvoicepayment";
$postfields["invoiceid"] = $control;
$postfields["transid"] = $t_id;
$postfields["gateway"] = "AllPay";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);
foreach ($data AS $temp) {
$results[$temp[0]] = $temp[1];
}
if ($results["result"]=="success") {
} else {
# Jezeli blad
echo "The following error occured: ".$results["message"]; }
?>
Po wysłaniu informacji z allpeya z numerem faktury (np. 400) Mój skrypt krzyczy ze nie może znaleźć tej faktury. Może źle odbieram dane?
Numer faktury wysyłam z zmiennej "control", która wraca później z bramki i na tej podstawie zatwierdzam płatność
Ten post edytował zkrystian 27.04.2008, 10:56:50