function payWithCreditCardPayflow($data) { global $wpdb; if (is_array($data)) { $request_params = array('HOSTPORT' => 443, 'USER' => PAYFLOW_API_USER, 'VENDOR' => PAYFLOW_API_VENDOR, 'PARTNER' => PAYFLOW_API_PARTNER, 'PWD' => PAYFLOW_API_PASSWORD, 'TENDER' => 'C', 'TRXTYPE' => 'S', 'ACCT' => $data['ACCT'], 'EXPDATE' => $data['EXPDATE'], 'CVV2' => $data['CVV2'], 'AMT' => $data['AMT'], 'CURRENCY' => 'AUD'); $nvp_string = ''; foreach ($request_params as $var => $val) { $nvp_string .= '&' . $var . '=' . urlencode($val); } $curl = curl_init(); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_URL, PAYFLOW_API_ENDPOINT); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string); $result = curl_exec($curl); curl_close($curl); $nvp_response_array = parse_str($result); $response = NVPToArray($result); // echo '<pre>'; // print_r($response); return $response; } }
public function checkusernameAction() { global $mySession; $db = new Db(); //$username = $_REQUEST['username']; //$password = $_REQUEST['password']; $dataForm = NVPToArray($_REQUEST['Data']); $myObj = new Users(); $result = $myObj->CheckLogin($dataForm); if ($result != "" and count($result) > 0 && $result[0]['user_status'] == 1) { $mySession->LoggedUserId = $result[0]['user_id']; exit("1"); } else { exit("0"); } }
public function processownerAction() { global $mySession; $db = new Db(); $dataForm = NVPToArray($_REQUEST['username']); $photo = $_REQUEST['photo']; $dataForm['photo'] = $photo; $myObj = new Users(); $Result = $myObj->SaveUser($dataForm, 2); if ($Result > 0) { exit("s"); } else { exit("f"); } }
} $nvp_string = ltrim($nvp_string, '&'); //echo "<pre>";print_r($nvp_string);exit; // Send NVP string to PayPal and store response $curl = curl_init(); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_URL, $api_endpoint); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string); $result = curl_exec($curl); //echo $result.'<br /><br />'; curl_close($curl); // Parse the API response $result_array = NVPToArray($result); echo '<pre />'; print_r($result_array); //step - 2 $SESSION['paypal_token'] = $result_array['TOKEN']; header("Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" . $result_array['TOKEN'] . ""); // Function to convert NTP string to an array function NVPToArray($NVPString) { $proArray = array(); while (strlen($NVPString)) { // name $keypos = strpos($NVPString, '='); $keyval = substr($NVPString, 0, $keypos); // value $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
private function process_transaction_search($start, $end) { /* Make the API call to PayPal, using API signature. The API response is stored in an associative array called $resArray */ $nvpStr = $this->format_nvp_search_str($start, $end); $resArray = hash_call("TransactionSearch", $nvpStr); if (!$resArray) { var_dump($resArray); $this->_damage_error($start, $end); return false; } /* Next, collect the API request in the associative array $reqArray as well to display back to the browser. Normally you wouldnt not need to do this, but its shown for testing */ $reqArray = $_SESSION['nvpReqArray']; /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") { var_dump($resArray); $this->_damage_error($start, $end); return false; } $resArray = NVPToArray($resArray); return $resArray['transactions']; }