2014-09-02 328 views
0

我試圖將登錄與paypal無paypal的api.js集成,但是我找不到它的文檔。使用PayPal登錄手動登錄

這裏是我試過

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和貝寶的遺失文件或我的錯。我的主要目的是做到這一點,我只想自定義loginwithpaypal按鈕,我想改變它的文本。

我歡迎任何有助於

如果我使用api.js,我能成功地整合,但正如我說我找不到文檔定製api.js的按鈕

回答

0
$(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

+0

我可以登錄做工精細,但它驗證之後,它只是重定向彈出到'''returnurl'''而不是打開彈出窗口的頁面。關於如何關閉窗口並重定向觸發彈出的頁面的想法? – evliu 2014-10-22 02:29:31

+0

返回網址必須與主機,端口和協議相匹配,因此您需要爲您的當前網域指定返回網址而不是它 – 2014-10-22 07:04:18

+0

@evliu並返回url是錯誤的參數,這是我的錯,它必須是redirect_uri – 2014-10-22 10:55:50