Backend code
@Controller
@RequestMapping("/examples")
public class ExamplesController {
private static final String PRIVATE_KEY = "pr_test_tXHm9qV9qV9bjIRHcQr9PLPa";
@RequestMapping(value = "/examples/checkout-with-default-email", method = GET)
public String checkout(Model model) throws IOException {
try (SecurionPayGateway securionPayGateway = new SecurionPayGateway(PRIVATE_KEY)) {
CheckoutRequest checkoutRequest = new CheckoutRequest()
.charge(2499, "EUR");
String signedCheckoutRequest = securionPayGateway.signCheckoutRequest(checkoutRequest);
model.addAttribute("signedCheckoutRequest", signedCheckoutRequest);
}
return "examples/checkout";
}
@RequestMapping(value = "/examples/checkout-with-default-email/payment", method = POST)
public String checkoutSubmit(Model model, @RequestParam String securionpayChargeId) {
model.addAttribute("chargeId", securionpayChargeId);
return "examples/checkout";
}
}