Last active
June 30, 2021 18:35
-
-
Save snez/ad9b91c0049f96f78fb6d409c396ba2c to your computer and use it in GitHub Desktop.
Stripe.js patch for Olegnax OneStepCheckout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/olegnax_osc/osc_form.js b/js/olegnax_osc/osc_form.js | |
index 2030f11..e093e31 100644 | |
--- a/js/olegnax_osc/osc_form.js | |
+++ b/js/olegnax_osc/osc_form.js | |
@@ -915,10 +915,22 @@ OnestepcheckoutForm.prototype = { | |
classThis.placeOrderButton.addClassName(classThis.disabledClassName); | |
classThis.placeOrderButton.disabled = true; | |
- new Ajax.Request(classThis.placeOrderUrl, { | |
- method: 'post', | |
- parameters: Form.serialize(classThis.form.form, true), | |
- onComplete: classThis.onComplete.bindAsEventListener(classThis) | |
+ createStripeToken(function(err) | |
+ { | |
+ if (err) | |
+ { | |
+ cryozonic.displayCardError(err); | |
+ classThis.turnOnPlaceOrderButton(); | |
+ classThis.overlay.hide(); | |
+ } | |
+ else | |
+ { | |
+ new Ajax.Request(classThis.placeOrderUrl, { | |
+ method: 'post', | |
+ parameters: Form.serialize(classThis.form.form, true), | |
+ onComplete: classThis.onComplete.bindAsEventListener(classThis) | |
+ }); | |
+ } | |
}); | |
} | |
}); | |
@@ -1360,4 +1372,4 @@ OnestepcheckoutAddress.prototype = { | |
afterFinish: function(){ delete el.effect; complateFunctionFn(); } | |
}); | |
} | |
-}; | |
\ No newline at end of file | |
+}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way of making a "before" and "after"
At the original code on "js/olegnax_osc/osc_form.js" from lines 918 to 925 I have this code:
new Ajax.Request(classThis.placeOrderUrl, { method: 'post', parameters: Form.serialize(classThis.form.form, true), onComplete: classThis.onComplete.bindAsEventListener(classThis) }); } }); }
If I change to your lines it stays like this from lines 918 to 933:
`createStripeToken(function(err)
This will not work, because my module is Stripe's official module and your mod is made to
Cryozonic's module. I have tried to change "cryozonic.displayCardError(err);" to "stripe.displayCardError(err);"
but it did not work neither...
Regards