Plants
& More
   
Example product

Potted plant

Monstera

Price: $24.99

Checkout

Checkout makes it simple to add payment buttons to your website.

When you use Checkout, we’ll handle all the tedious details for you. You can customize some of the Checkout elements (like logo image or title text), but if it’s not enough, you can always integrate using Custom Form.

This example shows a stripped-down version of Checkout with no extra features.

Use these card details to test different scenarios

Success
4242 4242 4242 4242
Copied
Insufficient funds
4024 0071 1846 8684
Copied

		<form action="/examples/checkout/payment" method="post">
			<script src="https://dev.shift4.com/checkout.js"
				class="shift4-button"
				data-key="pu_test_WVMFC9GFuvm54b0uorifKkCh"
				data-checkout-request="MjVhMmJjYTRiNzUyNzQ0MWU2MTljNDFkYjcwMTE1ZmZmZjc3NDI3OTk4MDBhY2MxYTc0ZjFhMDExOWY2OWYxZnx7ImNoYXJnZSI6eyJhbW91bnQiOjI0OTksImN1cnJlbmN5IjoiVVNEIn0sInRocmVlRFNlY3VyZSI6eyJlbmFibGUiOmZhbHNlfX0="
				data-name="Shift4"
				data-description="Checkout example"
				data-checkout-button="Buy now"
				data-class="btn btn-primary btn-lg">
			</script>
		</form>
	

		@Controller
		@RequestMapping("/examples")
		public class ExamplesController {
		
			private static final String PRIVATE_KEY = "pr_test_tXHm9qV9qV9bjIRHcQr9PLPa";

			@RequestMapping(value = "/examples/checkout", method = GET)
			public String checkout(Model model) throws IOException {
				try (Shift4Gateway shift4Gateway = new Shift4Gateway(PRIVATE_KEY)) {
					CheckoutRequest checkoutRequest = new CheckoutRequest()
							.charge(2499, "USD");
					
					String signedCheckoutRequest = shift4Gateway.signCheckoutRequest(checkoutRequest);
					
					model.addAttribute("signedCheckoutRequest", signedCheckoutRequest);
				}

				return "examples/checkout";
			}
	
			@RequestMapping(value = "/examples/checkout/payment", method = POST)
			public String checkoutSubmit(Model model, @RequestParam String shift4ChargeId) {
				model.addAttribute("chargeId", shift4ChargeId);

				return "examples/checkout";
			}
		}