Example #1
0
    'location' => "https://pal-test.adyen.com/pal/servlet/soap/Payment",
    'trace' => 1,
    'classmap' => $classmap));

#print("<pre>");
#print_r($soapClient->__getFunctions());
#print("</pre>");
#print("<hr />");
	
#print("<pre>");
#print_r($soapClient->__getTypes());
#print("</pre>");
#print("<hr />");

try {
	$result = $soapClient->capture(array('modificationRequest' => $rr, 'captureResponse' => $ro));
} catch (SoapFault $exception) {
	print("<pre>");
	print($exception);
	print("<pre>");
	print("<hr />");
    printHeaders($soapClient);
}

print("\nresult = " . $result->captureResult->response);
print("\npspreference = " . $result->captureResult->pspReference);
print("\n\n");

//====================== Debug Functions ======================
function printHeaders($client)
{
Example #2
0
 public function capture(Varien_Object $payment, $amount)
 {
     $session = Mage::getSingleton('adminhtml/session');
     //
     // Verify if remote interface is enabled
     //
     if (!$this->_canDoCapture($payment->getOrder())) {
         return $this;
     }
     if ((int) $this->getConfigData('remoteinterface', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null) != 1) {
         $this->addOrderComment($payment->getOrder(), Mage::helper('epay')->__('EPAY_LABEL_73'));
         return $this;
     }
     try {
         //
         // Read info directly from the database
         $read = Mage::getSingleton('core/resource')->getConnection('core_read');
         $row = $read->fetchRow("select * from epay_order_status where orderid = '" . $payment->getOrder()->getIncrementId() . "'");
         if ($row["status"] == '1') {
             $epayamount = (string) ($amount * 100);
             $tid = $row["tid"];
             $param = array('merchantnumber' => $this->getConfigData('merchantnumber', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null), 'transactionid' => $tid, 'amount' => $epayamount, 'group' => '', 'pbsResponse' => 0, 'epayresponse' => 0, 'pwd' => $this->getConfigData('remoteinterfacepassword', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null));
             $client = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL');
             $result = $client->capture($param);
             if ($result->captureResult == 1) {
                 //
                 // Success - transaction captured!
                 //
                 $this->addOrderComment($payment->getOrder(), "Transaction with id: " . $tid . " has been captured by amount: " . number_format($amount, 2, ",", "."));
                 if (!$payment->getParentTransactionId() || $tid != $payment->getParentTransactionId()) {
                     $payment->setTransactionId($tid);
                 }
                 $payment->setIsTransactionClosed(0);
             } else {
                 if ($result->epayresponse != -1) {
                     if ($result->epayresponse == -1002) {
                         $this->addOrderComment($payment->getOrder(), "Transaction could not be deleted by ePay: " . $result->epayresponse . ". Forretningsnummeret findes ikke.");
                         throw new Exception("Transaction could not be captured by ePay: " . $result->epayresponse . ". Forretningsnummeret findes ikke.");
                     } else {
                         if ($result->epayresponse == -1003 || $result->epayresponse == -1006) {
                             $this->addOrderComment($payment->getOrder(), "Transaction could not be captured by ePay: " . $result->epayresponse . ". Der er ikke adgang til denne funktion (API / Remote Interface).");
                             throw new Exception("Transaction could not be captured by ePay: " . $result->epayresponse . ". Der er ikke adgang til denne funktion (API / Remote Interface).");
                         } else {
                             $this->addOrderComment($payment->getOrder(), 'Transaction could not be captured by ePay: ' . $result->epayresponse . '. ' . $this->getEpayErrorText($result->epayresponse));
                             throw new Exception('Transaction could not be captured by ePay: ' . $result->epayresponse . '. ' . $this->getEpayErrorText($result->epayresponse));
                         }
                     }
                 } else {
                     throw new Exception("Transaction could not be captured by ePay: " . $result->pbsResponse . '. ' . $this->getPbsErrorText($result->pbsResponse));
                 }
             }
         } else {
             //
             // Somehow the order was not found - this must be an error!
             //
             throw new Exception("Order not found - please check the epay_order_status table!");
         }
     } catch (Exception $e) {
         $session->addException($e, $e->getMessage() . " - Go to the ePay administration to capture the payment manually.");
     }
     return $this;
 }
Example #3
0
 * - $options[cache_wsdl] = WSDL_CACHE_BOTH, we advice 
 *   to cache the WSDL since we usually never change it.
 */
$client = new SoapClient("https://pal-test.adyen.com/pal/Payment.wsdl", array("login" => "YourWSUser", "password" => "YourWSUserPassword", "style" => SOAP_DOCUMENT, "encoding" => SOAP_LITERAL, "cache_wsdl" => WSDL_CACHE_BOTH, "trace" => 1));
/**
 * Perform capture request by sending in a 
 * modificationRequest, the protocol is defined 
 * in the WSDL. The following parameters are used:
 * - merchantAccount: The merchant account the payment was processed with.
 * - modificationAmount: The amount to capture
 * 	- currency: the currency must match the original payment
 * 	- amount: the value must be the same or less than the original amount
 * - originalReference: This is the pspReference that was assigned to the authorisation
 * - reference: If you wish, you can to assign your own reference or description to the modification. 
 */
try {
    $result = $client->capture(array("modificationRequest" => array("merchantAccount" => "YourMerchantAccount", "modificationAmount" => array("currency" => "EUR", "value" => "199"), "originalReference" => "PspReferenceOfTheAuthorisedPayment", "reference" => "YourReference")));
    /**
     * If the message was syntactically valid and merchantAccount is correct you will 
     * receive a captureResult response with the following fields:
     * - pspReference: A new reference to uniquely identify this modification request. 
     * - response: A confirmation indicating we receievd the request: [capture-received]. 
     * 
     * Please note: The result of the cancellation is sent via a notification with eventCode CAPTURE.
     */
    print_r($result);
} catch (SoapFault $ex) {
    print "<pre>";
    print $ex;
    print "<pre>";
}
Example #4
0
 /**
  * @param mixed $data
  * @return CaptureResponse
  */
 public function sendData($data)
 {
     $client = new \SoapClient($this->endpoint . '?WSDL');
     $result = $client->capture($data);
     return $this->response = new CaptureResponse($this, array('captureResult' => $result->captureResult, 'pbsResponse' => $result->pbsResponse, 'epayresponse' => $result->epayresponse));
 }
Example #5
0
function epay_daily_cron_job()
{
    $gateway = getGatewayVariables("epay");
    $query = mysql_query("SELECT * FROM tblinvoices INNER JOIN tblepay epay ON epay.invoiceid = tblinvoices.id WHERE tblinvoices.paymentmethod = 'epay' AND tblinvoices.status = 'Unpaid' AND (tblinvoices.duedate <= NOW() + INTERVAL 1 DAY) AND epay.`status` = 0");
    while ($row = mysql_fetch_array($query)) {
        try {
            //Capture
            $epay_params['merchantnumber'] = $gateway["merchantnumber"];
            $epay_params['amount'] = $row['total'] * 100;
            $epay_params['transactionid'] = $row['txnid'];
            $epay_params['group'] = "";
            $epay_params['pbsResponse'] = "-1";
            $epay_params['epayresponse'] = "-1";
            $soap = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL');
            $soap_capture_result = $soap->capture($epay_params);
            //Transaction OK
            if ($soap_capture_result->captureResult == true) {
                //OK capture
                addInvoicePayment($row['invoiceid'], $row['txnid'], $row['total'], 0, "epay");
                mysql_query("UPDATE tblepay SET status = 1 WHERE invoiceid = " . $row['invoiceid']);
            } else {
                //Error in capture
                logActivity("epay_daily_cron_job: TXNID: " . $row['txnid'] . " PBS: " . $soap_capture_result->pbsresponse . " ePay: " . $soap_capture_result->epayresponse);
                mysql_query("UPDATE tblepay SET status = 2 WHERE invoiceid = " . $row['invoiceid']);
            }
        } catch (Exception $e) {
            logActivity("epay_daily_cron_job: " . $e->getMessage());
        }
    }
}