Skip to content

KPTechnologyLab/spring-paypal-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring PayPal REST API

Spring PayPal REST API integration.

Compatibility

  • Compatible with PayPal REST API version
<dependency>
    <groupId>com.paypal.sdk</groupId>
    <artifactId>rest-api-sdk</artifactId>
    <version>0.7.1</version>
</dependency>

Usage

  • Building the project
mvn clean install
  • Add the following dependency to your project.
<dependency>
    <groupId>com.kptechnologylab</groupId>
    <artifactId>spring-paypal-rest-api</artifactId>
    <version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>

Examples

  • Configuring PayPalRestTemplate
<bean id="payPalRestTemplate" class="com.kptechnologylab.springpaypal.PayPalRestTemplate">
       <constructor-arg index="0" value="EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM"/>
       <constructor-arg index="1" value="EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM"/>
       <constructor-arg index="2">
           <util:map>
               <entry key="mode" value="sandbox"/>
           </util:map>
       </constructor-arg>
   </bean>
  • Creating a payment
  CreditCard creditCard = creditCardBuilder()
                .type("visa").number("4446283280247004")
                .expireMonth(11).expireYear(2018)
                .firstName("Joe").lastName("Shopper")
                .build();

  Payer payer = payerBuilder()
          .paymentMethod(credit_card)
          .fundingInstruments(fundingInstrumentBuilder().creditCard(creditCard).build())
          .build();
  
  Transaction transaction = transactionBuilder()
          .amount(amountBuilder().currency("USD").total("10").build()).build();

  Payment payment  = paymentBuilder().intent(authorize).payer(payer).transactions(transaction).build();
  
  Payment paymentCreated = payPalRestTemplate.create(payment);
  • Capturing the payment
    Capture capture = payPalRestTemplate.capture(paymentCreated.getId());

About

Spring PayPal REST API Integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages