diff --git a/.gitignore b/.gitignore index 1c3e58b..15a8f89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .DS_Store -*.log \ No newline at end of file +*.log +*.orig \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 246e534..dbb2d2f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,27 +5,46 @@ module.exports = function (grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), + meta: { + banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */\n" + }, jshint: { all: { - src: [ "src/*.js", "test/*.js" ], + src: ["src/*.js", "test/spec/*.js"], options: { jshintrc: ".jshintrc" } } }, + concat: { + dist: { + src: ["", "src/paypal-button.js"], + dest: "dist/paypal-button.js", + options: { + banner: "<%= meta.banner %>" + } + }, + bundled: { + src: ["<%= meta.banner %>", "lib/MiniCart/src/minicart.js", "src/paypal-button.js"], + dest: "dist/paypal-button-minicart.js", + options: { + banner: "<%= meta.banner %>" + } + } + }, uglify: { dist: { - src: [ "", "src/paypal-button.js" ], + src: [ "<%= meta.banner %>", "src/paypal-button.js" ], dest: "dist/paypal-button.min.js", options: { - banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd, h:MM:ss TT\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */" + banner: "<%= meta.banner %>" } }, bundled: { - src: [ "", "lib/MiniCart/minicart.js", "src/paypal-button.js" ], + src: [ "<%= meta.banner %>", "lib/MiniCart/src/minicart.js", "src/paypal-button.js" ], dest: "dist/paypal-button-minicart.min.js", options: { - banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd, h:MM:ss TT\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */" + banner: "<%= meta.banner %>" } } } @@ -34,8 +53,10 @@ module.exports = function (grunt) { // Load grunt tasks from npm packages grunt.loadNpmTasks("grunt-contrib-jshint"); grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-concat"); + grunt.loadNpmTasks('grunt-update-submodules'); // Default task. - grunt.registerTask("default", ["jshint", "uglify"]); + grunt.registerTask("default", ["jshint", "update_submodules", "concat", "uglify"]); }; diff --git a/README.md b/README.md index 1361a96..b1d4a13 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,20 @@ All of PayPal's [HTML button variables](https://cms.paypal.com/us/cgi-bin/?cmd=_ * `data-name` Description of the item. * `data-number` The number of the item. * `data-amount` The price of the item. +* `data-currency` The currency of the item (note: these cannot be mixed). * `data-quantity` Quantity of items to purchase. * `data-shipping` The cost of shipping this item. * `data-tax` Transaction-based tax override variable. * `data-size` For button images: `small` and `large` work. For QR codes enter the pixel length of the longest side. +* `data-locale` The desired locale of the PayPal site. +* `data-callback` The IPN notify URL to be called on completion of the transaction. + ## Editable fields Creating editable fields is easy! Just add `-editable` to the name of your variable, e.g. `data-quantity-editable`, and an input field will magically appear for your users. +## Callback notification +On completion of a transaction you can get a payment notification ([IPN](https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro)) on a callback URL you specify using the `data-callback` attribute. An [IPN simulator](https://developer.paypal.com/webapps/developer/applications/ipn_simulator) is available on the sandbox. ## Localization * Changing the default language of a button can be done by setting the variable `data-lc` with the correct locale code, e.g. es_ES. diff --git a/dist/paypal-button-minicart.js b/dist/paypal-button-minicart.js new file mode 100644 index 0000000..742bd31 --- /dev/null +++ b/dist/paypal-button-minicart.js @@ -0,0 +1,2103 @@ +/*! + * PayPalJSButtons + * JavaScript integration for PayPal's payment buttons + * @version 1.0.1 - 2013-03-30 + * @author Jeff Harrell + */ +/*! + * MiniCart + * + * Improve your PayPal integration by creating an overlay which appears as a user adds products to their cart. + * + * @version 2.5.0 - 2012-12-02, 1:04:43 PM + * @author Jeff Harrell + * @url http://www.minicartjs.com/ + * @license > + */ +if (typeof PAYPAL === 'undefined' || !PAYPAL) { + var PAYPAL = {}; +} + +PAYPAL.apps = PAYPAL.apps || {}; + + +(function () { + 'use strict'; + + /** + * Default configuration + */ + var config = { + /** + * The parent element the cart should "pin" to + */ + parent: document.body, + + /** + * Edge of the window to pin the cart to + */ + displayEdge: 'right', + + /** + * Distance from the edge of the window + */ + edgeDistance: '50px', + + /** + * HTML target property for the checkout form + */ + formTarget: null, + + /** + * The base path of your website to set the cookie to + */ + cookiePath: '/', + + /** + * The number of days to keep the cart data + */ + cartDuration: 30, + + /** + * Strings used for display text + */ + strings: { + button: '', + subtotal: '', + discount: '', + shipping: '', + processing: '' + }, + + /** + * Unique ID used on the wrapper element + */ + name: 'PPMiniCart', + + /** + * Boolean to determine if the cart should "peek" when it's hidden with items + */ + peekEnabled: true, + + /** + * The URL of the PayPal website + */ + paypalURL: 'https://www.paypal.com/cgi-bin/webscr', + + /** + * The base URL to the visual assets + */ + assetURL: 'http://www.minicartjs.com/build/', + + events: { + /** + * Custom event fired before the cart is rendered + */ + onRender: null, + + /** + * Custom event fired after the cart is rendered + */ + afterRender: null, + + /** + * Custom event fired before the cart is hidden + * + * @param e {event} The triggering event + */ + onHide: null, + + /** + * Custom event fired after the cart is hidden + * + * @param e {event} The triggering event + */ + afterHide: null, + + /** + * Custom event fired before the cart is shown + * + * @param e {event} The triggering event + */ + onShow: null, + + /** + * Custom event fired after the cart is shown + * + * @param e {event} The triggering event + */ + afterShow: null, + + /** + * Custom event fired before a product is added to the cart + * + * @param data {object} Product object + */ + onAddToCart: null, + + /** + * Custom event fired after a product is added to the cart + * + * @param data {object} Product object + */ + afterAddToCart: null, + + /** + * Custom event fired before a product is removed from the cart + * + * @param data {object} Product object + */ + onRemoveFromCart: null, + + /** + * Custom event fired after a product is removed from the cart + * + * @param data {object} Product object + */ + afterRemoveFromCart: null, + + /** + * Custom event fired before the checkout action takes place + * + * @param e {event} The triggering event + */ + onCheckout: null, + + /** + * Custom event fired before the cart is reset + */ + onReset: null, + + /** + * Custom event fired after the cart is reset + */ + afterReset: null + } + }; + + + if (!PAYPAL.apps.MiniCart) { + + /** + * Mini Cart application + */ + PAYPAL.apps.MiniCart = (function () { + + var minicart = {}, + isShowing = false, + isRendered = false; + + + /** PRIVATE **/ + + /** + * PayPal form cmd values which are supported + */ + var SUPPORTED_CMDS = { _cart: true, _xclick: true }; + + + /** + * The form origin that is passed to PayPal + */ + var BN_VALUE = 'MiniCart_AddToCart_WPS_US'; + + + /** + * Regex filter for cart settings, which appear only once in a cart + */ + var SETTING_FILTER = /^(?:business|currency_code|lc|paymentaction|no_shipping|cn|no_note|invoice|handling_cart|weight_cart|weight_unit|tax_cart|page_style|image_url|cpp_|cs|cbt|return|cancel_return|notify_url|rm|custom|charset)/; + + + /** + * Adds the cart's CSS to the page in a