KR.onSubmit()
DESCRIPTION
KR.onSubmit() allows to intercept information about the authorized transaction before the form makes a POST to the URL defined with kr-post-success-url.
The callback receives an object with 2 parameters:
- KR: Reference to the library
- event: Object that contains the newly created transaction.
The object contained in event is the same as the one posted by the form. For more details, go here: return to the store .
The behavior varies depending on the boolean returned by your function:
Return value | Behavior |
---|---|
true | The JavaScript client performs a POST on kr-post-success-url. |
false | The POST with kr-post-success-url is not made. You manage the post-payment action yourself. |
Example of integration
https://github.com/lyra/rest-php-examples/blob/master/www/js_examples/jquery/minimalEmbeddedForm.onSubmit.php#L70-L85
<script type="text/javascript"> $(document).ready(function() { KR.onSubmit( function(event) { /* Change the button label to the orderStatus */ $(".kr-payment-button > span:first").html(event.clientAnswer.orderStatus); $(".kr-spinner").hide(); $(".kr-payment-button > span:first").show(); /* return values: * true: kr-post-success-url is called using POST * false: kr-post-success-url is not called, execution stops. */ return false; }); }); </script>