使用Paypal手动登录

时间:2014-09-02 13:59:31

标签: javascript paypal

我尝试将登录与paypal集成而没有paypal的api.js,但是我找不到它的文档。

这是我试过的

HTML

<img id="paypalVerify" src="~/Images/getverifiedbypaypal.jpg" onclick="windowPop()" />

JS

<script>
            function windowPop() {

                //Create Form Attributes
                var paypalForm = document.createElement("paypalForm");
                paypalForm.target = "paypalPopup1";
                paypalForm.method = "POST"; // or "post" if appropriate
                paypalForm.action = "https://www.sandbox.paypal.com/webapps/auth/loginauth";

                //Paypal Application ID
                var appid = document.createElement("input");
                appid.type = "text";
                appid.name = "appid";
                appid.value = "**************";
                paypalForm.appendChild(appid);

                //Paypal authend
                var authend = document.createElement("input");
                authend.type = "text";
                authend.name = "authend";
                authend.value = "sandbox";
                paypalForm.appendChild(authend);

                //Paypal scopes
                var scopes = document.createElement("input");
                scopes.type = "text";
                scopes.name = "scopes";
                scopes.value = "profile email address phone";
                paypalForm.appendChild(scopes);

                //Paypal locale
                var locale = document.createElement("input");
                locale.type = "text";
                locale.name = "locale";
                locale.value = "en-us";
                paypalForm.appendChild(locale);

                //Paypal locale
                var returnurl = document.createElement("input");
                returnurl.type = "text";
                returnurl.name = "returnurl";
                returnurl.value = "http://localhost:57559/";
                paypalForm.appendChild(returnurl);

                document.body.appendChild(paypalForm);

                var paypalPopup = window.open("", "paypalPopup1", "status=0,title=0,height=600,width=800,scrollbars=1");
                if (paypalPopup) {
                    paypalForm.submit();
                } else {
                    alert('You must allow popups for this map to work.');
                }
            }
        </script>

我尝试创建一个表单然后还创建了带有表单数据的弹出框,当用paypal点击登录时,弹出窗口创建后尝试提交表单。

我很确定问题是JS和Paypal缺少文档或我的错。我这样做的主要目的是,我只想自定义loginwithpaypal按钮,我想改变它的文字。

我将感激任何帮助

如果我使用api.js,我可以成功整合,但正如我所说,我找不到文档来定制api.js的按钮

1 个答案:

答案 0 :(得分:1)

$( document ).ready(function() {
  paypal.use(["login"], function (login) {
            login.render({
                "appid": "-************",
                "authend": "sandbox",
                "scopes": "profile email address phone",
                "containerid": "paypalLogin",
                "locale": "en-us",
                "text": "Verify your account with Paypal",
                "redirect_uri": "http://localhost:57559/"
       });
   });
});

在创建按钮请求作为文本属性时,我们可以设置按钮文本

Here is THE FIDDLE