Last active
August 29, 2015 14:23
-
-
Save rowatt/32dfdc6334bf5d7b3613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once( 'classes/class.config.php' ); | |
require_once( 'classes/class.fdms_tools.php' ); | |
$curlSession = curl_init(); | |
$post_data[ 'chargetotal' ] = '10.00'; | |
$post_data[ 'paymentMethod' ] = 'V'; | |
$post_data[ 'creditcard_name' ] = 'Mark Anderson'; | |
$post_data[ 'baddr1' ] = '123 High St'; | |
$post_data[ 'bzip' ] = 'IV36 3TZ'; | |
$post_data[ 'bcountry' ] = 'UK'; | |
curl_setopt( $curlSession, CURLOPT_URL, FDMS_Tools::$url ); | |
//add required FDMS hidden fields | |
FDMS_Tools::add_hidden_fields( $post_data ); | |
$post_data['hash'] = FDMS_Tools::get_hash( $post_data['chargetotal'], FDMS_Tools::$currency_code ); | |
printf( '<h1>Post URL</h1><pre><code>%s</code></pre>', FDMS_Tools::$url ); | |
printf( '<h1>Post Data</h1><pre><code>%s</code></pre>', print_r( $post_data, true ) ); | |
$data = http_build_query( $post_data ); | |
printf( '<h1>HTTP Query</h1><pre><code>%s</code></pre>', $data ); | |
curl_setopt( $curlSession, CURLOPT_POSTFIELDS, $data ); | |
curl_setopt( $curlSession, CURLOPT_FOLLOWLOCATION, TRUE ); | |
curl_setopt( $curlSession, CURLOPT_HEADER, TRUE ); | |
curl_setopt( $curlSession, CURLOPT_POST, 1 ); | |
curl_setopt( $curlSession, CURLOPT_RETURNTRANSFER, 1 ); | |
curl_setopt( $curlSession, CURLOPT_TIMEOUT, 30 ); | |
curl_setopt( $curlSession, CURLOPT_SSL_VERIFYPEER, FALSE ); | |
curl_setopt( $curlSession, CURLOPT_SSL_VERIFYHOST, 2 ); | |
//Send the request and store the result in an array | |
$rawresponse = curl_exec($curlSession); | |
if(curl_error($curlSession)) | |
{ | |
printf( '<h1>cURL Error</h1><pre><code>%s</code></pre>', curl_error($curlSession) ); | |
} | |
printf( '<h1>cURL Response</h1><pre><code>%s</code></pre>', $rawresponse ); | |
phpinfo(); | |
/* EOF */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment