Permalink
Browse files

Added create_token method and supported it in stripe driver. Small ch…

…ange to config values for tests
  • Loading branch information...
1 parent b7016b5 commit f0dee9e727a890ba7994fe5e3e7c31b9c35498ff @calvinfroedge committed Jun 22, 2012
View
5 language/english/response_messages_lang.php
@@ -24,7 +24,7 @@
'oneoff_payment_button_local_failure' => 'There was a problem generating the payment button',
'oneoff_payment_button_gateway_failure' => 'The payment button could not be generated',
'reference_payment_success' => 'The payment was successful.',
- 'reference_payment_local_failure' => 'The payment could not be sent to the payment gateway because it failed local validation.',
+ 'reference_payment_local_failure' => 'The payment could not be sent to the payment gateway because it failed local validation.',
'reference_payment_gateway_failure' => 'The payment was declined by the payment gateway.',
'capture_payment_success' => 'The payment capture was successful.',
'capture_payment_local_failure' => 'The payment capture could not be sent to the payment gateway because it failed local validation.',
@@ -67,6 +67,9 @@
'update_recurring_profile_success' => 'Recurring profile updated successfully.',
'update_recurring_profile_local_failure' => 'Recurring profile update request could not be sent to the payment gateway because local validation failed.',
'update_recurring_profile_gateway_failure' => 'Recurring profile update was rejected by the payment gateway.',
+ 'token_create_success' => 'Card tokenization successful.',
+ 'token_create_local_failure' => 'Card tokenization could not be attempted because validation failed locally.',
+ 'token_create_gateway_failure' => 'Card tokenization failed at the payment gateway.'
);
return $lang;
View
22 lib/payment_drivers/stripe_driver.php
@@ -133,6 +133,28 @@ public function method_map()
'amt' => 'amount'
)
),
+ 'token_create' => array(
+ 'api' => 'Stripe_Token',
+ 'method' => 'create',
+ 'required' => array(
+ 'cc_number',
+ 'cc_exp'
+ ),
+ 'keymatch' => array(
+ 'identifier' => 'customer',
+ 'cc_number' => 'card["number"]',
+ 'cc_exp' => 'card["exp_month,exp_year"]',
+ 'cc_code' => 'card["cvc"]',
+ 'first_name' => 'card["name"]',
+ 'last_name' => 'card["name"]',
+ 'street' => 'card["address_line1"]',
+ 'street2' => 'card["address_line2"]',
+ 'postal_code' => 'card["address_zip"]',
+ 'state' => 'card["address_state"]',
+ 'country' => 'card["address_country"]',
+ 'desc' => 'description'
+ )
+ )
);
return $map;
}
View
44 lib/payment_methods/token_create_method.php
@@ -0,0 +1,44 @@
+<?php
+
+class Token_Create_Method implements Payment_Method
+{
+ private $_params;
+
+ private $_descrip = "Stores card data on payment server and gives you a secure identifier for the card which can be used to create payments later.";
+
+ public function __construct()
+ {
+ $this->_params = array(
+ 'cc_type' => 'Visa', //Visa, MasterCard, Discover, Amex
+ 'cc_number' => '4111111111111111', //Credit card number
+ 'cc_exp' => '022013', //Must be formatted MMYYYY
+ 'cc_code' => '413', //3 or 4 digit cvv code
+ 'email' => 'calvinsemail@gmail.com', //email associated with account being billed
+ 'first_name' => 'Calvin', //first name of the purchaser
+ 'last_name' => 'Froedge', //last name of the purchaser
+ 'business_name' => 'The Business Name', //name of business
+ 'street' => '251 Somewhere Street', //street address of the purchaser
+ 'street2' => 'Apt B', //street address 2 of purchaser
+ 'city' => 'Somewherton', //city of the purchaser
+ 'state' => 'KY', //state of the purchaser
+ 'country' => 'US', // country of the purchaser
+ 'postal_code' => '42105', //zip code of the purchaser
+ 'amt' => '25.00', //purchase amount
+ 'phone' => '(801) 754 4466', //phone num of customer shipped to
+ 'fax' => '(801) 754 4466',
+ 'desc' => 'The transaction description', //Description for the transaction
+ 'custom' => 'Anything you want to put here', //Free form text field
+ 'po_num' => 'YOUR-PO-NUMBER',
+ );
+ }
+
+ public function get_params()
+ {
+ return $this->_params;
+ }
+
+ public function get_description()
+ {
+ return $this->_descrip();
+ }
+}
View
3 tests/tests/drivers/.drivers.test_vals.php
@@ -37,6 +37,9 @@
),
'eway_driver' => array(
'cc_number' => 4444333322221111
+ ),
+ 'beanstream_driver' => array(
+ 'cc_number' => 4030000010001234
)
);

0 comments on commit f0dee9e

Please sign in to comment.