Exemplo n.º 1
0
Arquivo: PSPM.php Projeto: Jemt/JSShop
 private function apiCall($type, $transactionId, $amount = -1)
 {
     $transactionInfo = explode(";", $transactionId);
     $transactionId = $transactionInfo[0];
     $orderId = $transactionInfo[1];
     $cfg = PSP::GetConfig("DIBS");
     $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 .= "&transact=" . $transactionId;
         if ($type === "Capture") {
             $check .= "&amount=" . $amount;
         }
         $checksum = md5($cfg["Encryption Key 2"] . md5($cfg["Encryption Key 1"] . $check));
     }
     $data = array("merchant" => $cfg["Merchant ID"], "transact" => $transactionId, "orderid" => $orderId, "md5key" => $checksum);
     if ($type === "Capture") {
         $data["amount"] = (string) $amount;
     }
     $url = null;
     if ($type === "Capture") {
         $url = "https://payment.architrade.com/cgi-bin/capture.cgi";
     } else {
         if ($type === "Cancel") {
             $url = "https://" . $cfg["API User: Username"] . ":" . $cfg["API User: Password"] . "@payment.architrade.com/cgi-adm/cancel.cgi";
         }
     }
     $response = PSP::Post($url, $data);
     $result = strpos($response, "status=ACCEPTED") !== false;
     PSP::Log("DIBS - API call result: " . "\nType: " . $type . "\nSuccess: " . ($result === true ? "true" : "false") . "\nResponse: " . $response);
     return $result;
 }