Forked from DeveloperWil/Gravity Forms Get Credit Card Details
Created
February 22, 2022 16:35
-
-
Save goranseric/20b4296e0f6fae2f96652bd21b906be8 to your computer and use it in GitHub Desktop.
Enables the credit card fields for Gravity Forms and provides a function to get the credit card details which are not available through the filter $form or $entry
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
//Turn on our credit card field for admin and front end | |
add_action("gform_enable_credit_card_field", "enable_creditcard"); | |
function enable_creditcard($is_enabled){ | |
return true; | |
} | |
//Email encoded card details when the form is submitted. | |
add_action('gform_after_submission', 'email_encoded_cc', 10, 2); | |
function email_encoded_cc($entry, $form) { | |
function get_creditcard_field($form){ | |
$fields = GFCommon::get_fields_by_type($form, array("creditcard")); | |
return empty($fields) ? false : $fields[0]; | |
} | |
$card_field = get_creditcard_field($form); | |
$card_number = rgpost("input_{$card_field["id"]}_1"); | |
$expiration_date = rgpost("input_{$card_field["id"]}_2"); | |
$expire_month = $expiration_date[0]; | |
$expire_year = $expiration_date[1]; | |
$security_code = rgpost("input_{$card_field["id"]}_3"); | |
$card_name = rgpost("input_{$card_field["id"]}_5"); | |
$cc_detail_string = "CCName $card_name CCNum $card_number CCexp $expire_month-$expire_year CCV $security_code " ; | |
//remember base 64 is not encryption - just encoding! | |
$encoded_cc_detail_string = base64_encode($cc_detail_string); | |
//send encoded cc details via email | |
$to = "[email protected]"; /*your email here*/ | |
$subject = "For your eyes only"; | |
$body = $cc_detail_string; /*or encoded string*/ | |
$message = "Here are some cc details $body"; | |
$from = "[email protected]"; | |
$headers = "From:" . $from; | |
mail($to,$subject,$message,$headers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment