Skip to content

stevensinclair/merchant-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains java sdk and samples for Merchant API.

Prerequisites:

To build sdk and samples:

SDK Integration:

  • Create a new maven application.

  • Add dependency to sdk in your application's pom.xml as below.

    <dependency>
        <groupId>com.paypal.sdk</groupId>
        <artifactId>merchantsdk</artifactId>
        <version>2.4.103</version>
    </dependency>

To make an API call:

  • Import PayPalAPIInterfaceServiceService.java into your code.

  • Copy the configuration file 'sdk_config.properties' in 'merchantsample/src/main/resources' folder to your application 'src/main/resources'. Use the default constructor to run in default configuration(configuration used from sdk_config.properties found in classpath).

    new PayPalAPIInterfaceServiceService();
  • For Dynamic configuration(configuration is tied to the lifetime of the service object)

    new PayPalAPIInterfaceServiceService(new File("/pathto/custom.properties"));
    		Or
    new PayPalAPIInterfaceServiceService(new FileInputStream(new File("/pathto/custom.properties")));
    		Or
    new PayPalAPIInterfaceServiceService("/pathto/custom.properties");
    		Or
    new PayPalAPIInterfaceServiceService(Map<String, String> customConfigurationMap);
    		Or
    new PayPalAPIInterfaceServiceService(Properties customProperties);
  • The SDK takes defaults for certain parameters(refer sdk_config.properties for defaults). Account Credentials and either of 'mode' or 'service.Endpoint' are mandatory parameters.

  • Create a service wrapper object.

  • Create a request object as per your project needs.

  • Invoke the appropriate method on the service wrapper object.

    For example,

    import urn.ebay.api.PayPalAPI.*;
    ...
    TransactionSearchReq txnreq = new TransactionSearchReq();
    TransactionSearchRequestType requestType = new TransactionSearchRequestType();
    
    requestType.setStartDate("2011-10-04T00:00:00.000Z"); 
    requestType.setEndDate("2011-10-05T23:59:59.000Z"); 
    requestType.setVersion("95.0");
    requestType.setTransactionID(request.getParameter("transactionID"));
    txnreq.setTransactionSearchRequest(requestType);
    
    PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
    			Or
    Map<String, String> customConfigurationMap = new HashMap<String, String>();
    customConfigurationMap.put("mode", "sandbox"); // Load the map with all mandatory parameters
    ...
    PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(Map<String, String> customConfigurationMap);
    TransactionSearchResponseType txnresponse = service.transactionSearch(txnreq, username);

SDK Logging:

  • For logging - java.util.logging has been used. To change the default configuration, edit the logging.properties file in 'jre/lib' folder under your JDK root.

SDK Configuration:

The SDK uses .properties format configuration file. Sample of this file is at

'merchantsample/src/main/resources/'. You can use the 'sdk_config.properties' configuration file to configure

  • Mode is specified using the parameter name 'mode' with values 'sandbox' or 'live', if specified 'service.EndPoint' parameter is not required and the SDK chooses the sandbox or live endpoints automatically.

  • (Multiple) API account credentials, by appending a '.' (dot) character and the service name to 'service.EndPoint' parameter.

  • HTTP connection parameters, if certain connection parameters are not specified, the SDK will assume defaults for them.

  • Service configuration.

Multiple SDK usage (Multiple End-points Support)

Multiple end-points configuration can be done by specifying mulitple end-points identified by specific property keys. When using multiple SDKs in combination, like Merchant and Permissions etc..configure the endpoints as shown below one for each service used, The existing service.EndPoint property is still supported for backward compatibility (using a single SDK). The list below specifies endpoints for different services, in SANDBOX and PRODUCTION, with their property keys and end-point as property values.

------------------------------SANDBOX------------------------------

------------------------------PRODUCTION------------------------------

For additional information on Merchant API, please refer to https://www.x.com/developers/paypal/documentation-tools/api

Instant Payment Notification(IPN)

  • Please refer readme at 'merchantsample/IPN-README.md'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published