Skip to content

Instantly share code, notes, and snippets.

@yogonza524
Created April 23, 2020 15:37
Show Gist options
  • Save yogonza524/6531d9460b407a68496928347b82d31a to your computer and use it in GitHub Desktop.
Save yogonza524/6531d9460b407a68496928347b82d31a to your computer and use it in GitHub Desktop.
@GetMapping("/createAndRedirect")
public String createAndRecirect() throws MPException {
Preference preference = new Preference();
preference.setBackUrls(
new BackUrls()
.setFailure("http://localhost:8080/failure")
.setPending("http://localhost:8080/pending")
.setSuccess("http://localhost:8080/success")
);
Item item = new Item();
item.setTitle("Test Item")
.setQuantity(1)
.setUnitPrice((float) 75.56);
preference.appendItem(item);
var result = preference.save();
return "redirect:" + result.getSandboxInitPoint();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment