Preauthorize

Placing a Customer Order at BillPay

Create the ipl_preauthorize_request instance

require_once 'api/ipl_xml_api.php';
require_once 'api/php5/ipl_preauthorize_request.php';

$req = new ipl_preauthorize_request($apiUrl, IPL_CORE_PAYMENT_TYPE_INVOICE);

Set the merchant access credentials

$req->set_default_params(
    $merchantId,
    $portalId,
    $securityKey
);

Add the customer information

$req->set_customer_details(
    $id,
    $type,
    $salutation,
    $title,
    $firstName,
    $lastName,
    $addressStreet,
    $addressStreetNo,
    $addressAddition,
    $zip,
    $city,
    $country,
    $email,
    $phoneNo,
    $mobilePhoneNo,
    $dayOfBirth,
    $language,
    $ip,
    $customerGroup
);

Add additional parameters like the fraud detection session id

$req->set_shipping_details(true);
$req->set_fraud_detection(sha(session_id()));

Add the complete/main order details

$req->set_total(
    $rebate, 
    $rebateGross, 
    $shippingName, 
    $shippingPrice,
    $shippingPriceGross, 
    $cartTotalPrice, 
    $cartTotalPriceGross,
    $currency, 
    $reference, 
    $reference2
);

Add the shopping cart items

$req->add_article(
    $articleid, 
    $articlequantity, 
    $articlename, 
    $articledescription,
    $article_price, 
    $article_price_gross
);

Add the customer's order history

$req->add_order_history(
    $historyOrderId, 
    $historyOrderDate, 
    $historyOrderAmount, 
    $historyOrderCurrency, 
    $historyOrderPaymentType, 
    $historyOrderStatus
);

The customer has accepted the Ts&Cs

$req->set_terms_accepted($termsAccepted);

Send the request to BillPay

try {
    $req->send();
} catch (Exception $e) {
    echo $e->getMessage();
}