/ v1 / payments / payment /总是返回一个空数组

时间:2015-05-20 11:34:59

标签: jquery ajax paypal

创建了一个测试应用和一个测试帐户。 测试帐户有很多交易,firstCall成功,它返回access_token我,我用来调用“ / v1 / payments / payment / ”,这个,我总是返回一个空数组...

/* -- */
function pp() {

    this.r = false;
    this.R = function(r) {
        this.r = $("body").data("ppfirstcall");
    };
    this.firstCall = function() {
        $.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) {

                $("body").data("ppfirstcall", result.responseJSON);

                //ppInvoice(result.responseJSON.access_token);
                var ppAccTok =  result.responseJSON.access_token;
                var tokType = result.responseJSON.token_type;

                $.ajax({
                    headers : {
                        "Content-Type": "application/json",
                        "Authorization":"Bearer "+ppAccTok
                    },

                    //url : "https://api.sandbox.paypal.com/v1/invoicing/search",
                    url : "https://api.sandbox.paypal.com/v1/payments/payment/",
                    type : "get",
                    processData: false,
                    //data : JSON.stringify(data),
                    complete: function(ppR)
                    {
                        console.log(tokType,ppAccTok,ppR);
                    }
                }  );

                console.log( "complete:",result.responseJSON.access_token, result.responseJSON );
            },
        });
    };
};

function runPP()
{
    pp = new pp();
    pp.firstCall();
}
/*  ----  */

0 个答案:

没有答案