Skip to content

Commit 238d175

Browse files
committed
Merge pull request #15 from lukerollans/master
Sanitize credit card number. Fixes #14
2 parents 35ce3e6 + 2be1846 commit 238d175

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

gravity-forms-braintree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin URI: http://plugify.io/
55
Description: Allow your customers to purchase goods and services through Gravity Forms via Braintree Payments
66
Author: Plugify
7-
Version: 1.1
7+
Version: 1.1.1
88
Author URI: http://plugify.io
99
*/
1010

lib/class.plugify-gform-braintree.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ protected function authorize( $feed, $submission_data, $form, $entry ) {
8181
// at least, not in this version
8282
if( $settings = $this->get_plugin_settings() ) {
8383

84+
// Sanitize card number, removing dashes and spaces
85+
$card_number = str_replace( array( '-', ' ' ), '', $submission_data['card_number'] );
86+
8487
// Prepare Braintree payload
8588
$args = array(
8689
'amount' => $submission_data['payment_amount'],
8790
'creditCard' => array(
88-
'number' => $submission_data['card_number'],
91+
'number' => $card_number,
8992
'expirationDate' => sprintf( '%s/%s', $submission_data['card_expiration_date'][0], $submission_data['card_expiration_date'][1]),
9093
'cardholderName' => $submission_data['card_name'],
9194
'cvv' => $submission_data['card_security_code']
@@ -104,7 +107,7 @@ protected function authorize( $feed, $submission_data, $form, $entry ) {
104107
if( $settings['settlement'] == 'Yes' ) {
105108
$args['options']['submitForSettlement'] = 'true';
106109
}
107-
110+
108111
// Send transaction to Braintree
109112
$result = Braintree_Transaction::sale( $args );
110113

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hello
44
Tags: credit card,braintree,gravity form,payment
55
Requires at least: 3.8
66
Tested up to: 3.9
7-
Stable tag: 1.1
7+
Stable tag: 1.1.1
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -61,6 +61,9 @@ No filters are currently available for this pre-release version
6161

6262
== Changelog ==
6363

64+
= 1.1.1 =
65+
* Dashes and spaces are now removed from credit card number before sending to Braintree
66+
6467
= 1.1 =
6568
* Fixed bug causing automatic settlement submission to fail
6669

0 commit comments

Comments
 (0)