Notification Reception
API Intro
Notify_Url(Hook): This URL must be configured by 【Notification Config API】 Method: POST
Request
{
"notify_id":"dy2dy42132y421u3423",
"timestamp":1615950072896,
"resource_type":"JSON",
"event_type":"ORDER_STATUS_CHANGED",
"ciphertext":"d12d3er1je12rj12i4123pmkr12n"
}
Request Schema
Parameter | Type | Requried | Description |
---|---|---|---|
notify_id |
String | M | Specifies UUID assigned by PingPong, one order mapping to one notifyId |
timestamp |
string | M | Specifies the time of completing payment in the format of timestamp. |
resource_type |
string | M | The format of the callback information. |
event_type |
string | M | The event that you subscribe to. |
ciphertext |
string | M | Specifies encrypted ciphertext. |
Decryption Sample
import sun.misc.BASE64Decoder;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
public class AESUtil {
public static String decrypt(String input, String key) {
byte[] keyBytes = key.getBytes();
byte[] output = doDecrypt(input, keyBytes);
return new String(output);
}
private static byte[] doDecrypt(String input, byte[] keyBytes) {
try {
Cipher cipher = buildCipher();
cipher.init(2, getSecretKeySpec(keyBytes));
byte[] output = cipher.doFinal(Base64.decodeBase64(input));
return output;
} catch (Exception var4) {
log.error("AESUtil#decrypt异常, input:{}", input, var4);
throw new RuntimeException("解密失败:" + var4.getMessage());
}
}
private static SecretKeySpec getSecretKeySpec(byte[] keyBytes){
return new SecretKeySpec(keyBytes, "AES");
}
private static Cipher buildCipher() {
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
return cipher;
} catch (Exception var2) {
log.error("生成Cipher异常", var2);
throw new RuntimeException("生成Cipher异常:" + var2.getMessage());
}
}
}
API Attention
- When interacting with this API, if the PingPong payment system does not receive a response from the developer`s backend indicating ok or timeout, the PingPong payment system will consider it as an unreceived notification and initiate further payment result notifications at a regular interval, such as 12 times in 1 hour, so as to ensure successful receipt. However, the PingPong payment system cannot ensure successful receipt of payment notifications in every case. (Notification frequency: 5/10/20/40/80/160/320/640/1280/2560s)
- As payment result notifications may be sent from the PingPong payment system to the developer’s backend multiple times, a single payment result might be notified to the developer's backend multiple times. For this reason, the Merchant's system must be able to handle duplicate notifications properly.
- when a notification is received and processed,you should be checked first to confirm whether the payment result has previously been processed or not.
Event Detail After decrypting the CipherText field you get the following object
1:ORDER_STATUS_CHANGED
{
"order_id":"W02202101061300335539414",
"order_type":"WITHDRAW",
"status":"SUCCESS",
"description":"XXXX1",
"reference":"XXXX1",
"from_account_id":"ba011911200012205085",
"to_account_id":"ba011911200012205085",
"partner_order_id":"qxxxxxxxxxxxxx123",
"fx_rate": 2.333,
"partner_order_id": "aadsasdfas",
"fail_reason": "RISK_DECLINED",
"order_amount":{
"amount":20.22,
"currency":"USD"
},
"fee":{
"amount":654,
"currency":"CHY"
},
"detail":{
"target_amount":654,
"target_currency":"CHY"
},
"create_time":1619681452644,
"finish_time":1619681452644
}
2:RECIPIENT_STATUS_CHANGED
2.1:Recipient
{
"biz_id":"su202012241148430252000001",
"status":"AVAILABLE",
"reason":"XXXXX"
}
2.2:Beneficiary
{
"biz_id":"ba011911200012205085",
"status":"AVAILABLE",
"reason":"XXXXX"
}