<!DOCTYPE html> <?php // Notes: //Written with PHP 5.3.28 //Ensure that the time on the PHP hosting server is current //When publishing, name the .php file “SWPRedirect.php” to account for $action_url="SWPRedirect.php"; on line 129 //Replace API LOGIN ID and [SECURE TRANSACTION] KEY values with those set in Virtual Terminal for the merchant in the environment where the code is being used //Provided on an "AS-IS" basis with no warranties of usability, implicit or explicitly stated ?> <?php function get_UTC_Time() { date_default_timezone_set("America/Chicago"); $unixtime=strtotime(gmdate('Y-m-d H:i:s')); $millitime=microtime(true) * 1000; $utc=number_format(($millitime * 10000) + 621355968000000000 , 0,'.', ''); return $utc; } function calculate_HMACMD5_hash($message_to_hash, $key) { $hash = hash_hmac('md5', $message_to_hash, $key); return $hash; } if(isset($_POST['submit'])) { $action_url=$_POST['environment_url']; $pg_api_login_id=$_POST['pg_api_login_id']; $key=$_POST['key']; $pg_transaction_type=$_POST['pg_transaction_type']; $pg_version_number=$_POST['pg_version_number']; $pg_total_amount=$_POST['pg_total_amount']; $pg_utc_time=$_POST['pg_utc_time']; $pg_transaction_order_number=$_POST['pg_transaction_order_number']; $pg_client_id=$_POST['pg_client_id']; $pg_client_command=$_POST['pg_client_command']; $pg_payment_method_id=$_POST['pg_payment_method_id']; $pg_payment_command=$_POST['pg_payment_command']; $pg_billto_postal_name_first=$_POST['pg_billto_postal_name_first']; $pg_billto_postal_name_last=$_POST['pg_billto_postal_name_last']; $pg_billto_company_name=$_POST['pg_billto_company_name']; $pg_billto_postal_street_line1=$_POST['pg_billto_postal_street_line1']; $pg_billto_postal_street_line2=$_POST['pg_billto_postal_street_line2']; $pg_billto_postal_city=$_POST['pg_billto_postal_city']; $pg_billto_postal_stateprov=$_POST['pg_billto_postal_stateprov']; $pg_billto_postal_postalcode=$_POST['pg_billto_postal_postalcode']; $pg_billto_postal_countrycode=$_POST['pg_billto_postal_countrycode']; $pg_billto_online_email=$_POST['pg_billto_online_email']; $pg_billto_telecom_phone_number=$_POST['pg_billto_telecom_phone_number']; $pg_shipto_postal_name=$_POST['pg_shipto_postal_name']; $pg_shipto_postal_street_line1=$_POST['pg_shipto_postal_street_line1']; $pg_shipto_postal_street_line2=$_POST['pg_shipto_postal_street_line2']; $pg_shipto_postal_city=$_POST['pg_shipto_postal_city']; $pg_shipto_postal_stateprov=$_POST['pg_shipto_postal_stateprov']; $pg_shipto_postal_postalcode=$_POST['pg_shipto_postal_postalcode']; $pg_consumer_id=$_POST['pg_consumer_id']; $pg_consumerorderid=$_POST['pg_consumerorderid']; $pg_walletid=$_POST['pg_walletid']; $pg_merchant_data_1=$_POST['pg_merchant_data_1']; $pg_merchant_data_2=$_POST['pg_merchant_data_2']; $pg_merchant_data_3=$_POST['pg_merchant_data_3']; $pg_merchant_data_4=$_POST['pg_merchant_data_4']; $pg_merchant_data_5=$_POST['pg_merchant_data_5']; $pg_merchant_data_6=$_POST['pg_merchant_data_6']; $pg_merchant_data_7=$_POST['pg_merchant_data_7']; $pg_merchant_data_8=$_POST['pg_merchant_data_8']; $pg_merchant_data_9=$_POST['pg_merchant_data_9']; $pg_line_item_header=$_POST['pg_line_item_header']; $pg_line_item_1=$_POST['pg_line_item_1']; $pg_line_item_2=$_POST['pg_line_item_2']; $pg_line_item_3=$_POST['pg_line_item_3']; $pg_line_item_4=$_POST['pg_line_item_4']; $pg_line_item_5=$_POST['pg_line_item_5']; $pg_line_item_6=$_POST['pg_line_item_6']; $pg_line_item_7=$_POST['pg_line_item_7']; $pg_line_item_8=$_POST['pg_line_item_8']; $pg_line_item_9=$_POST['pg_line_item_9']; $pg_line_item_10=$_POST['pg_line_item_10']; $pg_user_defined_1=$_POST['pg_user_defined_1']; $pg_user_defined_2=$_POST['pg_user_defined_2']; $pg_user_defined_3=$_POST['pg_user_defined_3']; $pg_user_defined_4=$_POST['pg_user_defined_4']; $pg_user_defined_5=$_POST['pg_user_defined_5']; $pg_user_defined_6=$_POST['pg_user_defined_6']; $pg_user_defined_7=$_POST['pg_user_defined_7']; $pg_user_defined_8=$_POST['pg_user_defined_8']; $pg_user_defined_9=$_POST['pg_user_defined_9']; $pg_user_defined_10=$_POST['pg_user_defined_10']; $pg_sales_tax_amount=$_POST['pg_sales_tax_amount']; $pg_convenience_fee=$_POST['pg_convenience_fee']; $pg_avs_method=$_POST['pg_avs_method']; $pg_schedule_transaction=$_POST['pg_schedule_transaction']; $pg_schedule_quantity=$_POST['pg_schedule_quantity']; $pg_schedule_frequency=$_POST['pg_schedule_frequency']; $pg_schedule_start_date=$_POST['pg_schedule_start_date']; $pg_return_method=$_POST['pg_return_method']; $pg_client_status=$_POST['pg_client_status']; $pg_note=$_POST['pg_note']; $pg_is_default=$_POST['pg_is_default']; $pg_payment_check_trn=$_POST['pg_payment_check_trn']; $pg_payment_check_account=$_POST['pg_payment_check_account']; $pg_payment_check_checkno=$_POST['pg_payment_check_checkno']; $pg_payment_check_account_type=$_POST['pg_payment_check_account_type']; $pg_payment_card_type=$_POST['pg_payment_card_type']; $pg_payment_card_name=$_POST['pg_payment_card_name']; $pg_payment_card_number=$_POST['pg_payment_card_number']; $pg_payment_card_expdate_month=$_POST['pg_payment_card_expdate_month']; $pg_payment_card_expdate_year=$_POST['pg_payment_card_expdate_year']; $pg_customer_acct_code=$_POST['pg_customer_acct_code']; $pg_procurement_card=$_POST['pg_procurement_card']; $pg_payment_card_verification=$_POST['pg_payment_card_verification']; $pg_swipe_data=$_POST['pg_swipe_data']; $pg_onetime_token=$_POST['pg_onetime_token']; $pg_return_url=$_POST['pg_return_url']; $environment_url=$_POST['environment_url']; $message_to_hash=$pg_api_login_id.'|'.$pg_transaction_type.'|'.$pg_version_number.'|'.$pg_total_amount.'|'.$pg_utc_time.'|'.$pg_transaction_order_number.'|'.$pg_client_id.'|'.$pg_client_command.'|'.$pg_payment_method_id.'|'.$pg_payment_command; echo "Message To Hash: <b>".$message_to_hash."</b><i> Note: This form uses the SWP-Redirect standard hash format for signing</i>"; $pg_ts_hash=calculate_HMACMD5_hash($message_to_hash, $key); $submit_button_label="Add transaction"; } else { $action_url="SWPRedirect.php"; $pg_api_login_id='xxxxxxxxxx'; $key='yyyyyyyyyy'; $pg_transaction_type='10'; $pg_version_number='2.0'; $pg_total_amount='20.00'; $pg_utc_time=get_UTC_Time(); $pg_transaction_order_number=rand(); $pg_client_id=''; $pg_client_command=''; $pg_payment_method_id=''; $pg_payment_command=''; $pg_billto_postal_name_first='John'; $pg_billto_postal_name_last='Smith'; $pg_billto_company_name=''; $pg_billto_postal_street_line1=''; $pg_billto_postal_street_line2=''; $pg_billto_postal_city=''; $pg_billto_postal_stateprov=''; $pg_billto_postal_postalcode=''; $pg_billto_postal_countrycode=''; $pg_billto_online_email=''; $pg_billto_telecom_phone_number=''; $pg_shipto_postal_name=''; $pg_shipto_postal_street_line1=''; $pg_shipto_postal_street_line2=''; $pg_shipto_postal_city=''; $pg_shipto_postal_stateprov=''; $pg_shipto_postal_postalcode=''; $pg_consumer_id=''; $pg_consumerorderid=$pg_transaction_order_number; $pg_walletid=''; $pg_merchant_data_1=''; $pg_merchant_data_2=''; $pg_merchant_data_3=''; $pg_merchant_data_4=''; $pg_merchant_data_5=''; $pg_merchant_data_6=''; $pg_merchant_data_7=''; $pg_merchant_data_8=''; $pg_merchant_data_9=''; $pg_line_item_header=''; $pg_line_item_1=''; $pg_line_item_2=''; $pg_line_item_3=''; $pg_line_item_4=''; $pg_line_item_5=''; $pg_line_item_6=''; $pg_line_item_7=''; $pg_line_item_8=''; $pg_line_item_9=''; $pg_line_item_10=''; $pg_user_defined_1=''; $pg_user_defined_2=''; $pg_user_defined_3=''; $pg_user_defined_4=''; $pg_user_defined_5=''; $pg_user_defined_6=''; $pg_user_defined_7=''; $pg_user_defined_8=''; $pg_user_defined_9=''; $pg_user_defined_10=''; $pg_sales_tax_amount=''; $pg_convenience_fee=''; $pg_avs_method='00000'; $pg_schedule_transaction='0'; $pg_schedule_quantity='0'; $pg_schedule_frequency='20'; $pg_schedule_start_date='12012088'; $pg_return_method='Post'; $pg_client_status=''; $pg_note=''; $pg_is_default=''; $pg_payment_check_trn=''; $pg_payment_check_account=''; $pg_payment_check_checkno=''; $pg_payment_check_account_type=''; $pg_payment_card_type='VISA'; $pg_payment_card_name='John Smith'; $pg_payment_card_number='4111111111111111'; $pg_payment_card_expdate_month='04'; $pg_payment_card_expdate_year='2099'; $pg_customer_acct_code=''; $pg_procurement_card='false'; $pg_payment_card_verification='123'; $pg_swipe_data=''; $pg_onetime_token=''; $pg_return_url='https://swp.paymentsgateway.net/Redirect/results.aspx'; $environment_url='https://sandbox.paymentsgateway.net/SWP/Redirect/default.aspx'; $message_to_hash=$pg_api_login_id.'|'.$pg_transaction_type.'|'.$pg_version_number.'|'.$pg_total_amount.'|'.$pg_utc_time.'|'.$pg_transaction_order_number.'|'.$pg_client_id.'|'.$pg_client_command.'|'.$pg_payment_method_id.'|'.$pg_payment_command; echo "Message To Hash: <b>".$message_to_hash."</b><i> Note: This form uses the SWP-Redirect standard hash format for signing</i>"; $pg_ts_hash=calculate_HMACMD5_hash($message_to_hash, $key); $submit_button_label="Continue"; } ?> <head><title>SWP-Redirect</title></head> <body> <form id="form1" method="post" action="<?php echo $action_url; ?>"> <table><tr> <td>API Login ID: <input name="pg_api_login_id" value='<?php echo $pg_api_login_id; ?>'></td> <td>Transaction Type: <input name="pg_transaction_type" value='<?php echo $pg_transaction_type; ?>'></td> <td>Version Number: <input name="pg_version_number" value='<?php echo $pg_version_number; ?>'></td> <td>Total Amount: <input name="pg_total_amount" value='<?php echo $pg_total_amount; ?>'></td> </tr> <tr> <td>UTC Time: <input name="pg_utc_time" value='<?php echo $pg_utc_time; ?>'></td> <td>Transaction Order Number: <input name="pg_transaction_order_number" value='<?php echo $pg_transaction_order_number; ?>'></td> <td>Client Command: <input name="pg_client_command" value='<?php echo $pg_client_command; ?>'></td> <td>Payment Method ID: <input name="pg_payment_method_id" value='<?php echo $pg_payment_method_id; ?>'></td> </tr> <tr> <td>Payment Command: <input name="pg_payment_command" value='<?php echo $pg_payment_command; ?>'></td> <td>First Name: <input name="pg_billto_postal_name_first" value="<?php echo $pg_billto_postal_name_first; ?>"/></td> <td>Last Name: <input name="pg_billto_postal_name_last" value="<?php echo $pg_billto_postal_name_last; ?>"/></td> <td>Company Name: <input name="pg_billto_company_name" value="<?php echo $pg_billto_company_name; ?>"/></td> </tr> <tr> <td>Street 1: <input name="pg_billto_postal_street_line1" value="<?php echo $pg_billto_postal_street_line1; ?>"/></td> <td>Street 2: <input name="pg_billto_postal_street_line2" value="<?php echo $pg_billto_postal_street_line2; ?>"/></td> <td>City: <input name="pg_billto_postal_city" value="<?php echo $pg_billto_postal_city; ?>"/></td> <td>State: <input name="pg_billto_postal_stateprov" value="<?php echo $pg_billto_postal_stateprov; ?>"/></td> </tr> <tr> <td>Postal Code: <input name="pg_billto_postal_postalcode" value="<?php echo $pg_billto_postal_postalcode; ?>"/></td> <td>Country Code: <input name="pg_billto_postal_countrycode" value="<?php echo $pg_billto_postal_countrycode; ?>"/></td> <td>Email: <input name="pg_billto_online_email" value="<?php echo $pg_billto_online_email; ?>"/></td> <td>Phone: <input name="pg_billto_telecom_phone_number" value="<?php echo $pg_billto_telecom_phone_number; ?>"/></td> </tr> <tr> <td>Shipto Name: <input name="pg_shipto_postal_name" value="<?php echo $pg_shipto_postal_name; ?>"/></td> <td>Shipto Street 1: <input name="pg_shipto_postal_street_line1" value="<?php echo $pg_shipto_postal_street_line1; ?>"/></td> <td>Shipto Street 2: <input name="pg_shipto_postal_street_line2" value="<?php echo $pg_shipto_postal_street_line2; ?>"/></td> <td>Shipto City: <input name="pg_shipto_postal_city" value="<?php echo $pg_shipto_postal_city; ?>"/></td> </tr> <tr> <td>Shipto State: <input name="pg_shipto_postal_stateprov" value="<?php echo $pg_shipto_postal_stateprov; ?>"/></td> <td>Shipto Postal Code: <input name="pg_shipto_postal_postalcode" value="<?php echo $pg_shipto_postal_postalcode; ?>"/></td> <td>Consumer ID: <input name="pg_consumer_id" value="<?php echo $pg_consumer_id; ?>"/></td> <td>Client Status: <input name="pg_client_status" value="<?php echo $pg_client_status; ?>"/></td> </tr> <tr> <td>Invoice/Order Number: <input name="pg_consumerorderid" value="<?php echo $pg_consumerorderid; ?>"/></td> <td>Wallet ID: <input name="pg_walletid" value="<?php echo $pg_walletid; ?>"/></td> <td>Merchant Data 1: <input name="pg_merchant_data_1" value="<?php echo $pg_merchant_data_1; ?>"/></td> <td>Merchant Data 2: <input name="pg_merchant_data_2" value="<?php echo $pg_merchant_data_2; ?>"/></td> </tr> <tr> <td>Merchant Data 3: <input name="pg_merchant_data_3" value="<?php echo $pg_merchant_data_3; ?>"/></td> <td>Merchant Data 4: <input name="pg_merchant_data_4" value="<?php echo $pg_merchant_data_4; ?>"/></td> <td>Merchant Data 5: <input name="pg_merchant_data_5" value="<?php echo $pg_merchant_data_5; ?>"/></td> <td>Merchant Data 6: <input name="pg_merchant_data_6" value="<?php echo $pg_merchant_data_6; ?>"/></td> </tr> <tr> <td>Merchant Data 7: <input name="pg_merchant_data_7" value="<?php echo $pg_merchant_data_7; ?>"/></td> <td>Merchant Data 8: <input name="pg_merchant_data_8" value="<?php echo $pg_merchant_data_8; ?>"/></td> <td>Merchant Data 9: <input name="pg_merchant_data_9" value="<?php echo $pg_merchant_data_9; ?>"/></td> <td>Line Item Header: <input name="pg_line_item_header" value="<?php echo $pg_line_item_header; ?>"/></td> </tr> <tr> <td>Line Item 1: <input name="pg_line_item_1" value="<?php echo $pg_line_item_1; ?>"/></td> <td>Line Item 2: <input name="pg_line_item_2" value="<?php echo $pg_line_item_2; ?>"/></td> <td>Line Item 3: <input name="pg_line_item_3" value="<?php echo $pg_line_item_3; ?>"/></td> <td>Line Item 4: <input name="pg_line_item_4" value="<?php echo $pg_line_item_4; ?>"/></td> </tr> <tr> <td>Line Item 5: <input name="pg_line_item_5" value="<?php echo $pg_line_item_5; ?>"/></td> <td>Line Item 6: <input name="pg_line_item_6" value="<?php echo $pg_line_item_6; ?>"/></td> <td>Line Item 7: <input name="pg_line_item_7" value="<?php echo $pg_line_item_7; ?>"/></td> <td>Line Item 8: <input name="pg_line_item_8" value="<?php echo $pg_line_item_8; ?>"/></td> </tr> <tr> <td>Line Item 9: <input name="pg_line_item_9" value="<?php echo $pg_line_item_9; ?>"/></td> <td>Line Item 10: <input name="pg_line_item_10" value="<?php echo $pg_line_item_10; ?>"/></td> <td>User Defined 1: <input name="pg_user_defined_1" value="<?php echo $pg_user_defined_1; ?>"/></td> <td>User Defined 2: <input name="pg_user_defined_2" value="<?php echo $pg_user_defined_2; ?>"/></td> </tr> <tr> <td>User Defined 3: <input name="pg_user_defined_3" value="<?php echo $pg_user_defined_3; ?>"/></td> <td>User Defined 4: <input name="pg_user_defined_4" value="<?php echo $pg_user_defined_4; ?>"/></td> <td>User Defined 5: <input name="pg_user_defined_5" value="<?php echo $pg_user_defined_5; ?>"/></td> <td>User Defined 6: <input name="pg_user_defined_6" value="<?php echo $pg_user_defined_6; ?>"/></td> </tr> <tr> <td>User Defined 7: <input name="pg_user_defined_7" value="<?php echo $pg_user_defined_7; ?>"/></td> <td>User Defined 8: <input name="pg_user_defined_8" value="<?php echo $pg_user_defined_8; ?>"/></td> <td>User Defined 9: <input name="pg_user_defined_9" value="<?php echo $pg_user_defined_9; ?>"/></td> <td>User Defined 10: <input name="pg_user_defined_10" value="<?php echo $pg_user_defined_10; ?>"/></td> </tr> <tr> <td>Sales Tax Amount: <input name="pg_sales_tax_amount" value="<?php echo $pg_sales_tax_amount; ?>"/></td> <td>Service ("convenience") Fee: <input name="pg_convenience_fee" value="<?php echo $pg_convenience_fee; ?>"/></td> <td>AVS Method: <input name="pg_avs_method" value="<?php echo $pg_avs_method; ?>"/></td> <td>Scheduled Transaction (0=no, 1=yes): <input name="pg_schedule_transaction" value="<?php echo $pg_schedule_transaction; ?>"/></td> </tr> <tr> <td>Schedule Quantity: <input name="pg_schedule_quantity" value="<?php echo $pg_schedule_quantity; ?>"/></td> <td>Schedule Frequency: <input name="pg_schedule_frequency" value="<?php echo $pg_schedule_frequency; ?>"/></td> <td>Schedule Start Date: <input name="pg_schedule_start_date" value="<?php echo $pg_schedule_start_date; ?>"/></td> <td>CC Type: <input name="pg_payment_card_type" value="<?php echo $pg_payment_card_type; ?>"/></td> </tr> <tr> <td>CC Name: <input name="pg_payment_card_name" value="<?php echo $pg_payment_card_name; ?>"/></td> <td>CC Expiration Year (yyyy): <input name="pg_payment_card_expdate_year" value="<?php echo $pg_payment_card_expdate_year; ?>"/></td> <td>CC Expiration Month (mm): <input name="pg_payment_card_expdate_month" value="<?php echo $pg_payment_card_expdate_month; ?>"/></td> <td>CC Number: <input name="pg_payment_card_number" value="<?php echo $pg_payment_card_number; ?>"/></td> </tr> <tr> <td>CC Security Code: <input name="pg_payment_card_verification" value="<?php echo $pg_payment_card_verification; ?>"/></td> <td>CC Account Code: <input name="pg_customer_acct_code" value="<?php echo $pg_customer_acct_code; ?>"/></td> <td>CC Procurement Card (true/false): <input name="pg_procurement_card" value="<?php echo $pg_procurement_card; ?>"/></td> <td>CC Swipe Data: <input name="pg_swipe_data" value="<?php echo $pg_swipe_data; ?>"/></td> </tr> <tr> <td>EFT TRN: <input name="pg_payment_check_trn" value="<?php echo $pg_payment_check_trn; ?>"/></td> <td>EFT Account Number: <input name="pg_payment_check_account" value="<?php echo $pg_payment_check_account; ?>"/></td> <td>EFT Check Number: <input name="pg_payment_check_checkno" value="<?php echo $pg_payment_check_checkno; ?>"/></td> <td>EFT Account Type: <input name="pg_payment_check_account_type" value="<?php echo $pg_payment_check_account_type; ?>"/></td> </tr> <tr> <td>Note: <input name="pg_note" value="<?php echo $pg_note; ?>"/></td> <td>Is Default? (0=false, 1=true): <input name="pg_is_default" value="<?php echo $pg_is_default; ?>"/></td> <td>One-time token: <input name="pg_onetime_token" value="<?php echo $pg_onetime_token; ?>"/></td> <td>Return (postback) URL: <input name="pg_return_url" value="<?php echo $pg_return_url; ?>"/></td> <td>Return Method: <input name="pg_return_method" value="<?php echo $pg_return_method; ?>"/></td> </tr> <tr> <td>Signature: <input name="pg_ts_hash" value='<?php echo $pg_ts_hash; ?>'></td> <td>Key: <input name="key" value='<?php echo $key; ?>'></td><br /><br /> </tr> <tr> <td><br /></td> </tr> <tr> <td><center>Environment URL: <input name="environment_url" value='<?php echo $environment_url; ?>'/></center></td> </tr> </table> <pre> <h2> Environment URLs</h2> <i>Live -</i> https://swp.paymentsgateway.net/Redirect/default.aspx <i>Sandbox -</i> https://sandbox.paymentsgateway.net/SWP/Redirect/default.aspx </pre> <center><input name="submit" type="submit" value="<?php echo $submit_button_label; ?>" /></center> </form> </body> </html>