# Page Redirection Workflow

## PAYON

{% file src="<https://4168833594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO0T6AWg35JuiFxALbE%2F-MZH-7uG7EZxonZK-SBH%2F-MZHCCMSM4CoqHMpGBtz%2FRedirection%20PAYON%20Payment%20Flow.pdf?alt=media&token=f2ac9e78-129f-4925-b16f-ce9ce355d9c0>" %}
PAYON\_Page\_Redirection\_Workflow
{% endfile %}

![Figure 01: PAYON Page Redirection](https://4168833594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO0T6AWg35JuiFxALbE%2F-MZH-7uG7EZxonZK-SBH%2F-MZHCUQYFLJczHYJSjM_%2FRedirection%20PAYON%20Payment%20Flow.jpg?alt=media\&token=7493bef0-5a95-4fba-b91c-80a5ad73bc60)

## Simple Redirect URL Implementation

{% tabs %}
{% tab title="JAVA" %}

```java
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");
	}
	
}
```

{% endtab %}
{% endtabs %}
