MALFORMED_REQUEST:"传入的JSON请求未映射到API请求"与Paypal集成在salesforce中

时间:2017-08-10 08:09:56

标签: json paypal salesforce payment

我正在我的salesforce帐户中进行paypal集成,但在通过Rest API调用付款时收到验证错误:Incoming JSON request does not map to API request

我试过以下链接示例json值: https://developer.paypal.com/docs/api/payments/#payment

分享正确的json值以进行付款,或协助我了解如何继续。

请找到付款的顶点代码:

public void Fetchcredentail(){
    Http http = new Http();
    HttpResponse response;
            response = new HttpResponse();
            response.setBody(convertJsonBody());
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://api.sandbox.paypal.com/v1/payments/payment');
            req.setMethod('POST');
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('Authorization', 'Bearer <Access token>');
            response  = http.send(req);
            system.debug(response+'-------'+response.getBody());
}   
public string convertJsonBody(){

        string json=        '{'+
    '  "intent": "sale",'+
    '  "payer": {'+
    '    "payment_method": "credit_card",'+
    '    "funding_instruments": [{'+
    '      "credit_card": {'+
    '        "number": "4417119669820331",'+
    '        "type": "visa",'+
    '        "expire_month": 11,'+
    '        "expire_year": 2018,'+
    '        "cvv2": "874",'+
    '        "first_name": "Venkat",'+
    '        "last_name": "H",'+
    '        "billing_address": {'+
    '          "line1": "111 First Street",'+
    '          "city": "Chennai",'+
    '          "state": "TN",'+
    '          "postal_code": "6000088",'+
    '          "country_code": "IN"'+
    '        }'+
    '      }'+
    '    }]'+
    '  },'+
    '  "transactions": [{'+
    '    "amount": {'+
    '      "total": "1.47",'+
    '      "currency": "USD",'+
    '      "details": {'+
    '        "subtotal": "1.41",'+
    '        "tax": "0.03",'+
    '        "shipping": "0.03"'+
    '      }'+
    '    },'+
    '    "description": "The payment transaction description."'+
    '  }]'+
    '}';
    return json;
}         

0 个答案:

没有答案