GetTransactionDetails

xiaoxiao2021-03-06  104

Import paypalapi.api.ebay. *; import java.net.URL;

import org.apache.axis.message.SOAPHeaderElement; import org.apache.axis.message.PrefixedQName; import org.apache.axis.message.MessageElement; import org.apache.axis.AxisFault; import org.apache.axis.client . *;

Import java.io. *;

Import eblbasecomponents.apis.ebay. *; import com.paypal.api.client. *;

/ ** * @Author bcoffman * taken from refundtransaction * * java gettransactiondetails * * /

public class GetTransactionDetails {public static void main (String [] args) throws Exception {if (args.length <1) {System.out.println ( "Usage: java GetTransactionDetails "); return;} // GetTransactionDetails client = new GetTransactionDetails (); client.testGetTransactionDetails (args [0]);} public GetTransactionDetails () {} public void testGetTransactionDetails (String txn_id) throws Exception {SimpleConfigFile cfg = new SimpleConfigFile ( "client_config.nvp"); String url = cfg.val ("URL"); system.out.println ("Connecting to /" URL "/": Testing getTransactionDetails (/ "" txn_id "/") "); paypalapiinterface binding = null; try { Binding = new paypalapiinterfaceServiceLocator (). getPalapalapi (NEW URL (URL)) .SetTimeout (60000);} catCh (Exception E) {Org.apache.Axis .Axisfault afe = null; if (e instanceof org.apache.axis.axisfault) {Afe = (org.apache.axis.axisfault) E;} string Note = Afe.GetFaultString (); system.out.println ("got Axisfault Exception " Note.toString ()); E.PrintStackTrace (); // throw axisfault.makefault (e); return;}

_GetTransactionDetailsReq _req = new _GetTransactionDetailsReq (); GetTransactionDetailsRequestType request = new GetTransactionDetailsRequestType (); _req.setGetTransactionDetailsRequest (request); request.setVersion (cfg.val ( "getDetails_version"));! If (cfg.val ( "proxy_host") = null ) {System.SetProperty ("http.proxyhost", cfg.val ("proxy_host")); if (cfg.val ("proxy_host")! = Null) {System.SetProperty ("http.proxyport", cfg.val ( "proxy_port"));} else {System.setProperty ( "http.proxyPort", "8080");}} eBLBaseComponents.apis.ebay.TransactionId txnID = new eBLBaseComponents.apis.ebay.TransactionId (txn_id); request. setTransactionID (txnID); // Insert ebl security ... PrefixedQName pqn = new PrefixedQName ( "urn: ebay: api: PayPalAPI", "RequesterCredentials", ""); SOAPHeaderElement eblSecurity = new SOAPHeaderElement (pqn); eblSecurity.setMu Stunderstand (True);

MessageElement Credentials = New MessageElement ("Credentials", "EBL", "URN: eBay: Apis: eblbasecomponents);

MessageElement username = new MessageElement ( "", "ebl: Username"); MessageElement password = new MessageElement ( "", "ebl: Password"); MessageElement subject = new MessageElement ( "", "ebl: Subject"); username. setObjectValue (cfg.val ( "user_name")); credentials.addChild (username); password.setObjectValue (cfg.val ( "user_passwd")); credentials.addChild (password); subject.setObjectValue (cfg.val ( "user_subject ")); credentials.addChild (subject); eblSecurity.addChild (credentials); org.apache.axis.client.Stub s = (Stub) binding; s.setHeader (eblSecurity);. // Below allows SSL connections org. Apache.axis.axisproperties.SetProperty ("Axis. SocketSecureFactory", "com.paypal.api.client.sslfactory);

// Print The Reuqest Object PrintGetTxndetailsReq (Request);

// This actually does the transaction ... GetTransactionDetailsResponseType resp = null; try {resp = binding.getTransactionDetails (_req);} catch (Exception e) {org.apache.axis.AxisFault afe = null; if (e instanceof org. Apache.axis.Axisfault) {Afe = (org.apache.axis.axisfault) E;} String Note = Afe.dumptostring (); System.out.Println ("Failed on Transaction: Note); // E. PRINTSTACKTRACE (); Return;}

// Now We process the output .printgettxndetailsres (resp);}

Void PrintGetTxndetailsReq (GetTransactionDetailsRequestType Req) {system.out.println (); system.out.println ("************ gettransactiondetails request **********"); System.out.println ( "transactionID:" req.getTransactionID () toString ().); System.out.println ( "Version:". req.getVersion () toString ());} void printGetTxnDetailsRes (GetTransactionDetailsResponseType res ) {

System.out.println (); system.out.println ("************ gettransactiondetails response ************"); if (res.getbuild () ! = null) System.out.println ("Build:" res. GetBuild (). Tostring ()); if (res.getversion ()! = null) System.out.println ("Version:" RES. Getversion (). TOSTRING ()); if (res. max) {system.out.println ("CORR ID:" Res. GetcorRing ());}

IF (res.gettimestamp ()! = null) {system.out.println ("TimeStamp:" res.getTimeStamp (). getTime ());}

System.out.println (); system.out.println ("ACK:" res. geneTack (). Tostring ());

EblbaseComponents.apis.ebay.errtype err [] = res. geneRrors (); if (err! = null) {for (int i = 0; i

System.out.println (); org.apache.axis.Message.MessageElement msg [] = res. max_any (); if (msg! = Null) {for (INT i = 0; i

PrintResults Display = New PrintResults ();

SYSTEM.OUT.PRINTLN ();

eBLBaseComponents.apis.ebay.PaymentTransactionType pt = resp.getPaymentTransactionDetails (); if (pt == null) {System.out.println ( "* no Payment Transaction Information *"); return;} eBLBaseComponents.apis.ebay.PaymentInfoType pi = pt.getPaymentInfo (); if (pi == null) {system.out.println ("* no payment information *");} else {system.out.println ("************ ** payment info "); Display.PrintPaymentInfo (PI);

EblbaseComponents.apis.ebay.payerinfotype pr = pt.getpayerinfo (); if (pr == null) {System.out.Println ("* no payer information *");} else {system.out.println ("** ********** payer info "); Display.PrintPayerInfotype (PR);}

EblbaseComponents.apis.ebay.receiverInfotype ri = pt.getReceiverInfo (); if (ri == null) {system.out.println ("* no receiver information *");} else {system.out.println ("** ********** Receiver info "); Display.printReceiverInfo (ri);}

EblbaseComponents.apis.ebay.paymentItemInfotype II = pt.getPaymentItemInfo (); if (ii == null) {system.out.println ("* no payment item information *");} else {system.out.println ("* * ************ payment iteminfo "); Display.PrintPaymentItemInfo (II);}}}

转载请注明原文地址:https://www.9cbs.com/read-124728.html

New Post(0)