Skip to content

Instantly share code, notes, and snippets.

@snez
Created November 24, 2016 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snez/c5939edb12d6dd518d46d8141f27c7b0 to your computer and use it in GitHub Desktop.
Save snez/c5939edb12d6dd518d46d8141f27c7b0 to your computer and use it in GitHub Desktop.
Stripe.js patch for SoftProdigy EnhancedCheckout 1.0.1
diff --git a/skin/frontend/default/default/js/softprodigy/checkout/opcheckout.js b/skin/frontend/default/default/js/softprodigy/checkout/opcheckout.js
index cf0d759..afc2423 100644
--- a/skin/frontend/default/default/js/softprodigy/checkout/opcheckout.js
+++ b/skin/frontend/default/default/js/softprodigy/checkout/opcheckout.js
@@ -95,6 +95,15 @@ Checkout.prototype = {
var url = this.blocks[stepId].url;
var data = this.getStepValues(stepId);
data['blocks'] = this.getBlocksToReloadByType(stepId);
+ if (typeof payment != 'undefined' && payment.currentMethod == 'cryozonic_stripe')
+ {
+ delete data['payment[cc_owner]'];
+ delete data['payment[cc_type]'];
+ delete data['payment[cc_number]'];
+ delete data['payment[cc_exp_month]'];
+ delete data['payment[cc_exp_year]'];
+ delete data['payment[cc_cid]'];
+ }
new Ajax.Request(
url,
{
@@ -171,6 +180,11 @@ Checkout.prototype = {
return true;
},
+ isCryozonicStripeMethodSelected: function() {
+ return document.getElementById("p_method_cryozonic_stripe") &&
+ document.getElementById("p_method_cryozonic_stripe").checked == true;
+ },
+
saveOrder: function(){
if(this.saveOrderProccessing){
this.saveOrderProccessing = false;
@@ -183,37 +197,57 @@ Checkout.prototype = {
if(!this.validateCheckout()){
return false;
}
- new Ajax.Request(
- $(this.checkoutForm).action,
- {
- method: 'post',
- parameters: Form.serialize($(this.checkoutForm)),
- onLoading: function(){
- this.setLoadWaiting();
- }.bind(this),
- onComplete: function(){
- this.resetLoadWaiting();
- }.bind(this),
- onSuccess: function(transport){
- this.resetLoadWaiting();
- this.saveOrderProccessing = false;
- if(transport.responseText.isJSON()){
- var data = transport.responseText.evalJSON();
- if(typeof data.redirect != 'undefined' && data.success){
- location.href = data.redirect;
- return;
- }
- if(data.success){
- location.href = this.successUrl;
- return;
- }
- if(data.error){
- this.updateContents({'error': data.error}, true);
+
+ var self = this;
+ var proceed = function()
+ {
+ new Ajax.Request(
+ $(self.checkoutForm).action,
+ {
+ method: 'post',
+ parameters: Form.serialize($(self.checkoutForm)),
+ onLoading: function(){
+ self.setLoadWaiting();
+ }.bind(self),
+ onComplete: function(){
+ self.resetLoadWaiting();
+ }.bind(self),
+ onSuccess: function(transport){
+ self.resetLoadWaiting();
+ self.saveOrderProccessing = false;
+ if(transport.responseText.isJSON()){
+ var data = transport.responseText.evalJSON();
+ if(typeof data.redirect != 'undefined' && data.success){
+ location.href = data.redirect;
+ return;
+ }
+ if(data.success){
+ location.href = self.successUrl;
+ return;
+ }
+ if(data.error){
+ self.updateContents({'error': data.error}, true);
+ }
}
- }
- }.bind(this)
- }
- );
+ }.bind(self)
+ }
+ );
+ };
+
+ if (this.isCryozonicStripeMethodSelected())
+ {
+ createStripeToken(function(err)
+ {
+ if (err)
+ alert(err);
+ else
+ proceed();
+ });
+ }
+ else
+ {
+ proceed();
+ }
},
getBlocksToReloadByType: function(type){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment