shop-old/libs/billpay/example/php5/capture.php
2026-04-20 01:03:43 +02:00

56 lines
2.2 KiB
PHP

<?php
session_start();
/**
* @author Jan Wehrs (jan.wehrs@billpay.de)
* @copyright Copyright 2010 Billpay GmbH
* @license commercial
*/
require_once '../../api/ipl_xml_api.php';
require_once '../../api/php5/ipl_capture_request.php';
// This is the transaction ID obtained from the preauthorization response
$tx_id = $_GET["tx_id"];
// The order ID must be unique -> generate a random number for this example
$orderReference = rand(1, 15000000000);
$req = new ipl_capture_request($_SESSION['api-url-base']);
$req->set_default_params($_SESSION['mid'], $_SESSION['pid'], $_SESSION['security-key']);
$req->set_capture_params($tx_id, 27455, "EUR", $orderReference, "12345612");
$req->set_payment_info_params(true, true);
try {
$req->send();
if (!$req->has_error()) {
echo "Account holder: " . $req->get_account_holder() . "<br />";
echo "Account number: " . $req->get_account_number() . "<br />";
echo "Bank code: " . $req->get_bank_code() . "<br />";
echo "Bank name: " . $req->get_bank_name() . "<br />";
echo "Invoice reference: " . $req->get_invoice_reference() . "<br />";
echo "<input type=\"button\" value=\"Update order\" onclick=\"window.location.href='updateorder.php?tx_id=$tx_id&ref=$orderReference'\" />";
echo "<input type=\"button\" value=\"Invoice\" onclick=\"window.location.href='invoicecreated.php?ref=$orderReference'\" />";
echo "<input type=\"button\" value=\"Edit cart content\" onclick=\"window.location.href='edit.php?ref=$orderReference'\" />";
echo "<input type=\"button\" value=\"Full cancel\" onclick=\"window.location.href='cancel.php?ref=$orderReference'\" />";
}
else {
echo "Error occured!<br />";
echo "Error code: " . $req->get_error_code() . "<br />";
echo "Merchant msg: " . utf8_decode($req->get_merchant_error_message()) . "<br />";
echo "Customer msg: " . utf8_decode($req->get_customer_error_message()) . "<br />";
}
echo "<br /><br />";
echo "<strong>Request XML:</strong> " . htmlentities($req->get_request_xml());
echo "<br /><br />";
echo "<strong>Response XML:</strong> " . htmlentities($req->get_response_xml());
}
catch(Exception $e) {
echo $e->getMessage();
}
?>