One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
dependencies { | |
implementation 'org.springframework.boot:spring-boot-starter-mustache' | |
implementation 'org.springframework.boot:spring-boot-starter-web' | |
implementation 'org.springframework.boot:spring-boot-starter-webflux' | |
compileOnly 'org.projectlombok:lombok' | |
developmentOnly 'org.springframework.boot:spring-boot-devtools' | |
annotationProcessor 'org.projectlombok:lombok' | |
testImplementation 'org.springframework.boot:spring-boot-starter-test' | |
testImplementation 'io.projectreactor:reactor-test' |
@WebMvcTest(IndexController.class) | |
@AutoConfigureMockMvc | |
class IndexControllerTest { | |
@Autowired | |
private MockMvc mockMvc; | |
@Test | |
@DisplayName("check if index page is rendered.") | |
public void testIndexPage() throws Exception { |
@Controller | |
@RequestMapping("/") | |
public class IndexController { | |
@GetMapping("/") | |
public String index(){ | |
return "index"; | |
} | |
} |
//... | |
@GetMapping("/capture") | |
public String captureOrder(){ | |
return ""; | |
} | |
@PostMapping | |
public String placeOrder(@RequestParam Double amountId, HttpServletRequest request){ | |
final URI returnUrl = buildReturnUrl(request); |
//... | |
private final PaymentService paymentService; | |
public OrderController(PaymentService paymentService) { | |
this.paymentService = paymentService; | |
} | |
@PostMapping | |
public String placeOrder(@RequestParam Double totalAmount, HttpServletRequest request){ |
@Data | |
public class CreatedOrder { | |
private final String orderId; | |
private final URI approvalLink; | |
} |
public interface PaymentService { | |
CreatedOrder createOrder(Double totalAmount, URI returnUrl); | |
} |
paypal: | |
clientId: ${paypal.clientId} | |
clientSecret: ${paypal.secret} |
@Service | |
public class PayPayPaymentService implements PaymentService{ | |
private final PayPalHttpClient payPalHttpClient; | |
public PayPayPaymentService(@Value("${paypal.clientId}") String clientId, | |
@Value("${paypal.clientSecret}") String clientSecret) { | |
payPalHttpClient = new PayPalHttpClient(new PayPalEnvironment.Sandbox(clientId, clientSecret)); | |
} |