Skip to content

Commit

Permalink
Merge pull request #15 from lukerollans/master
Browse files Browse the repository at this point in the history
Sanitize credit card number. Fixes #14
  • Loading branch information
lukerollans committed Jun 25, 2014
2 parents 35ce3e6 + 2be1846 commit 238d175
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gravity-forms-braintree.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://plugify.io/
Description: Allow your customers to purchase goods and services through Gravity Forms via Braintree Payments
Author: Plugify
Version: 1.1
Version: 1.1.1
Author URI: http://plugify.io
*/

Expand Down
7 changes: 5 additions & 2 deletions lib/class.plugify-gform-braintree.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ protected function authorize( $feed, $submission_data, $form, $entry ) {
// at least, not in this version
if( $settings = $this->get_plugin_settings() ) {

// Sanitize card number, removing dashes and spaces
$card_number = str_replace( array( '-', ' ' ), '', $submission_data['card_number'] );

// Prepare Braintree payload
$args = array(
'amount' => $submission_data['payment_amount'],
'creditCard' => array(
'number' => $submission_data['card_number'],
'number' => $card_number,
'expirationDate' => sprintf( '%s/%s', $submission_data['card_expiration_date'][0], $submission_data['card_expiration_date'][1]),
'cardholderName' => $submission_data['card_name'],
'cvv' => $submission_data['card_security_code']
Expand All @@ -104,7 +107,7 @@ protected function authorize( $feed, $submission_data, $form, $entry ) {
if( $settings['settlement'] == 'Yes' ) {
$args['options']['submitForSettlement'] = 'true';
}

// Send transaction to Braintree
$result = Braintree_Transaction::sale( $args );

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hello
Tags: credit card,braintree,gravity form,payment
Requires at least: 3.8
Tested up to: 3.9
Stable tag: 1.1
Stable tag: 1.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 1.1.1 =
* Dashes and spaces are now removed from credit card number before sending to Braintree

= 1.1 =
* Fixed bug causing automatic settlement submission to fail

Expand Down

0 comments on commit 238d175

Please sign in to comment.