如何从沙盒生活到使用Java支持Paypal?

时间:2014-12-09 11:25:22

标签: java rest paypal

我只需要你的帮助,我使用Java语言在我的网站上使用Paypal集成,在这里我使用Express Checkout服务和Rest API调用使用直接信用卡付款,现在我已经创建了沙盒帐户并测试了它们。它的工作非常好,有适当的反应。

现在,为了获得实时付款,我们在美国有一个商业商家帐户,我们已将该银行与我们的Paypal帐户相关联,当我为REST API交易提供该商业帐户的凭据时,它会抛出错误

错误代码:401 with response : Server returned HTTP response code: 401

导致此错误的代码是:

Map sdkConfig = new HashMap();         sdkConfig.put(“mode”,“live”);

    CreditCard creditCard = new CreditCard();
    creditCard.setType("visa");
    creditCard.setNumber("4446283280247004");
    creditCard.setExpireMonth(11);
    creditCard.setExpireYear(2018);
    creditCard.setFirstName("Joe Shopper");

    creditCard.setCvv2("177");
    Details details = new Details();
    details.setShipping("0");
    details.setSubtotal("0.01");
    details.setTax("0");


    Amount amount = new Amount();
    amount.setCurrency("USD");
    amount.setTotal("0.01");
    amount.setDetails(details);
   int random = (int) Math.round(Math.random()*1000000);
    System.out.println(random);
    Transaction transaction = new Transaction();
    transaction.setAmount(amount);
    transaction.setDescription("This is the payment transaction description.");


    List<Transaction> transactions = new ArrayList<Transaction>();
    transactions.add(transaction);
    FundingInstrument fundingInstrument = new FundingInstrument();
    fundingInstrument.setCreditCard(creditCard);


    List<FundingInstrument> fundingInstrumentList = new ArrayList<FundingInstrument>();
    fundingInstrumentList.add(fundingInstrument);
    Payer payer = new Payer();
    payer.setFundingInstruments(fundingInstrumentList);
    payer.setPaymentMethod("credit_card");
    Payment payment = new Payment();
    payment.setIntent("Sale");
    payment.setPayer(payer);
    payment.setTransactions(transactions);

    try {
        String accessToken = GenerateAccessToken.getAccessToken();
       APIContext apiContext = new APIContext(accessToken);
        apiContext.setConfigurationMap(sdkConfig);
       Payment createdPayment = payment.create(apiContext);
     System.out.println(Payment.getLastResponse());


        List<Transaction> trans = createdPayment.getTransactions();


    } catch (PayPalRESTException e) {
        e.printStackTrace();

    }

请告诉我,为了顺利进行交易和转移实际付款,我应该怎么做才能解决这个问题,如果在我的Paypal帐户设置中有任何我必须做的事情,请告诉我。

0 个答案:

没有答案
相关问题