简体   繁体   中英

How to process credit card in hosted mode via QBMS Java API

I modified the sample provided here , but it doesn't work for the hosted app. Clearly the problem is the connection ticket, which should not be used from my understanding.

The following is the java class:

public class MyPayment {
    public static void main(String[] args) throws Exception{
        QbmsConfiguration qbmsConfiguration =new QbmsConfiguration("/qbmsconnector.properties");

        // Create a JAXB-backed QbmsConnector
        QbmsConnector qbmsConnector =new JaxbQbmsConnector(qbmsConfiguration);

        // Build a charge request...
        CreditCardChargeRequest request =new CreditCardChargeRequest();
        request.setCreditCardNumber("4111111111111111");
        request.setNameOnCard("John Doe");
        request.setExpirationMonth(12);
        request.setExpirationYear(2014);
        request.setAmount(130.00);

        // ...define a connection ticket...
        String connectionTicket ="TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX";

        // ...and make the payment.
        try{
          CreditCardChargeResponse response = qbmsConnector.creditCardCharge(connectionTicket, request);
          System.out.println(response);
        }catch(QbmsOperationException e){
          System.out.println("Payment failed: "+ e.getMessage());
          e.printStackTrace();
        }
    }
}

Here is the qbmsconnector.properties

qbmsconnector.applicationLogin=loginidxxxxxx
qbmsconnector.applicationId=123456789
qbmsconnector.environment=ptc
qbmsconnector.model=hosted
qbmsconnector.keyStoreLocation=/qbms
qbmsconnector.keyStorePassword=password111
qbmsconnector.certPassword=password111
qbmsconnector.certAlias=alias_abc

It throws the following errors:

Payment failed: Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX
com.intuit.qbmsconnector.response.QbmsResponseStatusException: Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX
    at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.processSignonNode(Unknown Source)
    at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.unmarshal(Unknown Source)
    at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.extractCreditCardChargeResponse(Unknown Source)
    at com.intuit.qbmsconnector.jaxb.JaxbQbmsConnector.creditCardCharge(Unknown Source)
    at qbo.MyPayment.main(MyPayment.java:30)

This error:

Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX

Generally indicates 1 or 2 things:

  • You're not using a valid connection ticket (is that the actual connection ticket you're using, or did you XXX out the connection ticket?)

OR

  • You're using a valid connection ticket, but you're using it with the wrong environment. Connection tickets generated in the PTC environment do not work with the production environment, and vice versa. Did you generate the connection ticket for PTC, or for production?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM