/** * This function submits a transaction request to the server. * * @param string $issuerId The issuer Id to send the request to * @param string $purchaseId The purchase Id that the merchant generates * @param integer $amount The amount in cents for the purchase * @param string $description The description of the transaction * @param string $entranceCode The entrance code for the visitor of the merchant site. Determined by merchant * @param string $optExpirationPeriod Expiration period in specific format. See reference guide. Can be configured in config. * @param string $optMerchantReturnURL The return URL (optional) for the visitor. Optional. Can be configured in config. * @return An instance of AcquirerTransactionResponse or "false" on failure. */ function RequestTransaction( $issuerId, $purchaseId, $amount, $description, $entranceCode, $optExpirationPeriod="", // Optional $optMerchantReturnURL="" ) // Optional { $this->clearError(); $configCheck = $this->CheckConfig($this->config); if ($configCheck != "OK") { $this->setError( ING_ERROR_MISSING_CONFIG, "Config error: ".$configCheck, IDEAL_PRV_GENERIEKE_FOUTMELDING ); return $this->getError(); } if ( ! $this->verifyNotNull( $issuerId, "issuerId" ) || ! $this->verifyNotNull( $purchaseId, "purchaseId" ) || ! $this->verifyNotNull( $amount, "amount" ) || ! $this->verifyNotNull( $description, "description" ) || ! $this->verifyNotNull( $entranceCode, "entranceCode" ) ) { $errorResponse = $this->getError(); return $errorResponse; } //check amount length $amountOK = $this->LengthCheck("Amount", $amount, "12"); if ($amountOK != "ok") { return $this->getError(); } //check for diacritical characters $amountOK = $this->CheckDiacritical("Amount", $amount); if ($amountOK != "ok") { return $this->getError(); } //check description length $descriptionOK = $this->LengthCheck("Description", $description, "32"); if ($descriptionOK != "ok") { return $this->getError(); } //check for diacritical characters $descriptionOK = $this->CheckDiacritical("Description", $description); if ($descriptionOK != "ok") { return $this->getError(); } //check entrancecode length $entranceCodeOK = $this->LengthCheck("Entrancecode", $entranceCode, "40"); if ($entranceCodeOK != "ok") { return $this->getError(); } //check for diacritical characters $entranceCodeOK = $this->CheckDiacritical("Entrancecode", $entranceCode); if ($entranceCodeOK != "ok") { return $this->getError(); } //check purchaseid length $purchaseIDOK = $this->LengthCheck("PurchaseID", $purchaseId, "16"); if ($purchaseIDOK != "ok") { return $this->getError(); } //check for diacritical characters $purchaseIDOK = $this->CheckDiacritical("PurchaseID", $purchaseId); if ($purchaseIDOK != "ok") { return $this->getError(); } // According to the specification, these values should be hardcoded. $currency = "EUR"; $language = "nl"; $result = true; // Retrieve these values from the configuration file. $cfgExpirationPeriod = $this->getConfiguration( "EXPIRATIONPERIOD", true, $result ); $cfgMerchantReturnURL = $this->getConfiguration( "MERCHANTRETURNURL", true, $result ); if ( isset( $optExpirationPeriod ) && ( $optExpirationPeriod != "" ) ) { // If a (valid?) optional setting was specified for the expiration period, use it. $expirationPeriod = $optExpirationPeriod; } else { $expirationPeriod = $cfgExpirationPeriod; } if ( isset( $optMerchantReturnURL ) && ( $optMerchantReturnURL != "" ) ) { // If a (valid?) optional setting was specified for the merchantReturnURL, use it. $merchantReturnURL = $optMerchantReturnURL; } else { $merchantReturnURL = $cfgMerchantReturnURL; } if ( ! $this->verifyNotNull( $expirationPeriod, "expirationPeriod" ) || ! $this->verifyNotNull( $merchantReturnURL,"merchantReturnURL" ) ) { return false; } // Build the XML header for the transaction request $xmlMsg = $this->getXMLHeader( "AcquirerTrxReq", $issuerId, "<Issuer>\n<issuerID>" . $issuerId . "</issuerID>\n</Issuer>\n", $merchantReturnURL . $purchaseId . $amount . $currency . $language . $description . $entranceCode, "<merchantReturnURL>" . $merchantReturnURL . "</merchantReturnURL>\n" ); if ( ! $xmlMsg ) { return false; } // Add transaction information to the request. $xmlMsg .= "<Transaction>\n<purchaseID>" . $purchaseId . "</purchaseID>\n"; $xmlMsg .= "<amount>" . $amount . "</amount>\n"; $xmlMsg .= "<currency>" . $currency . "</currency>\n"; $xmlMsg .= "<expirationPeriod>" . $expirationPeriod . "</expirationPeriod>\n"; $xmlMsg .= "<language>" . $language . "</language>\n"; $xmlMsg .= "<description>" . $description . "</description>\n"; $xmlMsg .= "<entranceCode>" . $entranceCode . "</entranceCode>\n"; $xmlMsg .= "</Transaction>\n"; $xmlMsg .= "</AcquirerTrxReq>\n"; // Post the request to the server. $response = $this->PostXMLData( $xmlMsg ); if ($this->parseFromXml( "errorCode", $response ) != "") { $errorResponse = new ErrorResponse(); $errorResponse->setErrorCode($this->parseFromXml( "errorCode", $response )); $errorResponse->setErrorMessage($this->parseFromXml( "errorMessage", $response )); $errorResponse->setErrorDetail($this->parseFromXml( "errorDetail", $response )); $errorResponse->setConsumerMessage($this->parseFromXml( "consumerMessage", $response )); return $errorResponse; } if ($this->parseFromXml( "acquirerID", $response ) == "") { $errorResponse = new ErrorResponse(); $errorResponse->setErrorCode("ING1001"); $errorResponse->setErrorMessage("Transactie mislukt (aquirer side)"); $errorResponse->setConsumerMessage(""); return $errorResponse; } // Build the transaction response object and pass in the data. $res = new AcquirerTransactionResponse(); $res->setAcquirerID( $this->parseFromXml( "acquirerID", $response ) ); $res->setIssuerAuthenticationURL( html_entity_decode( $this->parseFromXml( "issuerAuthenticationURL", $response ) ) ); $res->setTransactionID( $this->parseFromXml( "transactionID", $response ) ); $res->setPurchaseID( $this->parseFromXml( "purchaseID", $response ) ); if (!$res) { return $response; } return $res; }