2013-10-25 73 views
1

我正在嘗試通過curl調用來設置Virtual Merchant。Curl Virtual Merchant

$url = 'https://demo.myvirtualmerchant.com/VirtualMerchantDemo/process.do'; 

$request = curl_init($url); // initiate curl object 
      curl_setopt($request, CURLOPT_POST, 1); 
      curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response 
      curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) 
      curl_setopt($request, CURLOPT_POSTFIELDS, $fields_string); // use HTTP POST to send form data 
      curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. 
      curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false); 
      curl_setopt($request, CURLOPT_FOLLOWLOCATION, 1); 
      $post_response = curl_exec($request); // execute curl post and store results in $post_response 
      curl_close ($request); // close curl object 

      print_r($post_response);die(); 

字段設置屬性。

當我執行這個代碼,它首先重定向我空白頁,然後刷新刷新,但之後我已要求一些參數,如: 完善的過程,status.php ssl_email = & ssl_status = TEST MODE + & ssl_cvv2_response = P & ...等等...

的var_dump結果(前重定向)

串(1504) 「 」

+0

使用'var_dump'而不是'print_r'並查看給了你什麼。 –

+0

很確定'cURL'沒有重定向你,但是響應呢? – MackieeE

+0

string(1504)...所以你有數據。但是,我認爲它是xml,所以你什麼都看不到。嘗試echo htmlspecialchars($ post_response);或只需按 + 查看源 –

回答

0

補充一點:curl_setopt($請求,CURLOPT_RETURNTRANSFER,真正的);

0

我在虛擬商戶網關上工作過。

$url = 'https://demo.myvirtualmerchant.com/VirtualMerchantDemo/process.do'; 
$fields = array(
'ssl_merchant_id'=>'Enter the virtual merchant id', 
    'ssl_user_id'=>'Enter the user id', 
    'ssl_pin'=>'Enter the pin number', 
    'ssl_show_form'=>'false',//if it is true Converge virtual merchant send one form. 
    'ssl_transaction_type'=>'ccsale', 
    'ssl_avs_address'=> 'Enter ur address', 
    'ssl_avs_zip'=> 'Enter ur zip code', 
    'ssl_email'=>'Enter ur email id', 
    'ssl_first_name'=>'Enter ur first name', 
    'ssl_last_name'=>'Enter the last name', 
    'ssl_state'=>'Enter state', 
    'ssl_amount'=>'Enter amount details', 
    'ssl_card_number'=>'Enter Account card number',//For Dummy card number: '5123456789' 
    'ssl_exp_date'=>'Enter Expire date of card',//For Dummy expire date: '0522' 
    'ssl_cvv2cvc2'=>'Enter cvc number',//Dummy cvv number: '100' 
    'ssl_invoice_number'=>'Enter Invoice number',  
); 
$fields_string = http_build_query($fields); 
//open curl session 
$ch = curl_init(); 
//begin seting curl options 
//set URL 
curl_setopt($ch, CURLOPT_URL, $url); 
//set method 
curl_setopt($ch, CURLOPT_POST, 1); 
//set post data string 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); 
//these two options are frequently necessary to avoid SSL errors with PHP 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
//perform the curl post and store the result 
$result = curl_exec($ch); 
//close the curl session 
curl_close($ch);} 

您必須將值添加到$ fields_string,沒有值然後它將顯示爲空。如果您瞭解更多虛擬商戶轉到:here。在那pdf也有PHP示例代碼