From cb1c6d2db9c45b4bb88677f4638748d3a26450ae Mon Sep 17 00:00:00 2001 From: Dmitry Fedyuk Date: Thu, 16 Feb 2017 15:05:43 +0300 Subject: [PATCH] no message --- view/frontend/web/main.js | 124 ++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 65 deletions(-) diff --git a/view/frontend/web/main.js b/view/frontend/web/main.js index 3b67fb8..a40fb87 100644 --- a/view/frontend/web/main.js +++ b/view/frontend/web/main.js @@ -38,70 +38,64 @@ define([ Stripe.setPublishableKey(this.publicKey()); return this; }, - /** + + /** + * 2017-02-16 * @override - * @see https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js#L127-L159 - * @used-by https://github.com/magento/magento2/blob/2.1.0/lib/web/knockoutjs/knockout.js#L3863 - * @param {this} _this - */ - placeOrder: function(_this) { - if (this.validate()) { - if (!this.isNewCardChosen()) { - /** - * 2016-08-23 - * Идентификаторы карт начинаются с приставки «card_» - * (например: «card_18lGFRFzKb8aMux1Bmcjsa5L»), - * а идентификаторы токенов — с приставки «tok_» - * (например: «tok_18lWSWFzKb8aMux1viSqpL5X»), - * тем самым по приставке мы можем отличить карты от токенов, - * и поэтому для карт и токенов мы можем использовать одну и ту же переменную. - */ - this.token = this.currentCard(); - this.placeOrderInternal(); - } - else { - // 2016-03-02 - // https://stripe.com/docs/custom-form#step-2-create-a-single-use-token - /** - * 2016-03-07 - * https://support.stripe.com/questions/which-cards-and-payment-types-can-i-accept-with-stripe - * Which cards and payment types can I accept with Stripe? - * With Stripe, you can charge almost any kind of credit or debit card: - * U.S. businesses can accept: - * Visa, MasterCard, American Express, JCB, Discover, and Diners Club. - * Australian, Canadian, European, and Japanese businesses can accept: - * Visa, MasterCard, and American Express. - */ - Stripe.card.createToken( - { - cvc: this.creditCardVerificationNumber() - ,exp_month: this.creditCardExpMonth() - ,exp_year: this.creditCardExpYear() - // 2017-02-16 - // https://stripe.com/docs/stripe.js#card-createToken - ,name: this.cardholder() - ,number: this.creditCardNumber() - }, - /** - * 2016-03-02 - * @param {Number} status - * @param {Object} response - */ - function(status, response) { - if (200 === status) { - // 2016-03-02 - // https://stripe.com/docs/custom-form#step-3-sending-the-form-to-your-server - _this.token = response.id; - _this.placeOrderInternal(); - } - else { - // 2016-03-02 - // https://stripe.com/docs/api#errors - _this.showErrorMessage(response.error.message); - } - } - ); - } - } - } + * @see ... + * @used-by placeOrder() + * @param {Object|Number} status + * @returns {Boolean} + */ + tokenCheckStatus: function(status) {return 200 === status;}, + + /** + * 2017-02-16 + * @override + * @see ... + * @used-by placeOrder() + * @param {Object} params + * @param {Function} callback + * @returns {Function} + */ + tokenCreate: function(params, callback) {return Stripe.card.createToken(params, callback);}, + + /** + * 2017-02-16 + * https://stripe.com/docs/api#errors + * @override + * @see ... + * @used-by placeOrder() + * @param {Object|Number} status + * @param {Object} resp + * @returns {String} + */ + tokenErrorMessage: function(status, resp) {return resp.error.message;}, + + /** + * 2017-02-16 + * @override + * @see ... + * @used-by placeOrder() + * @param {Object} resp + * @returns {String} + */ + tokenFromResponse: function(resp) {return resp.id;}, + + /** + * 2017-02-16 + * @override + * @see ... + * @used-by placeOrder() + * @returns {Object} + */ + tokenParams: function() {return { + cvc: this.creditCardVerificationNumber() + ,exp_month: this.creditCardExpMonth() + ,exp_year: this.creditCardExpYear() + // 2017-02-16 + // https://stripe.com/docs/stripe.js#card-createToken + ,name: this.cardholder() + ,number: this.creditCardNumber() + };} });}); \ No newline at end of file