Changeset 1391844
- Timestamp:
- 04/11/2016 08:19:00 AM (10 years ago)
- Location:
- rainbowpaypress/trunk
- Files:
-
- 11 added
- 1 deleted
- 38 edited
-
LICENSE (modified) (1 diff)
-
RainbowPayPress.php (modified) (25 diffs)
-
RainbowPayPress_util.php (modified) (14 diffs)
-
assets (deleted)
-
js/le_requirejs/admin/collection_orig__item.js (added)
-
js/le_requirejs/admin/collection_orig__transaction.js (modified) (4 diffs)
-
js/le_requirejs/admin/main_admin.js (modified) (4 diffs)
-
js/le_requirejs/admin/model_info__item_details.js (added)
-
js/le_requirejs/admin/model_orig__config.js (modified) (2 diffs)
-
js/le_requirejs/admin/model_orig__item.js (added)
-
js/le_requirejs/admin/model_orig__transaction.js (modified) (3 diffs)
-
js/le_requirejs/admin/view_agg__button.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__button__add_new_item.js (added)
-
js/le_requirejs/admin/view_agg__button__send_test_email.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__div__add_new_item.js (added)
-
js/le_requirejs/admin/view_agg__span__date.js (modified) (3 diffs)
-
js/le_requirejs/admin/view_agg__table__config.js (modified) (2 diffs)
-
js/le_requirejs/admin/view_agg__table__item_details.js (added)
-
js/le_requirejs/admin/view_agg__table__items.js (added)
-
js/le_requirejs/admin/view_agg__table__transactions.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__td__detail.js (added)
-
js/le_requirejs/admin/view_agg__tr__config__notes.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__tr__config__option.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__tr__config__option__boolean.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__tr__config__option__string.js (modified) (2 diffs)
-
js/le_requirejs/admin/view_agg__tr__config__option__string__email_notifications.js (modified) (1 diff)
-
js/le_requirejs/admin/view_agg__tr__item.js (added)
-
js/le_requirejs/admin/view_agg__tr__transaction.js (modified) (3 diffs)
-
js/le_requirejs/admin/view_agg__tr__w_header.js (modified) (2 diffs)
-
js/le_requirejs/backbone-private.js (modified) (1 diff)
-
js/le_requirejs/common.js (modified) (1 diff)
-
js/le_requirejs/jquery-private.js (modified) (1 diff)
-
js/le_requirejs/main.js (modified) (1 diff)
-
js/le_requirejs/model_info__details_base.js (added)
-
js/le_requirejs/model_orig__app_common.js (modified) (1 diff)
-
js/le_requirejs/public/main_public.js (modified) (3 diffs)
-
js/le_requirejs/public/model_info__stripe_checkout.js (modified) (1 diff)
-
js/le_requirejs/public/model_info__transaction_details.js (modified) (5 diffs)
-
js/le_requirejs/public/model_orig__app_public.js (modified) (1 diff)
-
js/le_requirejs/public/model_orig__fields.js (modified) (1 diff)
-
js/le_requirejs/public/view_agg__div__transaction.js (modified) (6 diffs)
-
js/le_requirejs/public/view_agg__table__transaction_details.js (modified) (9 diffs)
-
js/le_requirejs/public/view_agg__tr__transaction_detail.js (modified) (3 diffs)
-
js/le_requirejs/public/view_agg__tr__transaction_detail__stripe.js (modified) (2 diffs)
-
js/le_requirejs/underscore-private.js (modified) (1 diff)
-
js/le_requirejs/util.js (modified) (2 diffs)
-
js/le_requirejs/view_agg__table.js (modified) (2 diffs)
-
js/le_requirejs/view_agg__tr__detail_base.js (added)
-
readme.txt (modified) (4 diffs)
-
style.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rainbowpaypress/trunk/LICENSE
r1385818 r1391844 4 4 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 5 5 6 Version: 2.4.0-development_unreleased6 Version: 3.1.0-development_unreleased 7 7 8 8 Module: rainbowpaypress/LICENSE -
rainbowpaypress/trunk/RainbowPayPress.php
r1385818 r1391844 6 6 Author URI: http://www.maratbn.com 7 7 License: GPL3 8 Version: 2.4.0-development_unreleased8 Version: 3.1.0-development_unreleased 9 9 Text Domain: domain-plugin-RainbowPayPress 10 10 */ … … 16 16 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 17 17 18 Version: 2.4.0-development_unreleased18 Version: 3.1.0-development_unreleased 19 19 20 20 Module: rainbowpaypress/RainbowPayPress.php … … 42 42 namespace plugin_RainbowPayPress; 43 43 44 const PLUGIN_VERSION = ' 2.4.0-development_unreleased';44 const PLUGIN_VERSION = '3.1.0-development_unreleased'; 45 45 46 46 … … 52 52 const DOMAIN_PLUGIN_RAINBOW_PAY_PRESS = 'domain-plugin-RainbowPayPress'; 53 53 54 const SETTING__EMAIL_NOTIFICATIONS = 'plugin_RainbowPayPress__setting__email_notifications'; 54 const SETTING__ENTITY_NAME = 'plugin_RainbowPayPress__setting__entity_name'; 55 const SETTING__EMAIL_NOTIFICATIONS = 'plugin_RainbowPayPress__setting__email_notifications'; 55 56 const SETTING__FLAG_ENABLE_EMAIL_NOTIFICATIONS 56 57 = 'plugin_RainbowPayPress__setting__flag__enable_email_notifications'; 57 58 const SETTING__STRIPE_LIVE_PUBLISH_KEY 58 59 = 'plugin_RainbowPayPress__setting__stripe_live_publish_key'; 59 const SETTING__STRIPE_LIVE_SECRET_KEY = 'plugin_RainbowPayPress__setting__stripe_live_secret_key'; 60 const SETTING__STRIPE_LIVE_SECRET_KEY 61 = 'plugin_RainbowPayPress__setting__stripe_live_secret_key'; 60 62 const SETTING__STRIPE_TEST_PUBLISH_KEY 61 63 = 'plugin_RainbowPayPress__setting__stripe_test_publish_key'; 62 const SETTING__STRIPE_TEST_SECRET_KEY = 'plugin_RainbowPayPress__setting__stripe_test_secret_key'; 64 const SETTING__STRIPE_TEST_SECRET_KEY 65 = 'plugin_RainbowPayPress__setting__stripe_test_secret_key'; 63 66 64 67 const SHORTCODE__RAINBOW_PAY_PRESS = 'rainbow-pay-press'; 65 68 66 69 const SLUG_INFO_ROOT = 'plugin_RainbowPayPress_root'; 70 const SLUG_ITEMS = 'plugin_RainbowPayPress_items'; 67 71 const SLUG_SETTINGS = 'plugin_RainbowPayPress_settings'; 68 72 const SLUG_TRANSACTIONS = 'plugin_RainbowPayPress_transactions'; … … 98 102 '\\plugin_RainbowPayPress\\action_admin_print_footer_scripts'); 99 103 \add_action( 104 'wp_ajax_rainbow_pay_press__admin__add_item', 105 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__add_item'); 106 \add_action( 100 107 'wp_ajax_rainbow_pay_press__admin__charge', 101 108 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__charge'); 102 109 \add_action( 103 'wp_ajax_rainbow_pay_press__admin__delete', 104 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__delete'); 110 'wp_ajax_rainbow_pay_press__admin__delete_item', 111 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__delete_item'); 112 \add_action( 113 'wp_ajax_rainbow_pay_press__admin__delete_transaction', 114 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__delete_transaction'); 105 115 \add_action( 106 116 'wp_ajax_rainbow_pay_press__admin__get_config', 107 117 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__get_config'); 108 118 \add_action( 119 'wp_ajax_rainbow_pay_press__admin__get_items', 120 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__get_items'); 121 \add_action( 109 122 'wp_ajax_rainbow_pay_press__admin__get_transactions', 110 123 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__get_transactions'); 111 124 \add_action( 125 'wp_ajax_rainbow_pay_press__admin__modify_item', 126 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__modify_item'); 127 \add_action( 112 128 'wp_ajax_rainbow_pay_press__admin__send_test_email', 113 129 '\\plugin_RainbowPayPress\\action_wp_ajax_rainbow_pay_press__admin__send_test_email'); … … 126 142 function action_admin_enqueue_scripts($hook) { 127 143 if (($hook != 'toplevel_page_' . SLUG_INFO_ROOT) && 144 ($hook != 'rainbowpaypress_page_' . SLUG_ITEMS) && 128 145 ($hook != 'rainbowpaypress_page_' . SLUG_TRANSACTIONS) && 129 146 ($hook != 'rainbowpaypress_page_' . SLUG_SETTINGS)) return; … … 162 179 \add_submenu_page( 163 180 SLUG_INFO_ROOT, 181 \__('RainbowPayPress Items', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 182 \__('Items', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 183 'manage_options', 184 SLUG_ITEMS, 185 '\\plugin_RainbowPayPress\\FragmentUtil::renderAdmin_Items'); 186 187 \add_submenu_page( 188 SLUG_INFO_ROOT, 164 189 \__('RainbowPayPress Transactions', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 165 190 \__('Transactions', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), … … 181 206 if (!$wp_screen || $wp_screen->parent_base != SLUG_INFO_ROOT) return; 182 207 183 if (Util::isCurlAvailable()) return; 184 185 $strWarning = \implode([ 186 \__('RainbowPayPress warning:', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 187 ' ', 208 $_renderWarning = function($strWarning) { 209 ?><div class='notice notice-warning is-dismissible'><?php 210 ?><p><?=\__('RainbowPayPress warning:', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS) 211 ?> <?=$strWarning?></p></div><?php 212 }; 213 214 if (!Util::isCurlAvailable()) { 215 $_renderWarning( 188 216 \sprintf( 189 217 \__('Your PHP environment is lacking cURL support, without which it cannot communicate with the Stripe servers. This will prevent you from charging your transactions with RainbowPayPress, for which you would need to enable PHP cURL support on your server. If your server is running Debian or Ubuntu, this can be done by installing the package \'%s\'.', 190 218 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 191 'php5-curl') 192 ]); 193 194 ?><div class='notice notice-warning is-dismissible'><p><?=$strWarning?></p></div><?php 219 'php5-curl')); 220 } 221 222 if (Util::getOption(SETTING__ENTITY_NAME) == null) { 223 $_renderWarning( 224 \sprintf( 225 \__('Your %s is not configured, and this will prevent the RainbowPayPress shortcodes from working. You can configure it on the %s.', 226 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 227 '<b>' . \__('site / company / organization name', 228 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS) . '</b>', 229 '<a href=\'' 230 . \admin_url('admin.php?page=' . SLUG_SETTINGS) 231 . '\'>' . \__('settings page', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS) . '</a>')); 232 } 195 233 } 196 234 … … 217 255 </script> 218 256 <?php 257 } 258 259 function action_wp_ajax_rainbow_pay_press__admin__add_item() { 260 /** Possible errors: 261 * error__insufficient_permissions 262 * error__duplicate_handle 263 * error__add_item 264 **/ 265 266 $arrErrors = []; 267 268 if (!\current_user_can('manage_options')) { 269 \array_push($arrErrors, 'error__insufficient_permissions'); 270 } 271 272 $objItemAdded = null; 273 274 if (\count($arrErrors) == 0) { 275 $arrDataDecoded = \json_decode(\urldecode($_POST['data']), true); 276 277 $strHandle = $arrDataDecoded['handle']; 278 $strDescription = $arrDataDecoded['description']; 279 $strCost = $arrDataDecoded['cost']; 280 281 if ($strHandle != null && DBUtil::tbl__items__selectSpecificForHandle($strHandle)) { 282 \array_push($arrErrors, 'error__duplicate_handle'); 283 } else { 284 $objItemAdded = DBUtil::tbl__items__add($strHandle, 285 $strDescription, 286 $strCost); 287 if (!$objItemAdded) { 288 \array_push($arrErrors, 'error__add_item'); 289 } 290 } 291 } 292 293 die(json_encode(['item' => Util::translateItem($objItemAdded), 294 'success' => (\count($arrErrors) == 0), 295 'errors' => $arrErrors])); 219 296 } 220 297 … … 243 320 $dataTransaction = null; 244 321 245 if ( count($arrErrors) == 0) {322 if (\count($arrErrors) == 0) { 246 323 $id = $_POST['id']; 247 $dataTransaction = DBUtil:: selectTransaction($id);324 $dataTransaction = DBUtil::tbl__transactions__selectSpecific($id); 248 325 if (!$dataTransaction) { 249 326 \array_push($arrErrors, 'error__select_transaction'); … … 253 330 $stripe = null; 254 331 255 if ( count($arrErrors) == 0) {332 if (\count($arrErrors) == 0) { 256 333 257 334 // Based on: https://stripe.com/docs/checkout/guides/php … … 281 358 $dataRet = []; 282 359 283 if ( count($arrErrors) == 0) {360 if (\count($arrErrors) == 0) { 284 361 \plugin_RainbowPayPress\Stripe\Stripe::setApiKey($stripe['secret_key']); 285 362 … … 306 383 } else { 307 384 $dataRet['stripe_charge_id'] = $charge->id; 308 $charged = DBUtil::updateTransactionAsCharged($id, $customer->id, $charge->id); 385 $charged = DBUtil::tbl__transactions__update__charged($id, 386 $customer->id, 387 $charge->id); 309 388 if ($charged == null) { 310 389 \array_push($arrErrors, 'error__update_transaction'); … … 324 403 } 325 404 326 $flagSuccess = ( count($arrErrors) == 0);405 $flagSuccess = (\count($arrErrors) == 0); 327 406 328 407 $dataRet['success'] = $flagSuccess; … … 332 411 } 333 412 334 function action_wp_ajax_rainbow_pay_press__admin__delete() { 413 function action_wp_ajax_rainbow_pay_press__admin__delete_item() { 414 /** Possible errors: 415 * error__insufficient_permissions 416 * error__delete_item 417 **/ 418 419 $arrErrors = []; 420 421 if (!\current_user_can('manage_options')) { 422 \array_push($arrErrors, 'error__insufficient_permissions'); 423 } 424 425 if (\count($arrErrors) == 0) { 426 $id = $_POST['id']; 427 if (!DBUtil::tbl__items__delete($id)) { 428 \array_push($arrErrors, 'error__delete_item'); 429 } 430 } 431 432 die(json_encode(['success' => (\count($arrErrors) == 0), 433 'errors' => $arrErrors])); 434 } 435 436 function action_wp_ajax_rainbow_pay_press__admin__delete_transaction() { 335 437 /** Possible errors: 336 438 * error__insufficient_permissions … … 344 446 } 345 447 346 if ( count($arrErrors) == 0) {448 if (\count($arrErrors) == 0) { 347 449 $id = $_POST['id']; 348 if (!DBUtil:: deleteTransaction($id)) {450 if (!DBUtil::tbl__transactions__delete($id)) { 349 451 \array_push($arrErrors, 'error__delete_transaction'); 350 452 } 351 453 } 352 454 353 die(json_encode(['success' => ( count($arrErrors) == 0),455 die(json_encode(['success' => (\count($arrErrors) == 0), 354 456 'errors' => $arrErrors])); 355 457 } … … 374 476 375 477 die(\json_encode($objRet)); 478 } 479 480 function action_wp_ajax_rainbow_pay_press__admin__get_items() { 481 /** Possible errors: 482 * error__insufficient_permissions 483 * error__select_items 484 **/ 485 486 $arrErrors = []; 487 488 if (!\current_user_can('manage_options')) { 489 \array_push($arrErrors, 'error__insufficient_permissions'); 490 } 491 492 $arrItems = null; 493 if (\count($arrErrors) == 0) { 494 $arrItems = DBUtil::tbl__items__selectAll(); 495 if (!$arrItems) { 496 \array_push($arrErrors, 'error__select_items'); 497 } 498 } 499 500 die(\json_encode(['success' => (\count($arrErrors) == 0), 501 'errors' => $arrErrors, 502 'items' => Util::translateItems($arrItems)])); 376 503 } 377 504 … … 389 516 390 517 $arrTransactions = null; 391 if ( count($arrErrors) == 0) {392 $arrTransactions = DBUtil:: selectTransactions();518 if (\count($arrErrors) == 0) { 519 $arrTransactions = DBUtil::tbl__transactions__selectAll(); 393 520 if (!$arrTransactions) { 394 521 \array_push($arrErrors, 'error__select_transactions'); … … 396 523 } 397 524 398 die(\json_encode(['success' => ( count($arrErrors) == 0),525 die(\json_encode(['success' => (\count($arrErrors) == 0), 399 526 'errors' => $arrErrors, 400 527 'transactions' => $arrTransactions])); 528 } 529 530 function action_wp_ajax_rainbow_pay_press__admin__modify_item() { 531 /** Possible errors: 532 * error__insufficient_permissions 533 * error__duplicate_handle 534 * error__update_item 535 **/ 536 537 $arrErrors = []; 538 539 if (!\current_user_can('manage_options')) { 540 \array_push($arrErrors, 'error__insufficient_permissions'); 541 } 542 543 $item = null; 544 545 if (\count($arrErrors) == 0) { 546 $id = $_POST['id']; 547 $arrDataDecoded = \json_decode(\urldecode($_POST['data']), true); 548 $handle = getKeyValue($arrDataDecoded, 'handle'); 549 550 if ($handle != null && DBUtil::tbl__items__selectSpecificForHandle($handle)) { 551 \array_push($arrErrors, 'error__duplicate_handle'); 552 } else if (!DBUtil::tbl__items__update($id, $arrDataDecoded)) { 553 \array_push($arrErrors, 'error__update_item'); 554 } else { 555 $item = DBUtil::tbl__items__selectSpecific($id); 556 } 557 } 558 559 die(\json_encode(['success' => (\count($arrErrors) == 0), 560 'errors' => $arrErrors, 561 'item' => Util::translateItem($item)])); 401 562 } 402 563 … … 414 575 } 415 576 416 if ( count($arrErrors) == 0) {577 if (\count($arrErrors) == 0) { 417 578 $strRecipient = \get_option(SETTING__EMAIL_NOTIFICATIONS); 418 579 $strSiteURL = \get_site_url(); … … 446 607 } 447 608 448 die(\json_encode(['success' => ( count($arrErrors) == 0),609 die(\json_encode(['success' => (\count($arrErrors) == 0), 449 610 'errors' => $arrErrors])); 450 611 } … … 465 626 $objConfig = $_POST['config']; 466 627 467 if (array_key_exists('email_notifications', $objConfig)) { 468 \update_option(SETTING__EMAIL_NOTIFICATIONS, 469 $objConfig['email_notifications']); 470 } 471 472 if (array_key_exists('flag_enable_email_notifications', $objConfig)) { 473 \update_option(SETTING__FLAG_ENABLE_EMAIL_NOTIFICATIONS, 474 $objConfig['flag_enable_email_notifications']); 475 } 476 477 if (array_key_exists('stripe_key_live_secret', $objConfig)) { 478 \update_option(SETTING__STRIPE_LIVE_SECRET_KEY, $objConfig['stripe_key_live_secret']); 479 } 480 if (array_key_exists('stripe_key_live_publish', $objConfig)) { 481 \update_option(SETTING__STRIPE_LIVE_PUBLISH_KEY, 482 $objConfig['stripe_key_live_publish']); 483 } 484 485 if (array_key_exists('stripe_key_test_secret', $objConfig)) { 486 \update_option(SETTING__STRIPE_TEST_SECRET_KEY, $objConfig['stripe_key_test_secret']); 487 } 488 if (array_key_exists('stripe_key_test_publish', $objConfig)) { 489 \update_option(SETTING__STRIPE_TEST_PUBLISH_KEY, 490 $objConfig['stripe_key_test_publish']); 491 } 628 $_updateConfigFieldIfNecessary = function($strOption, $strField) use ($objConfig) { 629 if (\array_key_exists($strField, $objConfig)) { 630 \update_option($strOption, 631 $objConfig[$strField]); 632 } 633 }; 634 635 $_updateConfigFieldIfNecessary(SETTING__ENTITY_NAME, 636 'entity_name'); 637 $_updateConfigFieldIfNecessary(SETTING__EMAIL_NOTIFICATIONS, 638 'email_notifications'); 639 $_updateConfigFieldIfNecessary(SETTING__FLAG_ENABLE_EMAIL_NOTIFICATIONS, 640 'flag_enable_email_notifications'); 641 $_updateConfigFieldIfNecessary(SETTING__STRIPE_LIVE_SECRET_KEY, 642 'stripe_key_live_secret'); 643 $_updateConfigFieldIfNecessary(SETTING__STRIPE_LIVE_PUBLISH_KEY, 644 'stripe_key_live_publish'); 645 $_updateConfigFieldIfNecessary(SETTING__STRIPE_TEST_SECRET_KEY, 646 'stripe_key_test_secret'); 647 $_updateConfigFieldIfNecessary(SETTING__STRIPE_TEST_PUBLISH_KEY, 648 'stripe_key_test_publish'); 492 649 } 493 650 … … 504 661 function action_wp_ajax_rainbow_pay_press__submit() { 505 662 /** Possible errors: 663 * error__item_not_found 664 * error__item_disallowed 506 665 * error__insert_transaction 666 * error__select_transaction 507 667 **/ 508 668 509 669 $arrErrors = []; 510 670 511 $strType = $_POST['type']; 512 $strChargeDescription = $_POST['charge_description']; 513 $strProductCost = $_POST['charge_amount']; 514 $strStripeTokenId = $_POST['stripe_token_id']; 515 $strStripeEmail = $_POST['stripe_email']; 516 $strCustomerName = $_POST['customer_name']; 517 $strCustomerPhone = $_POST['customer_phone']; 518 $strShippingAddress = $_POST['shipping_address']; 519 520 if (!DBUtil::insertTransaction($strType, 521 $strChargeDescription, 522 $strProductCost, 523 $strStripeTokenId, 524 $strStripeEmail, 525 $strCustomerName, 526 $strCustomerPhone, 527 $strShippingAddress)) { 528 \array_push($arrErrors, 'error__insert_transaction'); 529 } 530 531 if (count($arrErrors) == 0 && Util::getFlagEnableEmailNotifications()) { 532 $strRecipient = \get_option(SETTING__EMAIL_NOTIFICATIONS); 533 $strSiteURL = \get_site_url(); 534 535 if (\strlen($strRecipient) > 0) { 536 \wp_mail( 537 $strRecipient, 538 \__('RainbowPayPress new pending transaction submitted at: ' . $strSiteURL, 539 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 540 \implode([ 541 \sprintf( 542 \__('New pending transaction has been submitted via the RainbowPayPress plugin installed onto the WordPress website at: %s', 543 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 544 $strSiteURL), 545 "\r\n\r\n", 546 \sprintf( 547 \__('Stripe transaction type: %s', 548 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 549 $strType), 550 "\r\n\r\n", 551 \sprintf( 552 \__('Charge: %s', 553 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 554 \implode([$strChargeDescription, 555 ' -- ', 556 Util::formatUSD($strProductCost)])), 557 "\r\n\r\n", 558 \sprintf( 559 \__('Customer: %s', 560 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 561 \implode([$strStripeEmail, 562 ' -- ', 563 $strCustomerName, 564 ' -- ', 565 $strCustomerPhone, 566 ($strShippingAddress != "" ? (' -- ' . $strShippingAddress) 567 : "")])), 568 "\r\n\r\n", 569 \sprintf( 570 \__('View / charge / delete this transaction at: %s', 571 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 572 \admin_url('admin.php?page=' . SLUG_TRANSACTIONS)) 573 ])); 574 } 575 } 576 577 die(json_encode(['success' => (count($arrErrors) == 0), 578 'errors' => $arrErrors])); 671 $arrDataDecoded = \json_decode(\urldecode($_POST['data']), true); 672 673 $strHandle = $arrDataDecoded['handle']; 674 675 $objItem = DBUtil::tbl__items__selectSpecificForHandle($strHandle); 676 677 $strDisallowedReason = null; 678 679 if ($objItem) { 680 \array_push($arrErrors, 'error__item_disallowed'); 681 682 $strDisallowedReason = $objItem['disallowed_reason']; 683 } else { 684 \array_push($arrErrors, 'error__item_not_found'); 685 } 686 687 $objTransaction = null; 688 689 if (\count($arrErrors) == 0) { 690 691 $idTransaction = DBUtil::tbl__transactions__insert($arrDataDecoded['type'], 692 $objItem['description'], 693 $objItem['cost'], 694 $arrDataDecoded['stripe_token_id'], 695 $arrDataDecoded['stripe_email'], 696 $arrDataDecoded['customer_name'], 697 $arrDataDecoded['customer_phone'], 698 $arrDataDecoded['shipping_address']); 699 700 if ($idTransaction === false) { 701 \array_push($arrErrors, 'error__insert_transaction'); 702 } else { 703 $objTransaction = DBUtil::tbl__transactions__selectSpecific($idTransaction); 704 if (!$objTransaction) { 705 \array_push($arrErrors, 'error__select_transaction'); 706 } else if (Util::getFlagEnableEmailNotifications()) { 707 708 $strRecipient = \get_option(SETTING__EMAIL_NOTIFICATIONS); 709 710 if (\strlen($strRecipient) > 0) { 711 712 $strSiteURL = \get_site_url(); 713 $strSubmissionTime = $objTransaction['created']; 714 $strShippingAddress = $objTransaction['shipping_address']; 715 716 \wp_mail( 717 $strRecipient, 718 \__('RainbowPayPress new pending transaction submitted at: ' . $strSiteURL, 719 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 720 \implode([ 721 \sprintf( 722 \__('New pending transaction has been submitted via the RainbowPayPress plugin installed onto the WordPress website at: %s', 723 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 724 $strSiteURL), 725 "\r\n\r\n", 726 \sprintf( 727 \__('Submission timestamp: %s', 728 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 729 $strSubmissionTime ? ($strSubmissionTime . 730 ' ' . 731 \__('UTC', 732 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS)) 733 : 'unknown'), 734 "\r\n\r\n", 735 \sprintf( 736 \__('Stripe transaction type: %s', 737 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 738 $objTransaction['type']), 739 "\r\n\r\n", 740 \sprintf( 741 \__('Charge: %s', 742 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 743 \implode([$objTransaction['charge_description'], 744 ' -- ', 745 Util::formatUSD($objTransaction['charge_amount'])])), 746 "\r\n\r\n", 747 \sprintf( 748 \__('Customer: %s', 749 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 750 \implode([$objTransaction['stripe_email'], 751 ' -- ', 752 $objTransaction['customer_name'], 753 ' -- ', 754 $objTransaction['customer_phone'], 755 ($strShippingAddress != "" ? (' -- ' . 756 $strShippingAddress) 757 : "")])), 758 "\r\n\r\n", 759 \sprintf( 760 \__('View / charge / delete this transaction at: %s', 761 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 762 \admin_url('admin.php?page=' . SLUG_TRANSACTIONS)) 763 ])); 764 } 765 } 766 } 767 } 768 769 die(json_encode(['transaction' => $objTransaction 770 ? ['created' => $objTransaction['created']] 771 : null, 772 'success' => (\count($arrErrors) == 0), 773 'errors' => $arrErrors, 774 'disallowed_reason' => $strDisallowedReason])); 579 775 } 580 776 581 777 function action_wp_enqueue_scripts() { 778 779 \wp_enqueue_style('plugin__RainbowPayPress__style_css', 780 \plugin_dir_url(__FILE__) . '/style.css', 781 null, 782 getUVArg()); 582 783 583 784 \wp_enqueue_script( … … 642 843 } 643 844 644 DBUtil::initializeTable_Transactions(); 845 DBUtil::tbl__items__init(); 846 DBUtil::tbl__transactions__init(); 645 847 } 646 848 647 849 function shortcode_rainbow_pay_press($atts) { 648 if ($atts == null || 649 $atts['amount'] == null || 650 $atts['desc'] == null || 651 $atts['name'] == null) { 850 851 $strEntityName = Util::getOption(SETTING__ENTITY_NAME); 852 if ($strEntityName == null) { 652 853 return '<b><i>' . 653 854 \sprintf( 654 \__('Short-code [%s] missconfigured.',855 \__('Short-code [%s] cannot be fully processed because entity name not configured.', 655 856 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 656 857 SHORTCODE__RAINBOW_PAY_PRESS) . 858 '</i></b>'; 859 } 860 861 $strItemHandle = $atts ? $atts['item'] : null; 862 if ($strItemHandle == null) { 863 return '<b><i>' . 864 \sprintf( 865 \__('Short-code [%s] cannot be fully processed because required parameter "%s" is not included.', 866 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 867 SHORTCODE__RAINBOW_PAY_PRESS, 868 'item') . 869 '</i></b>'; 870 } 871 872 $objItem = DBUtil::tbl__items__selectSpecificForHandle($strItemHandle); 873 if (!$objItem) { 874 return '<b><i>' . 875 \sprintf( 876 \__('Short-code [%s] cannot be fully processed because no item with the specified handle "%s" was found.', 877 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS), 878 SHORTCODE__RAINBOW_PAY_PRESS, 879 $strItemHandle) . 657 880 '</i></b>'; 658 881 } … … 662 885 ' data-plugin-rainbow-pay-press-type="' . \esc_attr($atts['type']) . 663 886 '"') . 664 ' data-plugin-rainbow-pay-press-amount="' . \esc_attr($ atts['amount']) .887 ' data-plugin-rainbow-pay-press-amount="' . \esc_attr($objItem['cost']) . 665 888 '"' . 666 ' data-plugin-rainbow-pay-press-name="' . \esc_attr($ atts['name']) .889 ' data-plugin-rainbow-pay-press-name="' . \esc_attr($strEntityName) . 667 890 '"' . 668 ' data-plugin-rainbow-pay-press-desc="' . \esc_attr($ atts['desc']) .891 ' data-plugin-rainbow-pay-press-desc="' . \esc_attr($objItem['description']) . 669 892 '"' . 670 671 ($atts['fields'] == null ? "" : 672 ' data-plugin-rainbow-pay-press-fields="' . \esc_attr($atts['fields']) . 893 ' data-plugin-rainbow-pay-press-handle="' . \esc_attr($strItemHandle) . 894 '"' . 895 896 ($atts['override_fields'] == null ? "" : 897 ' data-plugin-rainbow-pay-press-fields="' . \esc_attr($atts['override_fields']) . 673 898 '"') . 674 899 -
rainbowpaypress/trunk/RainbowPayPress_util.php
r1385818 r1391844 6 6 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 7 7 8 Version: 2.4.0-development_unreleased8 Version: 3.1.0-development_unreleased 9 9 10 10 Module: rainbowpaypress/RainbowPayPress_util.php … … 34 34 35 35 36 function getKeyValue($arr, $key, $default = null) { 37 if (!$arr) return $default; 38 39 if (\array_key_exists($key, $arr)) { 40 return $arr[$key]; 41 } 42 43 return $default; 44 } 45 36 46 function getDateTimeNow() { 37 47 $ms = \time() * 1000 + \substr(\microtime(), 2, 3); 38 return \gmdate('Y-m-d H:i:s', $ms / 1000);48 return \gmdate('Y-m-d H:i:s', $ms / 1000); 39 49 } 40 50 … … 48 58 49 59 class DBUtil { 50 static function deleteTransaction($id) { 51 global $wpdb; 52 return $wpdb->delete(DBUtil::getTableName_Transactions(), ['id' => $id]); 53 } 54 55 static function getTableName_Transactions() { 60 static function tbl__items__add($strHandle, $strDescription, $strCost) { 61 global $wpdb; 62 if (!$wpdb->insert( 63 DBUtil::tbl__items__getName(), [ 64 'handle' => $strHandle, 65 'description' => $strDescription, 66 'cost' => $strCost, 67 'currency' => 'usd_x_100' 68 ])) return false; 69 70 return DBUtil::tbl__items__selectSpecific($wpdb->insert_id); 71 } 72 73 static function tbl__items__delete($id) { 74 global $wpdb; 75 return $wpdb->delete(DBUtil::tbl__items__getName(), ['id' => $id]); 76 } 77 78 static function tbl__items__getName() { 79 global $wpdb; 80 return $wpdb->prefix . 'plugin_rainbow_pay_press_items'; 81 } 82 83 static function tbl__items__init() { 84 $strTableName = DBUtil::tbl__items__getName(); 85 global $wpdb; 86 $sql = "CREATE TABLE $strTableName ( 87 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, 88 handle varchar(20) NOT NULL UNIQUE, 89 cost int NOT NULL, 90 currency varchar(20) NOT NULL, 91 description varchar(1000) NOT NULL, 92 is_disallowed boolean, 93 disallowed_reason varchar(1000) 94 );"; 95 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 96 dbDelta($sql); 97 } 98 99 static function tbl__items__selectAll() { 100 $strTableName = DBUtil::tbl__items__getName(); 101 102 global $wpdb; 103 return $wpdb->get_results("SELECT id, 104 handle, 105 cost, 106 description, 107 is_disallowed, 108 disallowed_reason 109 FROM $strTableName", ARRAY_A); 110 } 111 112 static function tbl__items__selectSpecific($id) { 113 $strTableName = DBUtil::tbl__items__getName(); 114 115 global $wpdb; 116 $arrItem = $wpdb->get_results($wpdb->prepare("SELECT id, 117 handle, 118 cost, 119 description, 120 is_disallowed, 121 disallowed_reason 122 FROM $strTableName 123 WHERE id=%d", 124 $id), 125 ARRAY_A); 126 if (!$arrItem || count($arrItem) == 0) return false; 127 128 return $arrItem[0]; 129 } 130 131 static function tbl__items__selectSpecificForHandle($handle) { 132 $strTableName = DBUtil::tbl__items__getName(); 133 134 global $wpdb; 135 $arrItem = $wpdb->get_results($wpdb->prepare("SELECT id, 136 handle, 137 cost, 138 description, 139 is_disallowed, 140 disallowed_reason 141 FROM $strTableName 142 WHERE handle=%s", 143 $handle), 144 ARRAY_A); 145 if (!$arrItem || count($arrItem) == 0) return false; 146 147 return $arrItem[0]; 148 } 149 150 static function tbl__items__update($id, $objData) { 151 global $wpdb; 152 if(!$wpdb->update(DBUtil::tbl__items__getName(), 153 $objData, 154 ['id' => $id])) return false; 155 return true; 156 } 157 158 159 static function tbl__transactions__delete($id) { 160 global $wpdb; 161 return $wpdb->delete(DBUtil::tbl__transactions__getName(), ['id' => $id]); 162 } 163 164 static function tbl__transactions__getName() { 56 165 global $wpdb; 57 166 return $wpdb->prefix . 'plugin_rainbow_pay_press_transactions'; 58 167 } 59 168 60 static function initializeTable_Transactions() {61 $strTableName = DBUtil:: getTableName_Transactions();169 static function tbl__transactions__init() { 170 $strTableName = DBUtil::tbl__transactions__getName(); 62 171 global $wpdb; 63 172 $sql = "CREATE TABLE $strTableName ( … … 71 180 stripe_token_id varchar(100) NOT NULL, 72 181 stripe_email varchar(200) NOT NULL, 73 customer_name varchar(200) NOT NULL,74 customer_phone varchar(100) NOT NULL,182 customer_name varchar(200), 183 customer_phone varchar(100), 75 184 shipping_address varchar(300), 76 185 stripe_customer_id varchar(100), … … 81 190 } 82 191 83 static function insertTransaction($strType,84 $strChargeDescription,85 $strProductCost,86 $strStripeTokenId,87 $strStripeEmail,88 $strCustomerName,89 $strCustomerPhone,90 $strShippingAddress) {91 92 global $wpdb; 93 if (!$wpdb->insert(DBUtil:: getTableName_Transactions(), [192 static function tbl__transactions__insert($strType, 193 $strChargeDescription, 194 $strProductCost, 195 $strStripeTokenId, 196 $strStripeEmail, 197 $strCustomerName, 198 $strCustomerPhone, 199 $strShippingAddress) { 200 201 global $wpdb; 202 if (!$wpdb->insert(DBUtil::tbl__transactions__getName(), [ 94 203 'type' => $strType, 95 204 'created' => getDateTimeNow(), … … 103 212 'shipping_address' => $strShippingAddress])) return false; 104 213 105 return true; 106 } 107 108 static function selectTransaction($id) { 109 $strTableName = DBUtil::getTableName_Transactions(); 214 return $wpdb->insert_id; 215 } 216 217 static function tbl__transactions__selectAll() { 218 $strTableName = DBUtil::tbl__transactions__getName(); 219 220 global $wpdb; 221 return $wpdb->get_results("SELECT id, 222 type, 223 created, 224 charged, 225 charge_description, 226 charge_amount, 227 stripe_token_id, 228 stripe_email, 229 customer_name, 230 customer_phone, 231 shipping_address, 232 stripe_customer_id, 233 stripe_charge_id 234 FROM $strTableName ORDER BY charged, created", ARRAY_A); 235 } 236 237 static function tbl__transactions__selectSpecific($id) { 238 $strTableName = DBUtil::tbl__transactions__getName(); 110 239 111 240 global $wpdb; … … 130 259 } 131 260 132 static function selectTransactions() { 133 $strTableName = DBUtil::getTableName_Transactions(); 134 135 global $wpdb; 136 return $wpdb->get_results("SELECT id, 137 type, 138 created, 139 charged, 140 charge_description, 141 charge_amount, 142 stripe_token_id, 143 stripe_email, 144 customer_name, 145 customer_phone, 146 shipping_address, 147 stripe_customer_id, 148 stripe_charge_id 149 FROM $strTableName ORDER BY charged, created", ARRAY_A); 150 } 151 152 static function updateTransactionAsCharged($id, $stripe_customer_id, $stripe_charge_id) { 261 static function tbl__transactions__update__charged($id, 262 $stripe_customer_id, 263 $stripe_charge_id) { 153 264 154 265 $date_time = getDateTimeNow(); 155 266 156 267 global $wpdb; 157 if(!$wpdb->update(DBUtil:: getTableName_Transactions(),268 if(!$wpdb->update(DBUtil::tbl__transactions__getName(), 158 269 ['charged' => $date_time, 159 270 'stripe_customer_id' => $stripe_customer_id, … … 190 301 <h2><?=\__('Usage Info:', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS)?></h2> 191 302 <p>Use the shortcode 192 <code>[<?=SHORTCODE__RAINBOW_PAY_PRESS?> type='<span style='color:red'>live</span>' amount=1234 name="My entity" desc="Buy this" label="Click to buy"fields='!phone shipping']</code>303 <code>[<?=SHORTCODE__RAINBOW_PAY_PRESS?> type='<span style='color:red'>live</span>' item="handle" label="Click to buy" override_fields='!phone shipping']</code> 193 304 to embed a Stripe payment widget on 194 305 any page or post. … … 203 314 <ul class='rpp_subitems'> 204 315 <li> 205 <code>amount</code> 206 <p>The amount to charge in US cents.</p> 207 </li> 208 <li> 209 <code>name</code> 210 <p>Your site / company / organization name.</p> 211 </li> 212 <li> 213 <code>desc</code> 214 <p>Description of the product / service / fee you're charging for.</p> 316 <code>item</code> 317 <p>The handle of the item to sell. Items and their handles can be specified 318 <a href='<?=\admin_url('admin.php?page=' . SLUG_ITEMS)?>'>here</a>.</p> 215 319 </li> 216 320 </ul> … … 238 342 </li> 239 343 <li> 240 <code> fields</code>344 <code>override_fields</code> 241 345 <p> 242 Specifieswhich fields to include or exclude on the buyer entry form.346 Overrides default settings for which fields to include or exclude on the buyer entry form. 243 347 Available fields: 244 348 <ul class='rpp_subitems'> … … 260 364 } 261 365 366 static function renderAdmin_Items() { 367 // Based on http://codex.wordpress.org/Administration_Menus 368 if (!\current_user_can('manage_options' )) { 369 \wp_die(\__('You do not have sufficient permissions to access this page.', 370 DOMAIN_PLUGIN_RAINBOW_PAY_PRESS)); 371 } 372 ?> 373 <div class='wrap'> 374 <h3><?=\__('Items to be included in transactions:', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS)?></h3> 375 <p> 376 <span data-plugin-rainbow-pay-press-role='add-new-item'></span> 377 </p> 378 <p> 379 <span data-plugin-rainbow-pay-press-role='items'></span> 380 </p> 381 </div> 382 <?php 383 } 384 262 385 static function renderAdmin_Transactions() { 263 386 // Based on http://codex.wordpress.org/Administration_Menus … … 267 390 } 268 391 ?> 269 <style>270 .transaction--even {271 background-color: #eee;272 }273 .transaction--odd {274 background-color: #ddd;275 }276 </style>277 392 <div class='wrap'> 278 393 <h3><?=\__('Pending Transactions:', DOMAIN_PLUGIN_RAINBOW_PAY_PRESS)?></h3> … … 333 448 334 449 static function getConfig() { 335 return ['email_notifications' => Util::getOption(SETTING__EMAIL_NOTIFICATIONS), 450 return ['entity_name' => Util::getOption(SETTING__ENTITY_NAME), 451 'email_notifications' => Util::getOption(SETTING__EMAIL_NOTIFICATIONS), 336 452 'flag_enable_email_notifications' 337 453 => Util::getFlagEnableEmailNotifications(), … … 355 471 return \function_exists('\\curl_init'); 356 472 } 473 474 static function translateItem($objItemDB) { 475 if (!$objItemDB) return null; 476 477 return ['id' => $objItemDB['id'], 478 'handle' => $objItemDB['handle'], 479 'description' => $objItemDB['description'], 480 'cost' => \intval($objItemDB['cost']), 481 'is_disallowed' => $objItemDB['is_disallowed'] ? true : false, 482 'disallowed_reason' => $objItemDB['disallowed_reason']]; 483 } 484 485 static function translateItems($arrItems) { 486 if (!$arrItems) return null; 487 488 $arrItemsTranslated = []; 489 490 foreach ($arrItems as $objItem) { 491 \array_push($arrItemsTranslated, Util::translateItem($objItem)); 492 } 493 494 return $arrItemsTranslated; 495 } 357 496 } 358 497 ?> -
rainbowpaypress/trunk/js/le_requirejs/admin/collection_orig__transaction.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/collection_orig__transaction.js … … 36 36 define(['backbone', 37 37 'jquery', 38 'util', 38 39 'model_orig__app_common', 39 40 'admin/model_orig__transaction' 40 ], function (backbone, $, model_orig__app_common, ModelOrig_Transaction) {41 ], function (backbone, $, util, model_orig__app_common, ModelOrig_Transaction) { 41 42 42 43 return new (backbone.Collection.extend({ … … 93 94 94 95 model_orig__transaction.set({ 95 'charged': objData['charged'] == null 96 ? null 97 : new window 98 .Date(objData['charged'] 99 + ' GMT'), 96 'charged': util.parseDate(objData['charged']), 100 97 'stripe_customer_id': objData['stripe_customer_id'], 101 98 'stripe_charge_id': objData['stripe_charge_id'] … … 109 106 var $xhr = $.ajax(model_orig__app_common.get('ajax_url'), { 110 107 data: { 111 'action': 'rainbow_pay_press__admin__delete ',108 'action': 'rainbow_pay_press__admin__delete_transaction', 112 109 'id': model_orig__transaction.get('id') 113 110 }, -
rainbowpaypress/trunk/js/le_requirejs/admin/main_admin.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/main_admin.js … … 36 36 define(['jquery', 37 37 'model_orig__app_common', 38 'admin/collection_orig__item', 38 39 'admin/collection_orig__transaction', 39 40 'admin/model_orig__config', 41 'admin/view_agg__button__add_new_item', 40 42 'admin/view_agg__table__config', 43 'admin/view_agg__table__items', 41 44 'admin/view_agg__table__transactions' 42 45 ], function($, 43 46 model_orig__app_common, 44 collection_orig_transaction, 47 collection_orig__item, 48 collection_orig__transaction, 45 49 model_orig__config, 50 ViewAgg_Button_AddNewItem, 46 51 ViewAgg_Table_Config, 52 ViewAgg_Table_Items, 47 53 ViewAgg_Table_Transactions) { 48 54 49 55 function _processSpansWithRoles(params) { 50 56 51 (new ViewAgg_Table_Config()) 52 .$el 53 .appendTo($("span[data-plugin-rainbow-pay-press-role=app-config]")); 57 var $snapAppConfig = $("span[data-plugin-rainbow-pay-press-role=app-config]"); 58 if ($snapAppConfig) { 59 (new ViewAgg_Table_Config()).$el.appendTo($snapAppConfig); 60 } 54 61 55 62 56 collection_orig_transaction.fetch(); 63 var $snapAddNewItem = $("span[data-plugin-rainbow-pay-press-role=add-new-item]"); 64 if ($snapAddNewItem) { 65 (new ViewAgg_Button_AddNewItem()).$el.appendTo($snapAddNewItem); 66 } 57 67 58 function _processSpans($elSpans, params) { 68 69 var $snapItems = $("span[data-plugin-rainbow-pay-press-role=items]"); 70 if ($snapItems) { 71 collection_orig__item.fetch(); 72 (new ViewAgg_Table_Items()).$el.appendTo($snapItems); 73 } 74 75 76 function _processTransactionSpans($elSpans, params) { 77 if ($elSpans.length == 0) return; 78 79 collection_orig__transaction.fetch(); 80 59 81 for (var i = 0; i < $elSpans.length; i++) { 60 82 var $elSpan = $($elSpans[i]); 83 if (!$elSpan) continue; 61 84 62 85 (new ViewAgg_Table_Transactions(params)).$el.appendTo($elSpan); … … 64 87 } 65 88 66 _process Spans($("span[data-plugin-rainbow-pay-press-role=transactions]"));67 _processSpans($("span[data-plugin-rainbow-pay-press-role=transactions-charged]"),89 _processTransactionSpans( 90 $("span[data-plugin-rainbow-pay-press-role=transactions-charged]"), 68 91 {flag_exclude_uncharged: true}); 69 _processSpans($("span[data-plugin-rainbow-pay-press-role=transactions-pending]"), 92 _processTransactionSpans( 93 $("span[data-plugin-rainbow-pay-press-role=transactions-pending]"), 70 94 {flag_exclude_charged: true}); 71 95 } … … 83 107 84 108 model_orig__config.set({ 109 'entity_name': params['entity_name'], 85 110 'email_notifications': params['email_notifications'], 86 111 'flag_enable_email_notifications': -
rainbowpaypress/trunk/js/le_requirejs/admin/model_orig__config.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/model_orig__config.js … … 44 44 45 45 defaults: { 46 'entity_name': null, 46 47 'email_notifications': null, 47 48 'flag_enable_email_notifications': false, -
rainbowpaypress/trunk/js/le_requirejs/admin/model_orig__transaction.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/model_orig__transaction.js … … 34 34 35 35 36 define(['backbone'], function (backbone) { 37 38 // This will parse a date string in the format "2016-04-03 05:10:41" that is assumed to 39 // be in UTC time. 40 function _parseDate(strDate) { 41 if (!strDate) return null; 42 43 var arrParts = strDate.split(' '); 44 return new Date(arrParts[0] + 'T' + arrParts[1] + 'Z'); 45 } 36 define(['backbone', 'util'], function (backbone, util) { 46 37 47 38 return backbone.Model.extend({ … … 69 60 'id': data['id'], 70 61 'type': data['type'], 71 'created': _parseDate(data['created']),72 'charged': _parseDate(data['charged']),62 'created': util.parseDate(data['created']), 63 'charged': util.parseDate(data['charged']), 73 64 'charge_description': data['charge_description'], 74 65 'charge_amount': data['charge_amount'], -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__button.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__button.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__button__send_test_email.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__button__send_test_email.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__span__date.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__span__date.js … … 33 33 34 34 35 define(['backbone', 'jquery'], function(backbone, $) { 36 37 38 function _getDigits(num, len) { 39 var str = "" + num; 40 while (str.length < len) { 41 str = '0' + str; 42 } 43 return str; 44 } 45 46 function _getDateComponents(date) { 47 if (!date) return null; 48 49 return { 50 year: date.getFullYear(), 51 month: _getDigits(date.getMonth() + 1, 2), 52 day: _getDigits(date.getDate(), 2), 53 hour: _getDigits(date.getHours(), 2), 54 min: _getDigits(date.getMinutes(), 2), 55 sec: _getDigits(date.getSeconds(), 2), 56 msec: _getDigits(date.getMilliseconds(), 3) 57 }; 58 } 59 60 function _getDateReprTZName(date) { 61 var arrMatchTZ = date && date.toString().match(/\([^)]+\)/g); 62 return arrMatchTZ && arrMatchTZ.length == 1 && arrMatchTZ[0] || ""; 63 } 64 65 function _getDateStrings(date) { 66 67 var date_components = _getDateComponents(date); 68 if (!date_components) return null; 69 70 function _getWeekday() { 71 return (['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])[date.getDay()]; 72 } 73 74 return { 75 'weekday': _getWeekday(), 76 'date': date_components.year + '-' + date_components.month 77 + '-' + date_components.day, 78 'time': date_components.hour + ':' + date_components.min 79 + ':' + date_components.sec, 80 'tz': _getDateReprTZName(date) 81 }; 82 } 83 84 function _getDateRepr(date) { 85 86 var date_strings = _getDateStrings(date); 87 if (!date_strings) return null; 88 89 return date_strings.weekday + ' ' + date_strings.date 90 + ' ' + date_strings.time 91 + ' ' + date_strings.tz; 92 } 93 35 define(['backbone', 'jquery', 'util'], function(backbone, $, util) { 94 36 95 37 return backbone.View.extend({ … … 109 51 .appendTo(this.$el); 110 52 111 var date_strings = _getDateStrings(date);53 var date_strings = util.getDateStrings(date); 112 54 if (!date_strings) { 113 55 $spanWeekday.text(""); -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__table__config.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__table__config.js … … 86 86 this.$el.append($("<tr>").append($("<th>").append($buttonRefresh))); 87 87 88 (new ViewAgg_Tr_Config_Option_String({ 89 field: 'entity_name', 90 label: "Your site / company / organization name:", 91 prompt: "Enter your site / company / organization name:" 92 })).$el 93 .appendTo(this.$el); 94 88 95 (new ViewAgg_Tr_Config_Option_Boolean({ 89 96 field: 'flag_enable_email_notifications', -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__table__transactions.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__table__transactions.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__config__notes.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__config__notes.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__config__option.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__config__option.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__config__option__boolean.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__config__option__string.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__config__option__string.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__config__option__string.js … … 72 72 .get(params.field) 73 73 || ""); 74 if ( !strValNew) return;74 if (strValNew == null) return; 75 75 76 76 var objConfig = {}; -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__config__option__string__email_notifications.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__config__option__string__email_notifications.js -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__transaction.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__transaction.js … … 45 45 ViewAgg_Span_Date, 46 46 ViewAgg_Tr_WHeader) { 47 48 function _flipToSingleCol() {49 var totalCols = this.$el.children().length;50 51 this.$el.empty();52 53 return _td().attr({'colspan': totalCols,54 'style': 'text-align:center'})55 .appendTo(this.$el);56 }57 47 58 48 function _getStripeUrlForCharge(type, stripe_charge_id) { … … 190 180 191 181 markAsCharged: function() { 192 _flipToSingleCol.call(this).text("--- Charged ---");182 this.markAs("--- Charged ---"); 193 183 }, 194 184 195 185 markAsDeleted: function() { 196 _flipToSingleCol.call(this).text("--- Deleted ---");186 this.markAs("--- Deleted ---"); 197 187 } 198 188 }); -
rainbowpaypress/trunk/js/le_requirejs/admin/view_agg__tr__w_header.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__w_header.js … … 51 51 var $thHeader = $('<th>'); 52 52 53 this.$el.append($thHeader); 53 this.$el.attr('valign', 'top') 54 .append($thHeader); 54 55 55 56 this.get_$thHeader = function() { 56 57 return $thHeader; 57 58 }; 59 }, 60 61 _flipToSingleCol: function() { 62 var totalCols = this.$el.children().length; 63 64 this.$el.empty(); 65 66 return $('<td>').attr({'colspan': totalCols, 67 'style': 'text-align:center'}) 68 .appendTo(this.$el); 69 }, 70 71 markAs: function(strText) { 72 this._flipToSingleCol().text(strText); 58 73 } 59 74 }); -
rainbowpaypress/trunk/js/le_requirejs/backbone-private.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/backbone-private.js -
rainbowpaypress/trunk/js/le_requirejs/common.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/common.js -
rainbowpaypress/trunk/js/le_requirejs/jquery-private.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/jquery-private.js -
rainbowpaypress/trunk/js/le_requirejs/main.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/main.js -
rainbowpaypress/trunk/js/le_requirejs/model_orig__app_common.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/model_orig__app_common.js -
rainbowpaypress/trunk/js/le_requirejs/public/main_public.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/main_public.js … … 45 45 function _processShortcodes() { 46 46 function _processSpan($elSpan) { 47 var type = $elSpan.attr('data-plugin-rainbow-pay-press-type') || 'test', 48 amount = $elSpan.attr('data-plugin-rainbow-pay-press-amount'), 49 fields = $elSpan.attr('data-plugin-rainbow-pay-press-fields'), 50 name = $elSpan.attr('data-plugin-rainbow-pay-press-name'), 51 desc = $elSpan.attr('data-plugin-rainbow-pay-press-desc'), 52 info = $elSpan.attr('data-plugin-rainbow-pay-press-info'), 53 label = $elSpan.attr('data-plugin-rainbow-pay-press-label'); 47 var label = $elSpan.attr('data-plugin-rainbow-pay-press-label'); 54 48 55 49 var $buttonMakePayment = $('<button>').text(label || "Pay with Stripe") … … 68 62 } else { 69 63 (view_agg__div__transactionCached = 70 new ViewAgg_Div_Transaction({ 71 type: type, 72 amount: amount, 73 name: name, 74 desc: desc, 75 info: info, 76 fields: fields 77 })).$el.appendTo($elSpan); 64 new ViewAgg_Div_Transaction({ 65 type: $elSpan 66 .attr( 67 'data-plugin-rainbow-pay-press-type') 68 || 'test', 69 amount: $elSpan 70 .attr( 71 'data-plugin-rainbow-pay-press-amount'), 72 name: $elSpan 73 .attr( 74 'data-plugin-rainbow-pay-press-name'), 75 desc: $elSpan 76 .attr( 77 'data-plugin-rainbow-pay-press-desc'), 78 info: $elSpan 79 .attr( 80 'data-plugin-rainbow-pay-press-info'), 81 fields: $elSpan 82 .attr( 83 'data-plugin-rainbow-pay-press-fields'), 84 handle: $elSpan 85 .attr( 86 'data-plugin-rainbow-pay-press-handle') 87 })).$el.appendTo($elSpan); 78 88 } 79 89 }); -
rainbowpaypress/trunk/js/le_requirejs/public/model_info__stripe_checkout.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/model_info__stripe_checkout.js -
rainbowpaypress/trunk/js/le_requirejs/public/model_info__transaction_details.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/model_info__transaction_details.js … … 33 33 34 34 35 define([' backbone',36 ' jquery',35 define(['jquery', 36 'model_info__details_base', 37 37 'model_orig__app_common', 38 38 'public/model_orig__app_public', 39 ], function(backbone, $, model_orig__app_common, model_orig__app_public) { 39 ], function($, 40 ModelInfo_DetailsBase, 41 model_orig__app_common, 42 model_orig__app_public) { 40 43 41 return backbone.Model.extend({44 return ModelInfo_DetailsBase.extend({ 42 45 43 46 defaults: { … … 49 52 'customer_name': null, 50 53 'customer_phone': null, 54 'handle': null, 51 55 'shipping_address': null 52 },53 54 doCheckForFieldsWithMissingValues: function(model_orig__fields) {55 var arrFieldsRequired = model_orig__fields.getFieldsRequired();56 arrFieldsWithMissingValues = [];57 58 for (var i = 0; i < arrFieldsRequired.length; i++) {59 var field = arrFieldsRequired[i];60 var value = this.attributes[field];61 if (!value) {62 arrFieldsWithMissingValues.push(field);63 }64 }65 66 this.trigger('fields_with_missing_values', {67 fields: arrFieldsWithMissingValues68 });69 70 return arrFieldsWithMissingValues.length > 0 && true;71 56 }, 72 57 … … 74 59 var $xhr = $.post 75 60 (model_orig__app_common.get('ajax_url'), { 76 action: 'rainbow_pay_press__submit', 77 type: this.attributes['type'], 78 charge_description: this.attributes 79 ['charge_description'], 80 charge_amount: this.attributes['charge_amount'], 81 stripe_token_id: this.attributes['stripe_token_id'], 82 stripe_email: this.attributes['stripe_email'], 83 customer_name: this.attributes['customer_name'], 84 customer_phone: this.attributes['customer_phone'], 85 shipping_address: this.attributes['shipping_address'] 61 'action': 'rainbow_pay_press__submit', 62 'data': window.encodeURIComponent( 63 window.JSON.stringify({ 64 'type': this.attributes 65 ['type'], 66 'handle': this.attributes 67 ['handle'], 68 'stripe_token_id': this.attributes 69 ['stripe_token_id'], 70 'stripe_email': this.attributes 71 ['stripe_email'], 72 'customer_name': this.attributes 73 ['customer_name'], 74 'customer_phone': this.attributes 75 ['customer_phone'], 76 'shipping_address': this.attributes 77 ['shipping_address'] 78 })) 86 79 }), 87 80 me = this; … … 91 84 92 85 me.trigger('xhr__always__rainbow_pay_press__submit', { 93 success: objData && objData.success 86 errors: objData && objData['errors'], 87 success: objData && objData['success'], 88 transaction: objData && objData['transaction'], 89 disallowed_reason: 90 objData && objData['disallowed_reason'] 94 91 }); 95 92 }); -
rainbowpaypress/trunk/js/le_requirejs/public/model_orig__app_public.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/model_orig__app_public.js -
rainbowpaypress/trunk/js/le_requirejs/public/model_orig__fields.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/model_orig__fields.js -
rainbowpaypress/trunk/js/le_requirejs/public/view_agg__div__transaction.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/view_agg__div__transaction.js … … 35 35 define(['backbone', 36 36 'jquery', 37 'util', 37 38 'public/model_info__stripe_checkout', 38 39 'public/model_info__transaction_details', … … 41 42 ], function(backbone, 42 43 $, 44 util, 43 45 model_info__stripe_checkout, 44 46 ModelInfo_TransactionDetails, … … 54 56 // @param params.name Name of the seller 55 57 // @param params.desc Product description 58 // @param params.handle Item handle. 56 59 // @param params.info Miscellaneous additional information 57 60 initialize: function(params) { … … 72 75 'type': params.type, 73 76 'charge_description': params.desc, 74 'charge_amount': params.amount 77 'charge_amount': params.amount, 78 'handle': params.handle 75 79 }); 76 80 … … 99 103 }); 100 104 this.$el.text( 101 "Your transaction has been submitted successfully. Your confirmation code is: " 102 + model_info__transaction_details.get('stripe_token_id')) 105 "Your transaction has been submitted successfully on: " 106 + util.getDateRepr( 107 util.parseDate( 108 event.transaction['created'])) 109 + " Your confirmation code is: " 110 + model_info__transaction_details 111 .get('stripe_token_id')) 103 112 .append('<br>') 104 113 .append($buttonAnotherTransaction); 114 } else { 115 if (event.errors && 116 event.errors.indexOf('error__item_disallowed') >= 0) { 117 118 var strErrorDisallowed = 119 "Your transaction could not be submitted because this item has been marked as disallowed for purchase."; 120 121 if (event.disallowed_reason) { 122 strErrorDisallowed += "Disallowed reason: "; 123 strErrorDisallowed += event.disallowed_reason; 124 } 125 126 window.alert(strErrorDisallowed); 127 return; 128 } 129 130 var strError = 131 "Your transaction could not be submitted due to server-side error(s). Contact support."; 132 133 if (event.errors) { 134 strError += " Actual errors reported: "; 135 strError += event.errors.join(' '); 136 } 137 138 window.alert(strError); 105 139 } 106 140 }); -
rainbowpaypress/trunk/js/le_requirejs/public/view_agg__table__transaction_details.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/public/view_agg__table__transaction_details.js … … 54 54 ViewAgg_Table.prototype.initialize.apply(this, arguments); 55 55 56 this.$el.addClass('widget_view_agg__table__transaction_details'); 57 58 56 59 var model_info__transaction_details = params 57 60 .model_info__transaction_details, … … 59 62 60 63 (new ViewAgg_Tr_TransactionDetail({ 61 model_info__ transaction_details: model_info__transaction_details,64 model_info__details_base: model_info__transaction_details, 62 65 field: 'type', 63 66 name: "Stripe transaction type:" … … 65 68 66 69 (new ViewAgg_Tr_TransactionDetail({ 67 model_info__ transaction_details: model_info__transaction_details,70 model_info__details_base: model_info__transaction_details, 68 71 field: 'charge_description', 69 72 name: "Description:" … … 79 82 (new ViewAgg_Tr_TransactionDetail({ 80 83 callback_format_value: util.formatCurrency, 81 model_info__ transaction_details: model_info__transaction_details,84 model_info__details_base: model_info__transaction_details, 82 85 field: 'charge_amount', 83 86 name: "Puchase amount:" … … 90 93 name: "Stripe token id:", 91 94 name_seller: params.name, 92 text_enter: "Enter credit card info ",93 text_modify: "Modify "95 text_enter: "Enter credit card info...", 96 text_modify: "Modify..." 94 97 })).$el.appendTo(this.$el); 95 98 … … 100 103 name: "Stripe card email:", 101 104 name_seller: params.name, 102 text_enter: "Enter credit card info ",103 text_modify: "Modify "105 text_enter: "Enter credit card info...", 106 text_modify: "Modify..." 104 107 })).$el.appendTo(this.$el); 105 108 106 109 (new ViewAgg_Tr_TransactionDetail({ 107 model_info__ transaction_details:110 model_info__details_base: 108 111 model_info__transaction_details, 109 112 field: 'customer_name', 110 113 name: "Customer name:", 111 text_enter: "Enter customer name ",112 text_modify: "Modify "114 text_enter: "Enter customer name...", 115 text_modify: "Modify..." 113 116 })).$el.appendTo(this.$el); 114 117 115 118 if (model_orig__fields.get('flag_query_phone')) { 116 119 (new ViewAgg_Tr_TransactionDetail({ 117 model_info__ transaction_details:120 model_info__details_base: 118 121 model_info__transaction_details, 119 122 field: 'customer_phone', 120 123 name: "Customer phone:", 121 text_enter: "Enter customer phone ",122 text_modify: "Modify "124 text_enter: "Enter customer phone...", 125 text_modify: "Modify..." 123 126 })).$el.appendTo(this.$el); 124 127 } … … 126 129 if (model_orig__fields.get('flag_query_shipping')) { 127 130 (new ViewAgg_Tr_TransactionDetail({ 128 model_info__ transaction_details:131 model_info__details_base: 129 132 model_info__transaction_details, 130 133 field: 'shipping_address', 131 134 name: "Shipping address:", 132 text_enter: "Enter shipping address ",133 text_modify: "Modify "135 text_enter: "Enter shipping address...", 136 text_modify: "Modify..." 134 137 })).$el.appendTo(this.$el); 135 138 } 136 139 137 140 138 var $buttonSubmit = $('<button>').text("Submit") .appendTo(this.$el);141 var $buttonSubmit = $('<button>').text("Submit"); 139 142 140 143 $('<tr>').append($('<td>').attr('colspan', '2').append($buttonSubmit)) … … 184 187 185 188 if (model_info__transaction_details 186 .doCheckForFieldsWithMissingValues(model_orig__fields)) { 189 .doCheckForFieldsWithMissingValues( 190 model_orig__fields 191 .getFieldsRequired())) { 187 192 window.alert("Please specify the required information by clicking on the links in red."); 188 193 return; -
rainbowpaypress/trunk/js/le_requirejs/public/view_agg__tr__transaction_detail.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__transaction_detail.js … … 34 34 35 35 36 define(['backbone', 37 'jquery' 38 ], function (backbone, $) { 36 define(['view_agg__tr__detail_base'], function (ViewAgg_Tr_DetailBase) { 39 37 40 return backbone.View.extend({ 41 tagName: 'tr', 38 return ViewAgg_Tr_DetailBase.extend({ 42 39 43 40 // @param params.callback_format_value 44 41 // Optional value formatting callback. 45 // @param params.model_info__ transaction_details42 // @param params.model_info__details_base 46 43 // @param params.field 47 44 // @param params.name The name of this detail. … … 52 49 // value. 53 50 initialize: function(params) { 54 this.$el.addClass('widget_view_agg__tr__transaction_detail');55 51 56 var $aModify = params.text_enter 57 ? $('<a>').attr('href', '#') 58 : null; 52 ViewAgg_Tr_DetailBase.prototype.initialize.apply(this, arguments); 59 53 60 54 61 this.get$aModify = function() { 62 return $aModify; 63 }; 64 65 66 var $divValue = $('<div>'); 67 68 var $tdValue = $("<td width='66%'>").append(params.text 69 ? $('<span>').text(params.text) 70 : null) 71 .append($divValue); 72 73 74 var $divBottom = $('<div>').appendTo($tdValue); 75 76 this.get$divBottom = function() { 77 return $divBottom; 78 }; 79 80 81 if ($aModify) $aModify.appendTo($divBottom); 82 83 this.$el.append($("<td width='34%'>").text(params.name)) 84 .append($tdValue); 85 86 if ($aModify) { 87 var me = this; 88 89 $aModify.click(function(event) { 90 event.preventDefault(); 91 92 me.trigger('click_modify'); 93 }); 94 } 95 96 97 var field = params.field, 98 model_info__transaction_details = params.model_info__transaction_details; 99 100 if (model_info__transaction_details) { 101 this.on('click_modify', function() { 102 model_info__transaction_details.trigger('do_prompt', {field: field}); 103 }, this); 104 } 105 106 function _updateValue() { 107 var value = model_info__transaction_details.get(field); 108 109 if (params.callback_format_value) { 110 value = params.callback_format_value(value); 111 } 112 113 $divValue.text(value || ""); 114 115 if ($aModify) { 116 $aModify.text(value ? params.text_modify || params.text_enter 117 : params.text_enter); 118 if (value) { 119 $aModify.css('color', ""); 120 } 121 } 122 } 123 124 if (model_info__transaction_details) { 125 _updateValue.call(this); 126 127 this.listenTo(model_info__transaction_details, 128 'change:' + field, 129 _updateValue); 130 131 this.listenTo( 132 model_info__transaction_details, 133 'fields_with_missing_values', 134 function(event) { 135 if ($aModify && event.fields.indexOf(field) >= 0) { 136 $aModify.css('color', 'red'); 137 } 138 }); 139 } 55 this.$el.addClass('widget_view_agg__tr__transaction_detail'); 140 56 } 141 57 }); -
rainbowpaypress/trunk/js/le_requirejs/public/view_agg__tr__transaction_detail__stripe.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/admin/view_agg__tr__transaction_detail__stripe.js … … 45 45 // @param params.name_seller Name of the seller 46 46 initialize: function(params) { 47 ViewAgg_Tr_TransactionDetail.prototype.initialize.apply(this, arguments); 47 ViewAgg_Tr_TransactionDetail.prototype.initialize.call(this, { 48 model_info__details_base: params && 49 params.model_info__transaction_details, 50 field: params && 51 params.field, 52 name: params && 53 params.name, 54 name_seller: params && 55 params.name_seller, 56 text_enter: params && 57 params.text_enter, 58 text_modify: params && 59 params.text_modify 60 }); 48 61 49 62 -
rainbowpaypress/trunk/js/le_requirejs/underscore-private.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/underscore-private.js -
rainbowpaypress/trunk/js/le_requirejs/util.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/util.js … … 45 45 } 46 46 47 var strCents = "" + amount % 100; 47 var amountAbs = window.Math.abs(amount); 48 49 var strCents = "" + amountAbs % 100; 48 50 if (strCents.length == 1) strCents = '0' + strCents; 49 51 50 return '$' + _formatDollars(Math.floor(amount / 100)) + '.' + strCents; 52 return (amount < 0 ? '-' : "") + '$' 53 + _formatDollars(Math.floor(amountAbs / 100)) 54 + '.' + strCents; 55 } 56 57 function _getDigits(num, len) { 58 var str = "" + num; 59 while (str.length < len) { 60 str = '0' + str; 61 } 62 return str; 63 } 64 65 function _getDateComponents(date) { 66 if (!date) return null; 67 68 return { 69 year: date.getFullYear(), 70 month: _getDigits(date.getMonth() + 1, 2), 71 day: _getDigits(date.getDate(), 2), 72 hour: _getDigits(date.getHours(), 2), 73 min: _getDigits(date.getMinutes(), 2), 74 sec: _getDigits(date.getSeconds(), 2), 75 msec: _getDigits(date.getMilliseconds(), 3) 76 }; 77 } 78 79 function _getDateReprTZName(date) { 80 var arrMatchTZ = date && date.toString().match(/\([^)]+\)/g); 81 return arrMatchTZ && arrMatchTZ.length == 1 && arrMatchTZ[0] || ""; 82 } 83 84 function _getDateStrings(date) { 85 86 var date_components = _getDateComponents(date); 87 if (!date_components) return null; 88 89 function _getWeekday() { 90 return (['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])[date.getDay()]; 91 } 92 93 return { 94 'weekday': _getWeekday(), 95 'date': date_components.year + '-' + date_components.month 96 + '-' + date_components.day, 97 'time': date_components.hour + ':' + date_components.min 98 + ':' + date_components.sec, 99 'tz': _getDateReprTZName(date) 100 }; 101 } 102 103 // This will parse a date string in the format "2016-04-03 05:10:41" that is assumed to 104 // be in UTC time. 105 function _parseDate(strDate) { 106 if (!strDate) return null; 107 108 var arrParts = strDate.split(' '); 109 return new Date(arrParts[0] + 'T' + arrParts[1] + 'Z'); 51 110 } 52 111 53 112 return { 54 formatCurrency: _formatCurrency 113 formatCurrency: _formatCurrency, 114 getDateStrings: _getDateStrings, 115 parseDate: _parseDate, 116 117 118 getDateRepr: function(date) { 119 120 var date_strings = _getDateStrings(date); 121 if (!date_strings) return null; 122 123 return date_strings.weekday + ' ' + date_strings.date 124 + ' ' + date_strings.time 125 + ' ' + date_strings.tz; 126 } 55 127 }; 56 128 }); -
rainbowpaypress/trunk/js/le_requirejs/view_agg__table.js
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/js/le_requirejs/view_agg__table.js … … 40 40 initialize: function() { 41 41 42 this.$el.attr({'border': '0', 42 this.$el.addClass('widget_view_agg__table plugin_rainbow_payment_press') 43 .attr({'border': '0', 43 44 'cellspacing': '0', 44 45 'cellpadding': '0'}); -
rainbowpaypress/trunk/readme.txt
r1385818 r1391844 4 4 Requires at least: 3.8.1 5 5 Tested up to: 4.4.2 6 Stable tag: 2.3.06 Stable tag: 3.0.0 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 50 50 Currently only USD are supported. 51 51 52 Demo at: http://maratbn.com/projects/rainbow-pay-press/#demo 53 52 54 Technical summary and special considerations: 53 55 … … 80 82 https://wordpress.org/plugins/rainbowpaypress 81 83 https://github.com/maratbn/RainbowPayPress 84 http://maratbn.com/projects/rainbow-pay-press 82 85 83 86 … … 128 131 == Changelog == 129 132 133 = 3.0.0 = 134 * Fixed another date parsing bug that effected Firefox. 135 * Database schema has been modified. Table 'plugin_rainbow_pay_press_transactions' fields 136 'customer_name' and 'customer_phone' are now allowed to be NULL. If upgrading, user should 137 examine the table schema to verify that these fields are now allowed to be NULL, and if not, 138 alter the table manually to allow these fields to be NULL. User can use the Adminer plugin to 139 accomplish this. Alternatively, user can disable the plugin, backup the data in the table, 140 delete the table, and re-enable the plugin to create the table anew. 141 * Entity name is now specified in the global RainbowPayPress configuration rather than in each 142 shortcode. 143 * Fixed bug with resetting configuration settings to empty strings. 144 * Shortcode syntax has changed. Instead of specifying the cost amount and description of each item 145 in the shortcode, now only a pre-configured item handle is specified. Upon upgrading, users will 146 need to manually create the appropriate item records in the Items configuration, and to update 147 their shortcodes to include handles to their items. 148 * Shortcode syntax has changed. The previous shortcode parameter 'fields' has been renamed to 149 'override_fields'. Upon upgrading, users will need to manually modify their shortcodes to comply 150 with this latest parameter name. 151 130 152 = 2.3.0 = 131 153 * For better reliability and better server-side performance, loading the plugin's JavaScript logic -
rainbowpaypress/trunk/style.css
r1385818 r1391844 5 5 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 6 6 7 Version: 2.4.0-development_unreleased7 Version: 3.1.0-development_unreleased 8 8 9 9 Module: rainbowpaypress/style.css … … 30 30 31 31 32 .plugin_rainbow_payment_press.widget_view_agg__table td { 33 margin-right: 1em; 34 } 35 .plugin_rainbow_payment_press.widget_view_agg__table td:last-child { 36 margin-right: 0em; 37 } 38 39 40 .widget_view_agg__button__add_new_item { 41 font-weight: bold; 42 } 43 44 .widget_view_agg__table__items th, 45 .widget_view_agg__table__items td, 32 46 .widget_view_agg__table__transactions th, 33 47 .widget_view_agg__table__transactions td { 34 48 padding: 2px 5px; 35 49 } 50 51 52 .widget_view_agg__table__items .item--even, 53 .widget_view_agg__table__transactions .transaction--even { 54 background-color: #eee; 55 } 56 .widget_view_agg__table__items .item--odd, 57 .widget_view_agg__table__transactions .transaction--odd { 58 background-color: #ddd; 59 }
Note: See TracChangeset
for help on using the changeset viewer.