public function _process_return() { $action = $this->CI->input->get('action', TRUE); if ($action === FALSE) { return new Merchant_response('failed', 'invalid_response'); } if ($action === 'success') { return new Merchant_response('return', '', $_POST['txn_id']); } if ($action === 'cancel') { return new Merchant_response('failed', 'payment_cancelled'); } if ($action === 'ipn') { // generate the post string from _POST $post_string = 'cmd=_notify-validate&' . http_build_query($_POST); $response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $post_string); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $memo = $this->CI->input->post('memo'); if (strpos("VERIFIED", $response['data']) !== FALSE) { // Valid IPN transaction. return new Merchant_response('authorized', $memo, $_POST['txn_id'], (string) $_POST['mc_gross']); } else { // Invalid IPN transaction return new Merchant_response('declined', $memo); } } }
public function _process($params) { $data = array('VPSProtocol' => '2.23', 'TxType' => 'PAYMENT', 'Vendor' => $this->settings['vendor'], 'VendorTxCode' => $params['transaction_id'], 'Description' => $params['reference'], 'Amount' => sprintf('%01.2f', $params['amount']), 'Currency' => $params['currency_code'], 'CardHolder' => $params['card_name'], 'CardNumber' => $params['card_no'], 'CV2' => $params['csc'], 'CardType' => strtoupper($params['card_type']), 'ExpiryDate' => $params['exp_month'] . $params['exp_year'] % 100, 'AccountType' => 'E', 'ApplyAVSCV2' => 2); if ($data['CardType'] == 'MASTERCARD') { $data['CardType'] = 'MC'; } if (!empty($params['card_issue'])) { $data['IssueNumber'] = $params['card_issue']; } if (!empty($params['start_month']) and !empty($params['start_year'])) { $data['StartDate'] = $params['start_month'] . $params['start_year'] % 100; } $response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $data); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } // convert weird ini-type format to a useful array $response_array = explode("\n", $response['data']); foreach ($response_array as $key => $value) { unset($response_array[$key]); $line = explode('=', $value, 2); $response_array[trim($line[0])] = isset($line[1]) ? trim($line[1]) : ''; } if (empty($response_array['Status'])) { return new Merchant_response('failed', 'invalid_response'); } elseif ($response_array['Status'] == 'OK') { return new Merchant_response('authorized', $response_array['StatusDetail'], $response_array['VPSTxId'], (double) $params['amount']); } else { return new Merchant_response('declined', $response_array['StatusDetail']); } }
public function _process($params) { $request = array('amount' => (int) ($params['amount'] * 100), 'card' => $params['token'], 'currency' => strtolower($params['currency_code']), 'description' => $params['reference']); $response = Merchant::curl_helper(self::API_ENDPOINT . '/v1/charges', $request, $this->settings['api_key']); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $data = json_decode($response['data']); if (isset($data->error)) { return new Merchant_response('declined', $data->error->message); } else { return new Merchant_response('authorized', '', $data->id, $data->amount / 100); } }
public function _process($params) { $card_name = explode(' ', $params['card_name'], 2); $data = array('USER' => $this->settings['username'], 'PWD' => $this->settings['password'], 'SIGNATURE' => $this->settings['signature'], 'VERSION' => '65.1', 'METHOD' => 'doDirectPayment', 'PAYMENTACTION' => 'Sale', 'AMT' => sprintf('%01.2f', $params['amount']), 'CURRENCYCODE' => $params['currency_code'], 'ACCT' => $params['card_no'], 'EXPDATE' => $params['exp_month'] . $params['exp_year'], 'CVV2' => $params['csc'], 'IPADDRESS' => $this->CI->input->ip_address(), 'FIRSTNAME' => $card_name[0], 'LASTNAME' => isset($card_name[1]) ? $card_name[1] : ''); if (isset($params['card_type'])) { $data['CREDITCARDTYPE'] = ucfirst($params['card_type']); if ($data['CREDITCARDTYPE'] == 'Mastercard') { $data['CREDITCARDTYPE'] = 'MasterCard'; } } if (isset($params['card_issue'])) { $data['ISSUENUMBER'] = $params['card_issue']; } if (isset($params['start_month']) and isset($params['start_year'])) { $data['STARTDATE'] = $params['start_month'] . $params['start_year']; } if (isset($params['address'])) { $data['STREET'] = $params['address']; } if (isset($params['city'])) { $data['CITY'] = $params['city']; } if (isset($params['region'])) { $data['STATE'] = $params['region']; } if (isset($params['postcode'])) { $data['ZIP'] = $params['postcode']; } if (isset($params['country'])) { $data['COUNTRYCODE'] = strtoupper($params['country']); } // send request to paypal $response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $data); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $response_array = array(); parse_str($response['data'], $response_array); if (empty($response_array['ACK'])) { return new Merchant_response('failed', 'invalid_response'); } elseif ($response_array['ACK'] == 'Success' or $response_array['ACK'] == 'SuccessWithWarning') { return new Merchant_response('authorized', '', $response_array['TRANSACTIONID'], (double) $response_array['AMT']); } elseif ($response_array['ACK'] == 'Failure' or $response_array['ACK'] == 'FailureWithWarning') { return new Merchant_response('declined', $response_array['L_ERRORCODE0'] . ': ' . $response_array['L_LONGMESSAGE0']); } else { return new Merchant_response('failed', 'invalid_response'); } }
public function _process($params) { $date_expiry = $params['exp_month']; $date_expiry .= $params['exp_year'] % 100; $request = '<Txn>' . '<PostUsername>' . $this->settings['username'] . '</PostUsername>' . '<PostPassword>' . $this->settings['password'] . '</PostPassword>' . '<CardHolderName>' . htmlspecialchars($params['card_name']) . '</CardHolderName>' . '<CardNumber>' . $params['card_no'] . '</CardNumber>' . '<Amount>' . sprintf('%01.2f', $params['amount']) . '</Amount>' . '<DateExpiry>' . $date_expiry . '</DateExpiry>' . '<Cvc2>' . $params['csc'] . '</Cvc2>' . '<InputCurrency>' . $params['currency_code'] . '</InputCurrency>' . '<TxnType>Purchase</TxnType>' . '<TxnId>' . $params['transaction_id'] . '</TxnId>' . '<MerchantReference>' . $params['reference'] . '</MerchantReference>' . '<EnableAddBillCard>' . (int) $this->settings['enable_token_billing'] . '</EnableAddBillCard>' . '</Txn>'; $response = Merchant::curl_helper(self::PROCESS_URL, $request); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $xml = simplexml_load_string($response['data']); if (!isset($xml->Success)) { return new Merchant_response('failed', 'invalid_response'); } elseif ($xml->Success == '1') { return new Merchant_response('authorized', (string) $xml->HelpText, (string) $xml->DpsTxnRef, (string) $xml->Transaction->Amount); } else { return new Merchant_response('declined', (string) $xml->HelpText, (string) $xml->DpsTxnRef); } }
public function _process_return() { if (($payment_code = $this->CI->input->get_post('AccessPaymentCode')) === FALSE) { return new Merchant_response('failed', 'invalid_response'); } $data = array('CustomerID' => $this->settings['customer_id'], 'UserName' => $this->settings['username'], 'AccessPaymentCode' => $_REQUEST['AccessPaymentCode']); $response = Merchant::curl_helper(self::PROCESS_RETURN_URL . '?' . http_build_query($data)); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $xml = simplexml_load_string($response['data']); if (!isset($xml->TrxnStatus)) { return new Merchant_response('failed', 'invalid_response'); } elseif ($xml->TrxnStatus == 'True') { return new Merchant_response('authorized', '', (string) $xml->TrxnNumber, (double) $xml->ReturnAmount); } else { return new Merchant_response('declined', (string) $xml->TrxnResponseMessage, (string) $xml->TrxnNumber); } }
public function _process($params) { // eway thows HTML formatted error if customerid is missing if (empty($this->settings['customer_id'])) { return new Merchant_response('failed', 'Missing Customer ID!'); } $request = '<ewaygateway>' . '<ewayCustomerID>' . $this->settings['customer_id'] . '</ewayCustomerID>' . '<ewayTotalAmount>' . sprintf('%01d', $params['amount'] * 100) . '</ewayTotalAmount>' . '<ewayCustomerInvoiceDescription>' . $params['reference'] . '</ewayCustomerInvoiceDescription>' . '<ewayCustomerInvoiceRef>' . $params['transaction_id'] . '</ewayCustomerInvoiceRef>' . '<ewayCardHoldersName>' . $params['card_name'] . '</ewayCardHoldersName>' . '<ewayCardNumber>' . $params['card_no'] . '</ewayCardNumber>' . '<ewayCardExpiryMonth>' . $params['exp_month'] . '</ewayCardExpiryMonth>' . '<ewayCardExpiryYear>' . $params['exp_year'] % 100 . '</ewayCardExpiryYear>' . '<ewayTrxnNumber>' . $params['transaction_id'] . '</ewayTrxnNumber>' . '<ewayCVN>' . $params['csc'] . '</ewayCVN>' . '<ewayCustomerFirstName></ewayCustomerFirstName>' . '<ewayCustomerLastName></ewayCustomerLastName>' . '<ewayCustomerEmail></ewayCustomerEmail>' . '<ewayCustomerAddress></ewayCustomerAddress>' . '<ewayCustomerPostcode></ewayCustomerPostcode>' . '<ewayOption1></ewayOption1>' . '<ewayOption2></ewayOption2>' . '<ewayOption3></ewayOption3>' . '</ewaygateway>'; $response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $request); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $xml = simplexml_load_string($response['data']); if (!isset($xml->ewayTrxnStatus)) { return new Merchant_response('failed', 'invalid_response'); } elseif ($xml->ewayTrxnStatus == 'True') { return new Merchant_response('authorized', (string) $xml->ewayTrxnError, (string) $xml->ewayTrxnNumber, (double) $xml->ewayReturnAmount / 100); } else { return new Merchant_response('declined', (string) $xml->ewayTrxnError); } }
public function _process_return() { if ($this->CI->input->get('result', TRUE) === FALSE) { return new Merchant_response('failed', 'invalid_response'); } // validate dps response $request = '<ProcessResponse>' . '<PxPayUserId>' . $this->settings['user_id'] . '</PxPayUserId>' . '<PxPayKey>' . $this->settings['key'] . '</PxPayKey>' . '<Response>' . $this->CI->input->get('result', TRUE) . '</Response>' . '</ProcessResponse>'; $response = Merchant::curl_helper(self::PROCESS_URL, $request); if (!empty($response['error'])) { return new Merchant_response('failed', $response['error']); } $xml = simplexml_load_string($response['data']); if (!isset($xml->Success)) { return new Merchant_response('failed', 'invalid_response'); } elseif ($xml->Success == '1') { return new Merchant_response('authorized', (string) $xml->ResponseText, (string) $xml->DpsTxnRef, (double) $xml->AmountSettlement); } else { return new Merchant_response('declined', (string) $xml->ResponseText, (string) $xml->DpsTxnRef); } }