java测试帐户中的Paypal支付失败

java测试帐户中的Paypal支付失败,java,payment-gateway,paypal,paypal-sandbox,Java,Payment Gateway,Paypal,Paypal Sandbox,我正在尝试在Paypal DoDirectPayment中开发应用程序。我正在创建测试沙盒帐户,并使用以下代码和我自己的API凭据,但我得到的确认是失败 如果有人知道如何解决这个问题,请与我分享 提前谢谢 public class DoDirectPayment { private NVPCallerServices caller = null; public String DoDirectPaymentCode(String paymentAction,String amount,Stri

我正在尝试在Paypal DoDirectPayment中开发应用程序。我正在创建测试沙盒帐户,并使用以下代码和我自己的API凭据,但我得到的确认是失败

如果有人知道如何解决这个问题,请与我分享

提前谢谢

public class DoDirectPayment 
{
private NVPCallerServices caller = null;

public String DoDirectPaymentCode(String paymentAction,String amount,String cardType,
                            String acct,String expdate,String cvv2, String firstName,
                            String lastName, String street, String city, String state, 
                            String zip, String countryCode)
{
    NVPEncoder encoder = new NVPEncoder();
    NVPDecoder decoder = new NVPDecoder();

    try
    {

        caller = new NVPCallerServices();
    APIProfile profile = ProfileFactory.createSignatureAPIProfile();
        /*
         WARNING: Do not embed plaintext credentials in your application code.
         Doing so is insecure and against best practices.
         Your API credentials must be handled securely. Please consider
         encrypting them for use in any production environment, and ensure
         that only authorized individuals may view or modify them.
         */
    // Set up your API credentials, PayPal end point, API operation and version.
        profile.setAPIUsername("sdk-three_api1.sdk.com");
        profile.setAPIPassword("QFZCWN5HZM8VBG7Q");
        profile.setSignature("AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ");
        profile.setEnvironment("sandbox");
        profile.setSubject("");
        caller.setAPIProfile(profile);

        encoder.add("VERSION", "51.0");
        encoder.add("METHOD","DoDirectPayment");

    // Add request-specific fields to the request string.
        encoder.add("PAYMENTACTION",paymentAction);
        encoder.add("AMT",amount);
        encoder.add("CREDITCARDTYPE",cardType);     
        encoder.add("ACCT",acct);                       
        encoder.add("EXPDATE",expdate);
        encoder.add("CVV2",cvv2);
        encoder.add("FIRSTNAME",firstName);
        encoder.add("LASTNAME",lastName);                                       
        encoder.add("STREET",street);
        encoder.add("CITY",city);   
        encoder.add("STATE",state);         
        encoder.add("ZIP",zip); 
        encoder.add("COUNTRYCODE",countryCode);

    // Execute the API operation and obtain the response.
        String NVPRequest = encoder.encode();
        String NVPResponse =(String) caller.call(NVPRequest);
        decoder.decode(NVPResponse);

    } catch(Exception ex)
    {
        ex.printStackTrace();
    }
    return decoder.get("ACK");
}

public static void main(String[] args) {

    DoDirectPayment obj=new DoDirectPayment();
    System.out.println(obj.DoDirectPaymentCode("Authorization ", "1", "Visa", "1234123412341234", "122012", "123", "testname", "testname", "chennai", "chennai", "TX", "77570", "US"));

}

} 

PAYMENTACTION参数中有一个输入错误:
“Authorization”应该替换为“Authorization”(只需删除末尾的冗余空间)

并且您似乎仍然在使用默认的API用户名。通过在上注册为开发人员并创建预配置的美国网站Payments Pro帐户来建立您自己的帐户。注意:如果您获得“无效商户配置”,请在上登录一张票据,并要求他们在您的沙箱卖家帐户上启用网站支付专业版。确保为他们提供API用户名。