Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Feb 16, 2017
1 parent f8520ee commit cb1c6d2
Showing 1 changed file with 59 additions and 65 deletions.
124 changes: 59 additions & 65 deletions view/frontend/web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};}
});});

0 comments on commit cb1c6d2

Please sign in to comment.