Page Redirection Workflow

PAYON

Simple Redirect URL Implementation

public class MyController {

	@Autowired
	private RestOperations restTemplate;
	
	@RequestMapping(value="/order/complete",params={"txId"})
	public Mono<String> getOrderComplete(Model model, @RequestParam("txId") String txId) {
    
    //STEP01:Get Transaction Status endpoint
		String url = "https://pg.payon.com.kh:35505/pg/transaction/status";
		
		//STEP02: Init payment status request
		JSONObject paymentStatusReq = new JSONObject();
    paymentStatusReq.put("txId", txId);
    paymentStatusReq.put("merchantId", "YOUR MERCHANT ID");
    paymentStatusReq.put("termId", "YOUR TERM ID");
 
		//STEP03: Request to PAYON's PG server to get order's status
		MyPaymentResultModel paymentResult = restTemplate.postForObject(url, paymentStatusReq, String.class);
		
		//STEP04: Mappe payment result to model
		model.addAttribute("paymentResult", paymentResult);

		//STEP05: Render to the view and mapping with payment result
		return Mono.just("YOUR VIEW NAME");
	}
	
}

Last updated