-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.14 Bug fix in WeChatDirect Process, added AliPayDirectProcess
- Loading branch information
PayXpert Integration
committed
Feb 26, 2019
1 parent
84f243c
commit 33371b2
Showing
45 changed files
with
3,142 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/main/java/com/payxpert/connect2pay/client/requests/AlipayDirectProcessRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.payxpert.connect2pay.client.requests; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.payxpert.connect2pay.constants.AlipayIdentityCodeType; | ||
import com.payxpert.connect2pay.constants.AlipayPaymentMode; | ||
|
||
import net.sf.oval.constraint.CheckWith; | ||
import net.sf.oval.constraint.CheckWithCheck; | ||
import net.sf.oval.constraint.MaxLength; | ||
import net.sf.oval.constraint.NotNull; | ||
|
||
/** | ||
* Request for the Alipay Direct Process API call. | ||
* | ||
*/ | ||
public class AlipayDirectProcessRequest extends GenericRequest<AlipayDirectProcessRequest> { | ||
@NotNull | ||
@JsonIgnore | ||
private String customerToken; | ||
|
||
@NotNull | ||
private AlipayPaymentMode mode; | ||
|
||
@CheckWith(ignoreIfNull = false, value = IdentityCodeValidator.class) | ||
private AlipayIdentityCodeType identityCodeType; | ||
|
||
@MaxLength(32) | ||
@CheckWith(ignoreIfNull = false, value = IdentityCodeValidator.class) | ||
private String buyerIdentityCode; | ||
|
||
@MaxLength(10) | ||
private String notificationLang; | ||
|
||
@MaxLength(64) | ||
private String notificationTimeZone; | ||
|
||
public String getCustomerToken() { | ||
return customerToken; | ||
} | ||
|
||
public AlipayDirectProcessRequest setCustomerToken(String customerToken) { | ||
this.customerToken = customerToken; | ||
return getThis(); | ||
} | ||
|
||
public AlipayPaymentMode getMode() { | ||
return mode; | ||
} | ||
|
||
public AlipayDirectProcessRequest setMode(AlipayPaymentMode mode) { | ||
this.mode = mode; | ||
return getThis(); | ||
} | ||
|
||
public String getBuyerIdentityCode() { | ||
return buyerIdentityCode; | ||
} | ||
|
||
public AlipayDirectProcessRequest setBuyerIdentityCode(String buyerIdentityCode) { | ||
this.buyerIdentityCode = this.limitLength(buyerIdentityCode, 32); | ||
return getThis(); | ||
} | ||
|
||
public AlipayIdentityCodeType getIdentityCodeType() { | ||
return identityCodeType; | ||
} | ||
|
||
public AlipayDirectProcessRequest setIdentityCodeType(AlipayIdentityCodeType identityCodeType) { | ||
this.identityCodeType = identityCodeType; | ||
return getThis(); | ||
} | ||
|
||
public String getNotificationLang() { | ||
return notificationLang; | ||
} | ||
|
||
public AlipayDirectProcessRequest setNotificationLang(String notificationLang) { | ||
this.notificationLang = this.limitLength(notificationLang, 10); | ||
return getThis(); | ||
} | ||
|
||
public String getNotificationTimeZone() { | ||
return notificationTimeZone; | ||
} | ||
|
||
public AlipayDirectProcessRequest setNotificationTimeZone(String notificationTimeZone) { | ||
this.notificationTimeZone = this.limitLength(notificationTimeZone, 64); | ||
return getThis(); | ||
} | ||
|
||
@Override | ||
protected AlipayDirectProcessRequest getThis() { | ||
return this; | ||
} | ||
|
||
private static class IdentityCodeValidator implements CheckWithCheck.SimpleCheck { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public boolean isSatisfied(Object obj, Object value) { | ||
if (obj != null && AlipayDirectProcessRequest.class.isAssignableFrom(obj.getClass())) { | ||
AlipayDirectProcessRequest request = AlipayDirectProcessRequest.class.cast(obj); | ||
|
||
if (AlipayPaymentMode.APP.equals(request.mode) && value == null) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
133 changes: 133 additions & 0 deletions
133
src/main/java/com/payxpert/connect2pay/client/response/AlipayDirectProcessResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package com.payxpert.connect2pay.client.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.payxpert.connect2pay.client.Connect2payClient; | ||
import com.payxpert.connect2pay.client.containers.TransactionAttempt; | ||
import com.payxpert.connect2pay.constants.ResultCode; | ||
|
||
/** | ||
* This class represents the response to a Alipay Direct Process request. | ||
* | ||
*/ | ||
public class AlipayDirectProcessResponse extends GenericResponse<AlipayDirectProcessResponse> { | ||
// Library internal field, not returned by the API call | ||
private ResultCode code; | ||
private String message; | ||
|
||
private String apiVersion; | ||
|
||
private Double exchangeRate; | ||
|
||
private String qrCode; | ||
|
||
private String qrCodeUrl; | ||
|
||
private String webSocketUrl; | ||
|
||
@JsonProperty("transactionID") | ||
private String transactionId; | ||
|
||
private TransactionAttempt transactionInfo; | ||
|
||
/** | ||
* @return the result code | ||
*/ | ||
public ResultCode getCode() { | ||
return code; | ||
} | ||
|
||
/** | ||
* @param code | ||
* the code to set | ||
*/ | ||
public void setCode(ResultCode code) { | ||
this.code = code; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
/** | ||
* The API version for the response | ||
*/ | ||
public String getApiVersion() { | ||
return apiVersion; | ||
} | ||
|
||
public void setApiVersion(String apiVersion) { | ||
this.apiVersion = apiVersion; | ||
} | ||
|
||
/** | ||
* @return The currency exchange rate between the payment currency and RMB | ||
*/ | ||
public Double getExchangeRate() { | ||
return exchangeRate; | ||
} | ||
|
||
public void setExchangeRate(Double exchangeRate) { | ||
this.exchangeRate = exchangeRate; | ||
} | ||
|
||
/** | ||
* @return The QR code as PNG base64 encoded | ||
*/ | ||
public String getQrCode() { | ||
return qrCode; | ||
} | ||
|
||
public void setQrCode(String qrCode) { | ||
this.qrCode = qrCode; | ||
} | ||
|
||
/** | ||
* @return The URL to embed in a QR code | ||
*/ | ||
public String getQrCodeUrl() { | ||
return qrCodeUrl; | ||
} | ||
|
||
public void setQrCodeUrl(String qrCodeUrl) { | ||
this.qrCodeUrl = qrCodeUrl; | ||
} | ||
|
||
/** | ||
* @return The URL of the WebSocket to monitor the payment status in real time | ||
*/ | ||
public String getWebSocketUrl() { | ||
return webSocketUrl; | ||
} | ||
|
||
public void setWebSocketUrl(String webSocketUrl) { | ||
this.webSocketUrl = webSocketUrl; | ||
} | ||
|
||
/** | ||
* @return The identifier of the generated transaction, can be used to poll the transaction information | ||
* @see Connect2payClient#getTransactionInfo(com.payxpert.connect2pay.client.requests.TransactionInfoRequest) | ||
*/ | ||
public String getTransactionId() { | ||
return transactionId; | ||
} | ||
|
||
public void setTransactionId(String transactionId) { | ||
this.transactionId = transactionId; | ||
} | ||
|
||
/** | ||
* @return The information about the processed transaction (APP mode only) | ||
*/ | ||
public TransactionAttempt getTransactionInfo() { | ||
return transactionInfo; | ||
} | ||
|
||
public void setTransactionInfo(TransactionAttempt transactionInfo) { | ||
this.transactionInfo = transactionInfo; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/payxpert/connect2pay/constants/AlipayIdentityCodeType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.payxpert.connect2pay.constants; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* The Alipay identity code types available for Alipay direct process call | ||
* | ||
*/ | ||
public enum AlipayIdentityCodeType { | ||
/** | ||
* QR code | ||
*/ | ||
QRCODE, | ||
|
||
/** | ||
* Bar code | ||
*/ | ||
BARCODE; | ||
|
||
@JsonValue | ||
public String getFormattedName() { | ||
return this.name().toLowerCase(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/payxpert/connect2pay/constants/AlipayPaymentMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.payxpert.connect2pay.constants; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* The Alipay modes available for Alipay direct process call | ||
* | ||
*/ | ||
public enum AlipayPaymentMode { | ||
/** | ||
* POS mode: the payer scans the merchant's QR codes | ||
*/ | ||
POS, | ||
|
||
/** | ||
* APP mode: The merchant scans the payer's QR code | ||
*/ | ||
APP; | ||
|
||
@JsonValue | ||
public String getFormattedName() { | ||
return this.name().toLowerCase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.