Paypal Java脚本集成 [英] Paypal Java script integration

查看:162
本文介绍了Paypal Java脚本集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要将Paypal与我的移动网络应用程序集成。我试图使用客户端ID和密码ID获取访问令牌,但无法获取访问令牌。

Want to integrate Paypal with my mobile web application. I tried to get the access token using client id and secret id but unable to get the access token.

下面是我正在进行的示例Ajax调用以检索访问权限令牌。

Below is the sample Ajax call with I am making to retrieve the access token.

function getAccessToken(){
        $.ajax({
        url:"https://api.sandbox.paypal.com/v1/oauth2/token/",
        type:"POST",
        data : {"grant_type":"client_credentials"},
        beforeSend: function (request)
                {
                    request.setRequestHeader("Accept", "application/json");
                    request.setRequestHeader("Accept-Language", "en_US");
                    request.setRequestHeader("Authorization", "abc XXXXX:XXXXXXXXXXXXX");
                },
            success: function(data) {    
                alert(data);
            },
            error: function(e, messgae,type){
                alert("Error" + e +"          "+messgae+"         type         "+type);
            }
     });

我无法从服务器中检索访问令牌。
任何人都可以告诉我如何使用java脚本将Paypal与我的移动Web应用程序集成?

I am unable to retrive the access token from the server. Can anyone please tell me how can I integrate Paypal with my mobile web application using java script?

推荐答案

经过一系列尝试和失败后,我找到了正确的AJAX电话:

after a series of try and fail I found the correct AJAX call:

$.ajax({
        headers: {
             "Accept": "application/json",
             "Accept-Language": "en_US",
             "Authorization": "Basic "+btoa("**<Client ID>:<Secret>**")
        },
        url: "https://api.sandbox.paypal.com/v1/oauth2/token",
        type: "POST",
            data: "grant_type=client_credentials",
        complete: function(result) {
            alert(JSON.stringify(result));
        },
});

您需要将您的Client ID:Secret替换为您在Developer Dashboard上找到的那个,例如 AxxhGDh:hudh-X-h8qi

You need to replace Client ID:Secret with the one that you find on your Developer Dashboard, for example AxxhGDh:hudh-X-h8qi

这篇关于Paypal Java脚本集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆