App Pay
POST/api/entry/apppay
The merchant backend calls this API to create a prepayment transaction on PayCloud. PayCloud returns the payment parameters, and the merchant's app uses the WeChat or Alipay SDK to invoke the payment page and initiate the payment process.
For more details, please refer to the In-App Payment Product Introduction.
- Although the parameters
term_ip
,longitude
, andlatitude
are currently optional, considering that they may become mandatory in the future for risk control purposes, it is recommended to set these parameters in advance to prepare for potential changes.
Here is a Java code example
// Set application parameters and keys
private static final String APP_RSA_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCMPiTuC1xHkCUu/TospfJ7IldcnqYWaB4L287ADssc91NJ0NHP9AXvepTee1StWxRVamcyH3yWRJSnsbTWRqE+tQWDZ21Rhg5AQ8KWZ9RpSK+f07eX1K0rMUl3xUouvJgWzWvHZlUoIqXBx76nU7upFo5CoKmnyXYrZ0K2hjM9+7cRXff4+LJ7Js7d8eFgMWKEm0IN+h4SMeRCuU5DgIXf4W0sUZuyFXiDuIbID1kArp9JnO5woSY/OYCM3PjesaXMLHunLR2hTj4yAYg2WVT85tsWCT+B3rBDhpuNgZhRrPn9cgzaHfXCfZrpX9B5uSleuFbUFCz+e7ZqSmQ0O5PJAgMBAAECggEAMy2KdIQYzNTBfQBT9m8oqd7CWr5ahdrA/DrenB/J52wqLMnThzvZ3qaxJO+E2y5doT4PIq9y27NzPC8RexCTTzroJCfeMN3m3XTc0d5aGYG49W5hlTq7ZwO5d8e7ZorURZ35Mu8ZLGhYbPrjjFR2KyJcD9xpjR1rzjMEmW8ny/o+z1nMMdt77bLddHVwVWqEMxuyy8DRIRcLU6yqQdrio+y6nt0fYjA5lKhiAhgcjehmNFAppeLGa0bZyUGnUsXEhHpfyvbGwVqh4m65RwXi1Z5dmBSusql05GLyp6qwYjPiwNRGMehmMLCIyYAKB7lDhWVvwk7inLrxHOnR4nKGwQKBgQDmGnd0L3PiVWL3uwsNeEXz0w3I8C3RJ5ehDc21pPtUIINXrakHtWTY+d15Ay1tqVAIp+ID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gqlQv/+pE/pOV9MIQe0CAdD26JF10QpSssEwKgvKvnXPUynVu09cjSEipev5cLJSApKSDZxrRjSFBXrh6nzg8JK05ehkI8wdsryRUneh0PGN0PgYLP/wjKiqlgTJaItxnb/JQIDAQAB";
private static final String APP_ID = "wz715fc0d10ee9d156";
private static final String GATEWAY_URL = "https://open.n-age.co.jp";
// Instantiate a client
OpenApiClient openapiClient = new OpenApiClient(APP_ID, GATEWAY_URL, APP_RSA_PRIVATE_KEY, GATEWAY_RSA_PUBLIC_KEY);
// Build a request object, set parameters
PayInappOrderRequest request = new PayInappOrderRequest();
request.setMerchant_no("312100007235");
request.setStore_no("4121000078");
request.setPay_method_id("WeChatPay");
request.setMerchant_order_no("TEST_" + System.currentTimeMillis());
request.setPrice_currency("JPY");
request.setOrder_amount(1D);
request.setExpires(300);
request.setAttach("{\"key\":\"value\"}");
request.setNotify_url("https://m.website.com/pay/notify");
request.setTerm_ip("127.0.0.1");
request.setDescription("IPhone 15 5G White");
request.setLatitude("30.5595");
request.setLongitude("22.9375");
request.setSub_appid("wx1234567890");
request.setOs_type("IOS");
PayInappOrderResponse response;
try {
// Execute the request
response = openapiClient.execute(request);
} catch (OpenApiException e) {
// Handle network exceptions ......
// @TODO
System.err.println("\nrequest api error:" + e.getErrCode() + "->>" + e.getErrMsg());
return;
}
if (!response.isSuccess()) {
// Handle business exceptions ......
// @TODO
System.err.println("\napi execute error: " + JSON.toJSONString(response));
}
// Write your business code based on the API response ......
// @TODO
Request
Responses
- 200