Пример #1
0
 public function notify($requestArray)
 {
     $this->cleanRequestData($requestArray);
     if (!$this->goodRequest($requestArray)) {
         return new TransactionError('Bad _ss2 signature!', $requestArray);
     }
     if ($this->getConfigValue('merchantid') != $requestArray['merchantid']) {
         //			return new TransactionError('Incorrect MerchantID!', $requestArray);
     }
     if ($this->getConfigValue('projectid') != $requestArray['projectid']) {
         return new TransactionError('Incorrect ProjectID!', $requestArray);
     }
     if ($requestArray['status'] != '1') {
         return new TransactionError('Status not accepted: ' . $requestArray['status'], $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['orderid']);
     $result->amount->set($requestArray['amount'] / 100);
     $result->currency->set($requestArray['currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     // -- Shop must return OK for our server --
     echo 'OK';
     return $result;
 }
Пример #2
0
 public function notify($requestArray)
 {
     $requestArray['version'] = '1.2open';
     $keys = array('TPE', 'date', 'montant', 'reference', 'texte-libre', 'version', 'code-retour');
     $values = array();
     foreach (array('TPE', 'date', 'montant', 'reference', 'texte-libre', 'version', 'code-retour') as $key) {
         $values[$key] = $requestArray[$key];
     }
     $macParams = array_combine($keys, $values);
     $mac = $requestArray['retourPLUS'] . implode('+', $macParams) . '+';
     $hash = strtoupper($this->CMCIC_hmac($mac));
     ob_end_clean();
     file_put_contents(ClassLoader::getRealPath('cache.') . get_class($this) . '.php', var_export($requestArray, true));
     if ('annulation' == strtolower($requestArray['code-retour'])) {
         printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'Annulation');
     } else {
         if ($hash == $requestArray['MAC']) {
             $result = new TransactionResult();
             $result->gatewayTransactionID->set($requestArray['reference']);
             $result->amount->set(substr($requestArray['montant'], 0, -3));
             $result->currency->set(substr($requestArray['montant'], -3));
             $result->rawResponse->set($requestArray);
             $result->setTransactionType(TransactionResult::TYPE_SALE);
             printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'OK');
             return $result;
         } else {
             printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'Document falsifie');
             exit;
         }
     }
 }
Пример #3
0
 public function notify($requestArray)
 {
     if ($secretWord = $this->getConfigValue('secretWord')) {
         // Check the SHA1 signature
         $format = '%s%s%s%s%s%s%s%s%s%s%s';
         $shastr = sprintf($format, $requestArray['orderID'], $requestArray['currency'], $requestArray['amount'], $requestArray['PM'], $requestArray['ACCEPTANCE'], $requestArray['STATUS'], $requestArray['CARDNO'], $requestArray['PAYID'], $requestArray['NCERROR'], $requestArray['BRAND'], $secretWord);
         $Sha1 = strtoupper(sha1($shastr));
         // Ensures that no returning parameter has been altered
         if ($Sha1 != $requestArray['SHASIGN']) {
             return new TransactionError('SHASIGN mismatch', $requestArray);
         }
     }
     // Check payment authorization
     if (!in_array($requestArray['STATUS'], array(5, 51, 59, 9, 91, 95))) {
         return new TransactionError('Payment Not Authorized. Status = ' . $requestArray['STATUS'], $requestArray);
     }
     // Transaction OK
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['orderID']);
     $result->amount->set($requestArray['amount']);
     $result->currency->set($requestArray['currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #4
0
 public function void()
 {
     $result = new TransactionResult();
     $result->amount->set($this->details->amount->get());
     $result->currency->set($this->details->currency->get());
     $result->setTransactionType(TransactionResult::TYPE_VOID);
     return $result;
 }
Пример #5
0
 public function notify($requestArray)
 {
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['cartId']);
     $result->amount->set($requestArray['cost']);
     $result->currency->set($requestArray['currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #6
0
 public function notify($requestArray)
 {
     $requestArray = $_REQUEST;
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['ID']);
     $result->amount->set($requestArray['AMOUNT'] / 100);
     $result->currency->set($requestArray['CURRENCY']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #7
0
 public function extractTransactionResult($array)
 {
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($array['GOOGLE-ORDER-NUMBER'][0]['VALUE']);
     $total = $array['ORDER-TOTAL'][0];
     $result->amount->set($total['VALUE']);
     $result->currency->set($total['ATTRIBUTES']['CURRENCY']);
     $result->rawResponse->set($array);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #8
0
 public function notify($requestArray)
 {
     if ('69.20.58.35' != $_SERVER['REMOTE_ADDR']) {
         exit;
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['transaction_id']);
     $result->amount->set($requestArray['total']);
     $result->currency->set($requestArray['currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #9
0
 public function notify($requestArray)
 {
     if ('PD' == $requestArray['responseCode']) {
         return new TransactionError('Transaction declined', $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['transactionID']);
     $result->amount->set(str_replace(',', '', $requestArray['paymentAmount']));
     $result->currency->set($requestArray['currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
 public function notify($requestArray)
 {
     // test transactions enabled?
     if ($requestArray['Live'] != 1 && !$this->getConfigValue('test')) {
         return new TransactionError('Test transactions disabled', $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['receiptnumber']);
     $result->amount->set($requestArray['xxxAmount']);
     $result->currency->set(0 == $requestArray['Currency'] ? 'CAD' : 'USD');
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #11
0
 public function notify($requestArray)
 {
     // check for secret word
     if ($requestArray['ap_securitycode'] != $this->getConfigValue('SECURITY_CODE')) {
         return new TransactionError('Invalid AlertPay security code', $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['ap_referencenumber']);
     $result->amount->set($requestArray['ap_amount']);
     $result->currency->set($requestArray['ap_currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #12
0
Файл: VCS.php Проект: saiber/www
 public function notify($requestArray)
 {
     if (empty($requestArray['test'])) {
         echo '<CallBackResponse>Accepted</CallBackResponse>';
     }
     if (substr($requestArray['p3'], -8) == 'APPROVED') {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($requestArray['p2']);
         $result->amount->set($requestArray['p6']);
         $result->currency->set('ZAR');
         $result->rawResponse->set($requestArray);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
         return $result;
     }
 }
Пример #13
0
 public function notify($requestArray)
 {
     //file_put_contents(ClassLoader::getRealPath('cache.') . get_class($this) . '.php', var_export($requestArray, true));
     $Checksum = $this->verifyChecksum($requestArray['Merchant_Id'], $requestArray['Order_Id'], $requestArray['Amount'], $requestArray['AuthDesc'], $requestArray['Checksum'], $this->getConfigValue('WorkingKey'));
     if ($Checksum == "true" && in_array($requestArray['AuthDesc'], array('Y', 'B'))) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($requestArray['-']);
         $result->amount->set($requestArray['Amount']);
         $result->currency->set('INR');
         $result->rawResponse->set($requestArray);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
     } else {
         $result = new TransactionError('Invalid checksum', $requestArray);
     }
     return $result;
 }
Пример #14
0
 public function notify($requestArray)
 {
     if (1 == $requestArray['x_response_code']) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($requestArray['x_trans_id']);
         $result->amount->set($requestArray['x_amount']);
         $result->currency->set('USD');
         $result->rawResponse->set($requestArray);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
     } else {
         $result = new TransactionError($requestArray['x_response_reason_text'], $requestArray);
         $url = ActiveRecordModel::getApplication()->getRouter()->createUrl(array('controller' => 'checkout', 'action' => 'pay', 'query' => array('error' => $requestArray['x_response_reason_text'])));
         ob_clean();
         echo '<html><head><meta http-equiv="REFRESH" content="0;url=' . $url . '"></HEAD></html>';
         exit;
     }
     return $result;
 }
Пример #15
0
 public function notify($requestArray)
 {
     $secretWord = $this->getConfigValue('secretWord');
     $md5 = $requestArray['merchant_id'] . $requestArray['transaction_id'] . strtoupper(md5($secretWord)) . $requestArray['mb_amount'] . $requestArray['mb_currency'] . $requestArray['status'];
     file_put_contents('/var/www/livecart/cache/mb-md', $md5);
     $md5 = strtoupper(md5($md5));
     if (in_array($requestArray['status'], array(1, 2)) && ($md5 == $requestArray['md5sig'] || !$secretWord) && $this->getConfigValue('email') == $requestArray['pay_to_email']) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($requestArray['mb_transaction_id']);
         $result->amount->set($requestArray['amount']);
         $result->currency->set($requestArray['currency']);
         $result->rawResponse->set($requestArray);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
     } else {
         $result = new TransactionError('Transaction declined', $requestArray);
     }
     return $result;
 }
Пример #16
0
 public function notify($requestArray)
 {
     // check for secret word
     if ($secretWord = $this->getConfigValue('secretWord')) {
         $orderNum = 'Y' == $requestArray['demo'] ? 1 : $requestArray['order_number'];
         $expected = $secretWord . $requestArray['sid'] . $orderNum . $requestArray['total'];
         if ($requestArray['key'] != strtoupper(md5($expected))) {
             return new TransactionError('Invalid 2Checkout secret word', $requestArray);
         }
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['order_number']);
     $result->amount->set($requestArray['total']);
     $result->currency->set($this->get2CoCurrency());
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #17
0
 public function notify($requestArray)
 {
     //file_put_contents(ClassLoader::getRealPath('cache.') . 'notify.php', var_export($requestArray, true));
     if ($requestArray['md5key'] == $this->getMd5Key($requestArray)) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($requestArray['transact']);
         $result->amount->set($requestArray['amount'] / 100);
         $result->rawResponse->set($requestArray);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
         $currency = $this->getCurrency($requestArray['currency']);
         if (is_numeric($currency)) {
             $currency = $this->getCurrency($currency);
         }
         $result->currency->set($currency);
     } else {
         $result = new TransactionError('md5key mismatch', $requestArray);
     }
     return $result;
 }
Пример #18
0
 public function notify($requestArray)
 {
     // $this->debug('notify()', $requestArray);
     if (array_key_exists('CpiResultsCode', $requestArray) == false || $requestArray['CpiResultsCode'] != 0 || array_key_exists('OrderHash', $requestArray) == false) {
         return new TransactionError('Transaction declined', $requestArray);
     }
     $data = $_POST;
     unset($data['OrderHash']);
     if ($requestArray['OrderHash'] != generateHash(array_values($data), $this->getConfigValue('key'))) {
         return new TransactionError('Transaction declined', $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['OrderId']);
     $result->amount->set($requestArray['PurchaseAmount'] / 100);
     $result->currency->set(self::currencyFromNumeric3($requestArray['PurchaseCurrency']));
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #19
0
 public function notify($requestArray)
 {
     $data = $this->getReturnData($requestArray);
     if ('OK' == $data['Status']) {
         list($id, $rand, $currency) = explode('-', $data['VendorTxCode']);
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($data['VPSTxId']);
         $result->amount->set($data['Amount']);
         $result->currency->set($currency);
         $result->rawResponse->set($data);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
         $checks = array();
         foreach (array_intersect_key($data, array_flip(array('AVSCV2', 'AddressResult', 'PostCodeResult', 'CV2Result'))) as $check => $res) {
             $checks[] = $check . ': ' . $res;
         }
         $result->details->set(implode('<br>', $checks));
     } else {
         $result = new TransactionError($data['StatusDetail'], $requestArray);
     }
     return $result;
 }
Пример #20
0
 public function notify($requestArray)
 {
     $this->saveDebug($requestArray);
     if ('ORDER_CREATED' != $requestArray['message_type']) {
         return new TransactionError('Invalid 2CO message type', $requestArray);
     }
     // check for secret word
     if (0 && ($secretWord = $this->getConfigValue('secretWord'))) {
         $expected = $requestArray['sale_id'] . $requestArray['vendor_id'] . $requestArray['invoice_id'] . $secretWord;
         if ($requestArray['md5_hash'] != strtoupper(md5($expected))) {
             return new TransactionError('Invalid 2Checkout secret word', $requestArray);
         }
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['sale_id']);
     $result->amount->set($requestArray['invoice_list_amount']);
     $result->currency->set($requestArray['list_currency']);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
 public function notify($requestArray)
 {
     // assign posted variables to local variables
     $paymentStatus = $requestArray['payment_status'];
     $paymentAmount = $requestArray['mc_gross'];
     $paymentCurrency = $requestArray['mc_currency'];
     $txn_id = $requestArray['txn_id'];
     $receiverEmail = $requestArray['receiver_email'];
     $payerEmail = $requestArray['payer_email'];
     // read the post from PayPal system and add 'cmd'
     $req = 'cmd=_notify-validate';
     foreach ($requestArray as $key => $value) {
         if (is_array($value)) {
             continue;
         }
         $value = urlencode(stripslashes($value));
         $req .= "&" . $key . "=" . $value;
     }
     // check that receiver_email is your Primary PayPal email
     if (strtolower($receiverEmail) != strtolower($this->getConfigValue('EMAIL'))) {
         throw new PaymentException('Invalid PayPal receiver e-mail');
     }
     // post back to PayPal system to validate
     $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
     $fp = fsockopen('www.' . ($this->getConfigValue('SANDBOX') ? 'sandbox.' : '') . 'paypal.com', 80, $errno, $errstr, 30);
     if (!$fp) {
         throw new PaymentException('Could not connect to PayPal server');
     } else {
         fputs($fp, $header . $req);
         while (!feof($fp)) {
             $res = fgets($fp, 1024);
             if (is_numeric(strrpos($res, "VERIFIED"))) {
                 if ($paymentStatus != 'Completed' && !$this->getConfigValue('SANDBOX')) {
                     throw new PaymentException('Payment is not completed');
                 }
             } else {
                 if (is_numeric(strrpos($res, "INVALID"))) {
                     throw new PaymentException('Invalid response from PayPal');
                 }
             }
         }
         fclose($fp);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['txn_id']);
     $result->amount->set($requestArray['mc_gross']);
     $result->currency->set($requestArray['mc_currency']);
     $result->rawResponse->set($requestArray);
     if ('Completed' == $requestArray['payment_status']) {
         $result->setTransactionType(TransactionResult::TYPE_SALE);
     } else {
         $result->setTransactionType(TransactionResult::TYPE_AUTH);
     }
     return $result;
 }
 protected function processAuth($api, $type)
 {
     $paypal = $this->getHandler($api);
     $address = PayPalTypes::AddressType($this->details->firstName->get() . ' ' . $this->details->lastName->get(), $this->details->address->get(), '', $this->details->city->get(), $this->details->state->get(), $this->details->postalCode->get(), $this->details->country->get(), $this->details->phone->get());
     $personName = PayPalTypes::PersonNameType('', $this->details->firstName->get(), '', $this->details->lastName->get());
     $payerInfo = PayPalTypes::PayerInfoType($this->details->email->get(), $this->details->clientID->get(), 'verified', $personName, $this->details->country->get(), '', $address);
     $paymentDetails = PayPalTypes::PaymentDetailsType($this->details->amount->get(), $this->details->amount->get(), 0, 0, 0, $this->details->description->get(), $this->details->clientID->get(), $this->details->invoiceID->get(), '', '', '', array(), $this->details->currency->get());
     $paypal->setParams($type, $this->data['token'], $this->data['PayerID'], $paymentDetails);
     $paypal->execute($api);
     if ($paypal->success()) {
         $response = $paypal->getAPIResponse();
         if (isset($response->Errors)) {
             $error = isset($response->Errors->LongMessage) ? $response->Errors : ($error = $response->Errors[0]);
             return new TransactionError($error->LongMessage, $response);
         } else {
             $paymentInfo = $response->DoExpressCheckoutPaymentResponseDetails->PaymentInfo;
             $result = new TransactionResult();
             $result->gatewayTransactionID->set($paymentInfo->TransactionID);
             $result->amount->set($paymentInfo->GrossAmount);
             $result->currency->set($response->Currency);
             $result->rawResponse->set($response);
             if ('Sale' == $type) {
                 $result->setTransactionType(TransactionResult::TYPE_SALE);
             } else {
                 $result->setTransactionType(TransactionResult::TYPE_AUTH);
             }
             return $result;
         }
     } else {
         return $paypal->getAPIException();
     }
 }
Пример #23
0
 public function notify($requestArray)
 {
     if ($requestArray['valid'] == 'false') {
         return new TransactionError('Transaction declined', $requestArray);
     }
     // 1. Remove the domain
     $callbackStr = $_SERVER['REQUEST_URI'];
     // 2. Remove the hash parameter
     $callbackStr = substr($callbackStr, 0, strrpos($callbackStr, '&hash=') + 1);
     // 4. Append your secret digest key
     $callbackStr .= $this->getConfigValue('digestkey');
     // 5. Encrypt using MD5
     $callbackStr = md5($callbackStr);
     // 6. compare it with the version sent by PayPoint.net
     if ($requestArray['hash'] != $callbackStr) {
         return new TransactionError('Invalid hash', $requestArray);
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['trans_id']);
     $result->amount->set($requestArray['amount']);
     $result->currency->set(array_key_exists('currency', $requestArray) ? $requestArray['currency'] : self::PAYPOINTLITE_DEFAULT_CURRENCY);
     $result->rawResponse->set($requestArray);
     $result->setTransactionType(TransactionResult::TYPE_SALE);
     return $result;
 }
Пример #24
0
 private function process()
 {
     set_time_limit(0);
     $this->initHandler();
     if ($this->details->gatewayTransactionID->get()) {
         $this->addField('x_trans_id', $this->details->gatewayTransactionID->get());
     }
     // construct the fields string to pass to authorize.net
     $fields = array();
     foreach ($this->fields as $key => $value) {
         $fields[] = $key . '=' . urlencode($value);
     }
     // execute the HTTPS post via CURL
     $ch = curl_init($this->gateway);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $fields));
     //curl_setopt($ch, CURLOPT_PROXY, 'proxy.shr.secureserver.net');
     //curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
     $response = urldecode(curl_exec($ch));
     if (curl_errno($ch)) {
         return new TransactionError(curl_error($ch), $this->fields);
     }
     curl_close($ch);
     $keys = array("Response Code", "Response Subcode", "Response Reason Code", "Response Reason Text", "Approval Code", "AVS Result Code", "Transaction ID", "Invoice Number", "Description", "Amount", "Method", "Transaction Type", "Customer ID", "Cardholder First Name", "Cardholder Last Name", "Company", "Billing Address", "City", "State", "Zip", "Country", "Phone", "Fax", "Email", "Ship to First Name", "Ship to Last Name", "Ship to Company", "Ship to Address", "Ship to City", "Ship to State", "Ship to Zip", "Ship to Country", "Tax Amount", "Duty Amount", "Freight Amount", "Tax Exempt Flag", "PO Number", "MD5 Hash", "Card Code (CVV2/CVC2/CID) Response Code", "Cardholder Authentication Verification Value (CAVV) Response Code");
     $values = $this->getCsvValues($response, '|');
     // add additional keys for reserved fields and merchant defined fields
     for ($i = 0; $i <= 27; $i++) {
         array_push($keys, 'Reserved Field ' . $i);
     }
     $i = 0;
     while (count($keys) < count($values)) {
         array_push($keys, 'Merchant Defined Field ' . ++$i);
     }
     while (count($values) < count($keys)) {
         array_push($values, '');
     }
     $result = array_combine($keys, $values);
     // declined transaction
     if (1 != $result['Response Code'] || in_array($result['Response Reason Code'], array(311))) {
         return new TransactionError($result['Response Reason Text'], $result);
     }
     // prepare TransactionResult object
     $res = new TransactionResult();
     $res->gatewayTransactionID->set($result['Transaction ID']);
     $res->amount->set($result['Amount']);
     $res->currency->set('USD');
     $res->AVSaddr->set(in_array($result['AVS Result Code'], array('A', 'X', 'Y')));
     $res->AVSzip->set(in_array($result['AVS Result Code'], array('W', 'X', 'Y', 'Z')));
     $res->CVVmatch->set('M' == $result['AVS Result Code']);
     $res->rawResponse->set($result);
     switch (strtolower($result['Transaction Type'])) {
         case 'auth_capture':
             $res->setTransactionType(TransactionResult::TYPE_SALE);
             break;
         case 'auth_only':
             $res->setTransactionType(TransactionResult::TYPE_AUTH);
             break;
         case 'prior_auth_capture':
             $res->setTransactionType(TransactionResult::TYPE_CAPTURE);
             break;
         case 'void':
             $res->setTransactionType(TransactionResult::TYPE_VOID);
             break;
         case 'credit':
             $res->setTransactionType(TransactionResult::TYPE_REFUND);
             break;
         default:
             throw new PaymentException('Transaction type "' . $result['Transaction Type'] . '" is not implemented');
             break;
     }
     return $res;
 }
Пример #25
0
 public function capture()
 {
     $params = array();
     $params['merchant_id'] = $this->getConfigValue('merchant_id');
     $params['trnAmount'] = $this->details->amount->get();
     $params['trnType'] = 'PAC';
     $params['adjId'] = $this->details->get('gatewayTransactionID');
     $params['errorPage'] = $this->application->getRouter()->createUrl(array('controller' => 'index', 'action' => 'index'));
     $pairs = array();
     foreach ($params as $key => $value) {
         $pairs[] = $key . '=' . urlencode($value);
     }
     $url = 'https://www.beanstream.com/scripts/process_transaction.asp?' . $this->generateHash(implode('&', $pairs));
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     $res = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     if (strpos($res, 'Approved')) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set($this->details->get('gatewayTransactionID') . '-PAC');
         $result->amount->set($this->details->amount->get());
         $result->currency->set(ActiveRecordModel::getApplication()->getDefaultCurrencyCode());
         $result->rawResponse->set($info['url']);
         $result->setTransactionType(TransactionResult::TYPE_CAPTURE);
         return $result;
     } else {
         $q = array();
         parse_str(parse_url($info['url'], PHP_URL_QUERY), $q);
         return new TransactionError($q['messageText'], $info);
     }
     //var_dump($res);
 }
Пример #26
0
 public function testPaymentMethod()
 {
     ActiveRecordModel::getApplication()->getConfig()->setRuntime('INVENTORY_TRACKING', 'DISABLE');
     $this->product1->isEnabled->set(true);
     $this->product1->save();
     $this->order->addProduct($this->product1, 1);
     $this->order->save();
     ActiveRecord::clearPool();
     $this->order = CustomerOrder::getInstanceById($this->order->getID(), true);
     $this->order->loadAll();
     $this->assertEquals(1, $this->order->getShoppingCartItemCount());
     $condition = DiscountCondition::getNewInstance();
     $condition->isEnabled->set(true);
     $condition->conditionClass->set('RuleConditionPaymentMethodIs');
     $condition->addValue('TESTING');
     $condition->save();
     $this->assertEquals(0, count($this->order->getDiscountConditions(true)));
     $this->order->setPaymentMethod('TESTING');
     $this->assertEquals(1, count($this->order->getDiscountConditions(true)));
     $this->order->setPaymentMethod('AnotherOne');
     $this->assertEquals(0, count($this->order->getDiscountConditions(true)));
     // test finalized order
     ClassLoader::import('library.payment.TransactionResult');
     $transResult = new TransactionResult();
     $transResult->setTransactionType(TransactionResult::TYPE_SALE);
     $transResult->amount->set(10000);
     $transResult->currency->set('USD');
     $transaction = Transaction::getNewInstance($this->order, $transResult);
     $transaction->method->set('TESTING');
     $transaction->save();
     $this->order->finalize();
     ActiveRecord::clearPool();
     $reloaded = CustomerOrder::getInstanceById($this->order->getID(), true);
     $reloaded->loadAll();
     $this->assertTrue($reloaded->isExistingRecord());
     $this->assertEquals(1, $reloaded->getShoppingCartItemCount());
     $this->assertEquals(1, count($reloaded->getDiscountConditions(true)));
     $condition->removeValue('TESTING');
     $condition->addValue('Whatever');
     $condition->save();
     $this->assertEquals(0, count($reloaded->getDiscountConditions(true)));
 }
Пример #27
0
 public function notify($requestArray)
 {
     if (in_array($this->transactionResult->ResponseCode, array('00', '08', '10', '11', '16'))) {
         $result = new TransactionResult();
         $result->gatewayTransactionID->set((string) $this->transactionResult->AuthCode);
         $result->amount->set((string) $this->transactionResult->ReturnAmount);
         $result->currency->set((string) $this->transactionResult->MerchantOption2);
         $result->rawResponse->set($this->transactionResult);
         $result->setTransactionType(TransactionResult::TYPE_SALE);
         return $result;
     } else {
         return new TransactionError($this->transactionResult->ErrorMessage, $requestArray);
     }
 }
Пример #28
0
 public function process($Request_type)
 {
     $params = array();
     $params['Merchant_id'] = $this->getConfigValue('merchant');
     $params['Version'] = '3';
     $params['Customer_refno'] = $this->order->getID();
     $params['Transaction_id'] = $this->details->gatewayTransactionID->get();
     // The payment amount
     $params['Amount'] = round($this->details->amount->get() * 100);
     if ($this->getConfigValue('test')) {
         $params['Amount'] = 50001;
         // other values may not work in test mode.
     }
     $params['VAT'] = "0";
     $params['Response_URL'] = $this->application->getRouter()->getBaseUrl();
     $params['Request_type'] = $Request_type;
     $params['Delivery_date'] = date("Ymd");
     // yyyymmdd
     $params['MAC'] = md5($params['Merchant_id'] . $params['Version'] . $params['Customer_refno'] . $params['Transaction_id'] . $params['Amount'] . $params['VAT'] . $params['Response_URL'] . $params['Request_type'] . $params['Delivery_date'] . $this->getConfigValue('md5'));
     $path = $this->urlAppendParams($this->getConfigValue('test') ? 'https://test-epayment.auriganet.eu/admingw' : 'https://epayment.auriganet.eu/admingw', $params);
     $ch = curl_init($path);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = urldecode(curl_exec($ch));
     $requestArray = array();
     if (preg_match('/Location\\:.*/', $response, $m)) {
         list($location, $parameterString) = explode($params['Response_URL'] . '?', $m[0]);
         $pairs = explode('&', $parameterString);
         foreach ($pairs as $pair) {
             list($key, $value) = explode('=', $pair);
             $requestArray[trim($key)] = trim($value);
         }
     }
     // mac check
     $string = array();
     foreach (array('Merchant_id', 'Version', 'Customer_refno', 'Transaction_id', 'Status', 'Status_code', 'Credit_status_code', 'AuthCode', '3DSec', 'Batch_id', 'Currency', 'Payment_method', 'Card_num', 'Exp_date', 'Card_type', 'Risk_score', 'Issuing_bank', 'Ip_country', 'Issuing_country', 'Authorized_amount', 'Fee_amount', 'Credit_amount') as $field) {
         if (array_key_exists($field, $requestArray)) {
             $string[] = $requestArray[$field];
         }
     }
     $string[] = $this->getConfigValue('md5');
     if ($requestArray['MAC'] !== md5(implode('', $string))) {
         return new TransactionError('md5key mismatch', $requestArray);
     }
     // --
     if ($requestArray['Status'] !== 'A' || $requestArray['Status_code'] != '0') {
         return new TransactionError('Transaction error/denied', $requestArray);
     }
     if ($this->getConfigValue('test')) {
         $requestArray['Currency'] = 'USD';
         // for testing in shop w/o sek, changing back to usd
     }
     $result = new TransactionResult();
     $result->gatewayTransactionID->set($requestArray['Transaction_id']);
     $result->rawResponse->set($requestArray);
     $result->amount->set($this->details->amount->get());
     $result->currency->set($requestArray['Currency']);
     $result->setTransactionType(TransactionResult::TYPE_CAPTURE);
     return $result;
 }
Пример #29
0
 /**
  *  DoVoid implementation for all PayPal payment classes
  */
 public function processVoid(TransactionPayment $handler)
 {
     $details = $handler->getDetails();
     $paypal = $handler->getHandler('DoVoid');
     $paypal->setParams($details->gatewayTransactionID->get(), '');
     $paypal->execute();
     if ($paypal->success()) {
         $response = $paypal->getAPIResponse();
         if (isset($response->Errors)) {
             return new TransactionError($response->Errors->LongMessage, $response);
         } else {
             $result = new TransactionResult();
             $result->rawResponse->set($response);
             $result->setTransactionType(TransactionResult::TYPE_VOID);
             return $result;
         }
     } else {
         return $paypal->getAPIException();
     }
 }
Пример #30
0
 private function process()
 {
     $this->initHandler();
     if ($this->details->gatewayTransactionID->get()) {
         $this->addField('transaction', $this->details->gatewayTransactionID->get());
     }
     // calculate operation hash
     $hash = $this->getConfigValue('secret') . $this->fields['opcode'] . $this->getConfigValue('productid');
     switch ($this->fields['opcode']) {
         case 1:
         case 4:
             $hash .= $this->fields['fname'] . $this->fields['lname'] . $this->fields['street'] . $this->fields['ip'] . $this->fields['card_no'] . $this->fields['amount'];
             break;
         case 2:
         case 5:
         case 6:
         case 3:
             $hash .= $this->fields['transaction'] . (in_array($this->fields['opcode'], array(2, 3)) ? $this->fields['amount'] : '');
             break;
     }
     $this->addField('hash', md5($hash));
     set_time_limit(0);
     // construct the fields string to pass with HTTP request
     $fields = array();
     foreach ($this->fields as $key => $value) {
         $fields[] = $key . '=' . urlencode($value);
     }
     // execute the HTTPS post via CURL
     $ch = curl_init($this->gateway);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $fields));
     $response = trim(urldecode(curl_exec($ch)));
     if (curl_errno($ch)) {
         return new TransactionError(curl_error($ch), $this->fields);
     }
     curl_close($ch);
     $response = explode("\n", $response);
     if ('N|' == substr($response[0], 0, 2)) {
         return new TransactionError(substr($response[0], 2), $response);
     }
     // get transaction ID
     $transactionID = '';
     foreach ($response as $line) {
         if ('T' == substr($line, 0, 2)) {
             $values = explode('|', $line);
             $transactionID = $values[1];
         }
     }
     // prepare TransactionResult object
     $res = new TransactionResult();
     $res->gatewayTransactionID->set($transactionID);
     $res->amount->set($this->fields['amount']);
     $res->currency->set($this->fields['currency']);
     $res->rawResponse->set($response);
     switch ($this->fields['opcode']) {
         case self::OP_SALE:
             $res->setTransactionType(TransactionResult::TYPE_SALE);
             break;
         case self::OP_AUTH:
             $res->setTransactionType(TransactionResult::TYPE_AUTH);
             break;
         case self::OP_CAPTURE:
             $res->setTransactionType(TransactionResult::TYPE_CAPTURE);
             break;
         case self::OP_VOID:
             $res->setTransactionType(TransactionResult::TYPE_VOID);
             break;
         case self::OP_REFUND:
             $res->setTransactionType(TransactionResult::TYPE_REFUND);
             break;
         default:
             throw new PaymentException('Transaction type "' . $this->fields['opcode'] . '" is not implemented');
             break;
     }
     return $res;
 }