JavaEE 集成全球支付之PayPal

原文链接: https://juejin.im/post/5ac5dc346fb9a028cb2ddc2d

#JavaEE 集成全球支付之PayPal

简单集成

1. 导入依赖

<dependency>
  <groupId>com.github.catalpaflatgroupId>
  <artifactId>module-paypalartifactId>
  <version>0.0.1version>
dependency>
复制代码

2. yml配置

catalpaflat:
  paypal:
    sandbox_access_token: access_token$sandbox$catalpaflat1234567ec3dcc77213f4
    product_access_token: access_token$production$catalpaflat123456782bb3ec3dcc77213f4
    environment: sandbox
复制代码

3. 注入依赖

@Configuration
public class PayPalResourceConfig {
    @Bean
    public PayPalSpecificSupport payPalSpecificSupport(PayPalProperties payPalProperties) throws PackagerException {
        return new PayPalSpecificSupport(payPalProperties);
    }
}
复制代码

4. 简单调用


@RestController
@RequestMapping
public class PayPalIdal {
    @Resource
    private PayPalSpecificSupport payPalSpecificSupport;

    @GetMapping("public_access_token")
    public String get() throws PackagerException {
        return payPalSpecificSupport.obtainPublicAccessToken();
    }

    @PostMapping("place_order")
    public Result placeOrder(@RequestBody @Valid PayPalVO payPalVO) throws PackagerException {
        return payPalSpecificSupport.placeOrder(payPalVO);
    }

    @PutMapping("return")
    public Result returnOrder(@RequestBody @Valid ReturnVO returnVO) throws PackagerException {
        return payPalSpecificSupport.refund(returnVO);
    }
}
复制代码

你可能感兴趣的:(JavaEE 集成全球支付之PayPal)