one page checkout javascript issues

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hello,

Having a problem with the one page checkout. I am creating a new payment plugin for Paij payment solution. Their API uses an externally hosted js file at their site. When I click the button to go from shipping info to payment info I get the error "Uncaught Reference Error: paij is not defined"

It appears as though it doesn't recognize the external js file. Any help/ideas would be appreciated.

Here's the code for my plugin's PaymentInfo.cshtml file


@{
    Layout = "";
}
@model Nop.Plugin.Payments.Paij.Models.PaymentInfoModel
@using Nop.Web.Framework;
               <script src="https://api.montypay.de/assets/checkout-sdk/checkout.js" type="text/javascript"></script>

<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td>

            <p>@Html.Raw(Model.DescriptionText)</p>
            <p>

               <script type="text/javascript">
                  
                    $(document).ready(function() {
                        $(".payment-info-next-step-button").hide();
                    
                    checkout = new paij.Checkout({
                        web_hook: '@ViewBag.callbackurl',
                        api_key: '@ViewBag.user_key',
                        transaction: {
                            amount: @ViewBag.amount,
                            currency_code: '@ViewBag.currency',
                            description: '@ViewBag.storedescription'
                        }
                    }).writeButton().onSuccess(function (event) {
                        //figure out if this is one page or regular and go to next step;
                        if (document.location.href.indexOf('onepagecheckout') > -1) {
                            PaymentInfo.init('#co-payment-info-form', '@Request.Url.GetLeftPart(UriPartial.Authority)/checkout/OpcSavePaymentInfo/');
                            PaymentInfo.save();
                            }
                        else {
                            $(".payment-info-next-step-button").click();
                            //form.get(0).submit();
                            //this.form.submit();
                            }
                        console.log("onSuccess");
                        console.log(event.transaction);
                    }).onFail(function (event) {
                        console.log("onFail with %s fired!", event.error);
                    }).onCancel(function () {
                        console.log("onCancel fired!");
                    });
                    });
                </script>
                <input type="hidden" id="paijform" name="paijform" value="0" />

            </p>
        </td>
    </tr>
</table>
11 years ago
Hi,

look at the code of your page in browser and ensure that script is not plugged to make sure that this is the reason.
11 years ago
As an experiment I took the reference to the external Js file and pasted it into the onepagecheckout.cshtml file, and everything worked. It seems to have something to do with how it's loading the content dynamically. I have a test site setup at startest.simonsell-crm-machine.com if you'd like to see for yourself.

Has any one else had issues with trying to load Js into the payment info panel on the one page checkout?
11 years ago
I'm running out of things to try here... :/
11 years ago
the javascript reference works perfectly when i take the shop out of one page checkout mode
11 years ago
okay so a new experiment shows me that when I save the js file locally and load it from the scripts folder, it seems to work on one page checkout.

getting closer
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.