17 Commits

Author SHA1 Message Date
bea988bc4c Merge branch '7.x-3.x-dev' into add-metadata-endracing-7.x-3.1 2019-10-04 21:14:15 -05:00
01a5a1b15f Update from remote. 2019-10-04 21:05:43 -05:00
e17d91d6e3 Add missing call. 2019-10-04 15:12:00 -05:00
19038bc7a0 Remove debug code. 2019-10-04 15:10:19 -05:00
d95fa6e721 Follow UI checkboxes. 2019-10-04 15:08:27 -05:00
06a97cf9c9 Create a function to add metadata in both places it may be needed. 2019-10-04 15:03:30 -05:00
6a7858b6fa Get confused. 2019-10-03 23:48:51 -05:00
c5dc6d041b Try some things. 2019-10-03 23:30:17 -05:00
0b3a964634 Merge branch '7.x-3.1' into add-metadata-endracing-7.x-3.1 2019-10-03 22:13:12 -05:00
c0cb9f8f81 Ignore ptaches. 2019-10-03 21:39:35 -05:00
017b4b731c 7.x-3.x-dev 2019-10-03 21:18:09 -05:00
0675dcb249 Init from ENDracing production version. 2018-02-23 14:19:19 -06:00
90baa97458 Remove extra lines. 2017-05-19 16:12:14 -05:00
562e2a3698 Replace lost brackets. 2017-05-19 14:51:38 -05:00
ee03f3243d Clean up. 2017-05-19 11:31:59 -05:00
8493a9c1f7 Update branch from d.o. 2017-05-19 09:53:14 -05:00
c2a752501f Sync with Drupal.org. 2017-05-07 09:16:56 -05:00
4 changed files with 58 additions and 19 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.patch

View File

@ -6,10 +6,3 @@ dependencies[] = libraries
package = Ubercart - payment
core = 7.x
php = 5.3
; Information added by Drupal.org packaging script on 2019-08-08
version = "7.x-3.1"
core = "7.x"
project = "uc_stripe"
datestamp = "1565244191"

View File

@ -96,7 +96,7 @@ function uc_stripe_install() {
* Implements hook_uninstall().
*/
function uc_stripe_uninstall() {
variable_del('uc_stripe_authenticaiton_required_email');
variable_del('uc_stripe_authentication_required_email');
}
/**
@ -123,8 +123,8 @@ function uc_stripe_schema() {
),
'completed' => array(
'description' => 'Competion status of this pending order',
'type' => 'int',
'not null' => TRUE
'type' => 'int',
'not null' => TRUE
),
'hash' => array (
'description' => 'The unqiue has of order and payment id',
@ -234,8 +234,7 @@ function _uc_stripe_move_customer_id(&$sandbox) {
}
/**
*
* create table to track orders that require extra authentication verification.
* Creates table to track orders that require extra authentication verification.
*/
function uc_stripe_update_7301() {
@ -267,17 +266,27 @@ function uc_stripe_update_7301() {
'type' => 'varchar',
'length' => '100',
'not null' => TRUE
)
),
),
'unique keys' => array(
'hash' => array(
'hash'
)
),
'primary key' => array(
'id'
)
'primary key' => array('id'),
);
db_create_table('uc_stripe_pending_auth', $table);
}
/**
* Changes typo in variable uc_stripe_authenticaiton_required_email.
*/
function uc_stripe_update_7302() {
$typo_var_name = 'uc_stripe_authenticaiton_required_email';
$value = variable_get($typo_var_name, '');
if (!empty($value)) {
variable_set('uc_stripe_authentication_required_email', $value);
variable_del($typo_var_name);
}
}

View File

@ -416,10 +416,10 @@ function uc_stripe_settings_form() {
$email_text = _uc_stripe_get_authentication_required_email_text();
$form['uc_stripe_settings']['uc_stripe_authenticaiton_required_email'] = array(
$form['uc_stripe_settings']['uc_stripe_authentication_required_email'] = array(
'#type' => 'textarea',
'#title' => t('Email for Recurring payment authentication'),
'#default_value' => variable_get('uc_stripe_authenticaiton_required_email', $email_text),
'#default_value' => variable_get('uc_stripe_authentication_required_email', $email_text),
'#description' => t('If your site uses recurring payments, some transactions will require the customer to return to the site and authenticate before the subscrption payment can be processed.')
);
@ -436,6 +436,20 @@ function uc_stripe_settings_form() {
'#description' => 'Show "powered by Stripe" in checkout.',
'#default_value' => variable_get('uc_stripe_poweredby', FALSE),
);
$form['uc_stripe_settings']['uc_stripe_metadata_titles'] = array(
'#type' => 'checkbox',
'#title' => t('Metadata: Title'),
'#description' => t('Include order item title(s) in Stripe metadata.'),
'#default_value' => variable_get('uc_stripe_metadata_titles', FALSE),
);
$form['uc_stripe_settings']['uc_stripe_metadata_models'] = array(
'#type' => 'checkbox',
'#title' => t('Metadata: Model'),
'#description' => t('Include item model(s) (SKU(s)) in Stripe metadata.'),
'#default_value' => variable_get('uc_stripe_metadata_models', FALSE),
);
return $form;
}
@ -603,6 +617,7 @@ function uc_stripe_charge($order_id, $amount, $data) {
"currency" => strtolower($order->currency),
"customer" => $stripe_customer_id,
"description" => t("Order #@order_id", array("@order_id" => $order_id)),
"metadata" => make_metadata($order),
"payment_method" => $stripe_payment_method_id,
"payment_method_types" => ['card'],
"confirm" => true,
@ -753,7 +768,7 @@ function uc_stripe_renew($order, &$fee) {
))->execute();
// Prepare email to alert user that authentication is required.
$params['body'] = variable_get('uc_stripe_authenticaiton_required_email', _uc_stripe_get_authentication_required_email_text());
$params['body'] = variable_get('uc_stripe_authentication_required_email', _uc_stripe_get_authentication_required_email_text());
$params['user'] = user_load($order->uid);
$params['hash'] = $hash;
drupal_mail('uc_stripe', 'authentication_required', $params['user']->mail,language_default(), $params);
@ -1001,6 +1016,7 @@ function _uc_stripe_confirm_payment(){
$params = array(
'payment_method' => $data['payment_method_id'],
"description" => t("Order #@order_id", array("@order_id" => $order_id)),
"metadata" => make_metadata($order),
'amount' => $amount,
'currency' => strtolower($order->currency),
'confirmation_method' => 'manual',
@ -1077,6 +1093,7 @@ function _uc_stripe_create_stripe_customer($order, $payment_method_id = NULL){
$params = array(
'description' => "OrderID: {$order->order_id}",
"metadata" => make_metadata($order),
'email' => "$order->primary_email"
);
@ -1103,6 +1120,25 @@ function _uc_stripe_create_stripe_customer($order, $payment_method_id = NULL){
}
function make_metadata($order){
//Get item titles and models
foreach($order->products as $item){
$titles[] = $item->title;
$models[] = $item->model;
}
$metadata = array();
if (!empty($models) and variable_get('uc_stripe_metadata_models', FALSE)) {
$metadata['models'] = implode(";", $models);
}
if (!empty($titles) and variable_get('uc_stripe_metadata_titles', FALSE)) {
$metadata['titles'] = implode(";", $titles);
}
return $metadata;
}
/**
*
* @param string $stripe_id