Advertisement
Guest User

Untitled

a guest
Dec 9th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1. <?php
  2. $url = 'http://your_domain.com/silent_post';
  3. $data = array(
  4.     'x_response_code' => '1',
  5.     'x_response_subcode' => '1',
  6.     'x_response_reason_code' => '1',
  7.     'x_response_reason_text' => 'This transaction has been approved.',
  8.     'x_auth_code' => '',
  9.     'x_avs_code' => 'P',
  10.     'x_trans_id' => '1821199455',
  11.     'x_invoice_num' => '',
  12.     'x_description' => '',
  13.     'x_amount' => '9.95',
  14.     'x_method' => 'CC',
  15.     'x_type' => 'auth_capture',
  16.     'x_cust_id' => '1',
  17.     'x_first_name' => 'John',
  18.     'x_last_name' => 'Smith',
  19.     'x_company' => '',
  20.     'x_address' => '',
  21.     'x_city' => '',
  22.     'x_state' => '',
  23.     'x_zip' => '',
  24.     'x_country' => '',
  25.     'x_phone' => '',
  26.     'x_fax' => '',
  27.     'x_email' => '',
  28.     'x_ship_to_first_name' => '',
  29.     'x_ship_to_last_name' => '',
  30.     'x_ship_to_company' => '',
  31.     'x_ship_to_address' => '',
  32.     'x_ship_to_city' => '',
  33.     'x_ship_to_state' => '',
  34.     'x_ship_to_zip' => '',
  35.     'x_ship_to_country' => '',
  36.     'x_tax' => '0.0000',
  37.     'x_duty' => '0.0000',
  38.     'x_freight' => '0.0000',
  39.     'x_tax_exempt' => 'FALSE',
  40.     'x_po_num' => '',
  41.     'x_MD5_Hash' => 'A375D35004547A91EE3B7AFA40B1E727',
  42.     'x_cavv_response' => '',
  43.     'x_test_request' => 'false',
  44.     'x_subscription_id' => '365314',
  45.     'x_subscription_paynum' => '1',
  46. );
  47.  
  48. $parameters = array(
  49.     'http' => array(
  50.         'method' => 'POST',
  51.         'header'  => 'Content-type: application/x-www-form-urlencoded' . "\r\n",
  52.         'content' => http_build_query($data),
  53.     )
  54. );
  55.  
  56. $start = microtime(true);
  57. $pointer = fopen($url, 'rb', false, stream_context_create($parameters));
  58. if (!$pointer) {
  59.     die('Cannot open URL.');
  60. }
  61.  
  62. $response = stream_get_contents($pointer);
  63.  
  64. fclose($pointer);
  65.  
  66. $elapsed = microtime(true) - $start;
  67.  
  68. if ($response === false) {
  69.     die('Cannot read from URL');
  70. }
  71.  
  72. echo 'Request took ' . round($elapsed, 2) . ' seconds. ';
  73. echo 'Response (' . strlen(utf8_decode($response)) . ' Bytes) was:<hr/>' . $response;
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement