public function RedirectToPaymentForm($orderId, $amount, $currency, $continueUrl = null, $callbackUrl = null) { $cfg = PSP::GetConfig("DIBS"); // Currency - make sure numeric value is used to work around checksum bug if (is_numeric($currency) === false) { $currency = PSP::CurrencyCodeToNumericValue($currency); } // Create checksum (if keys are configured) $checksum = ""; if (isset($cfg["Encryption Key 1"]) && $cfg["Encryption Key 1"] !== "" && isset($cfg["Encryption Key 2"]) && $cfg["Encryption Key 2"] !== "") { $check = ""; $check .= "merchant=" . $cfg["Merchant ID"]; $check .= "&orderid=" . $orderId; $check .= "¤cy=" . $currency; $check .= "&amount=" . $amount; $checksum = md5($cfg["Encryption Key 2"] . md5($cfg["Encryption Key 1"] . $check)); } // Output echo ' <form id="DIBS" method="POST" action="https://payment.architrade.com/paymentweb/start.action"> <input type="hidden" name="merchant" value="' . $cfg["Merchant ID"] . '"> <input type="hidden" name="callbackurl" value="' . PSP::GetProviderUrl("DIBS") . "/Callback.php" . '"> <input type="hidden" name="accepturl" value="' . PSP::GetProviderUrl("DIBS") . "/Callback.php" . '"> <input type="hidden" name="orderid" value="' . $orderId . '"> <input type="hidden" name="amount" value="' . $amount . '"> <input type="hidden" name="currency" value="' . $currency . '"> <input type="hidden" name="md5key" value="' . $checksum . '"> ' . (PSP::GetTestMode() === true ? '<input type="hidden" name="test" value="true">' : '') . ' <input type="hidden" name="CUSTOM_Callback" value="' . ($callbackUrl !== null ? $callbackUrl : "") . '"> <input type="hidden" name="CUSTOM_ContinueUrl" value="' . ($continueUrl !== null ? $continueUrl : "") . '"> </form> <script type="text/javascript"> setTimeout(function() { document.getElementById("DIBS").submit(); }, 100); </script> '; exit; }
<?php // Example of how ANY application can communicate // with ANY Payment Service Provider (PSP) using the // standardized payment interface (PSPI). require_once dirname(__FILE__) . "/../../PSPInterface.php"; $orderId = "1041"; $amount = 10; $currency = "DKK"; // Notice: URL parameters are not allowed. // TransactionId, OrderId, Amount, and Currency is passed to CustomCallback.php via POST. $continueUrl = PSP::GetProviderUrl("DIBS") . "/Test/ThanksPage.php"; $callbackUrl = PSP::GetProviderUrl("DIBS") . "/Test/CustomCallback.php"; $p = PSP::GetPaymentProvider("DIBS"); $p->RedirectToPaymentForm($orderId, $amount, $currency, $continueUrl, $callbackUrl);