Alipay+Alipay+

getAuthCode

The Alipay+ client SDK uses the getAuthCode API to obtain the authorization code from the Mobile Payment Partner (MPP).

Method signature

copy
public interface CommonOAuthService {

    void getAuthCode(CommonOAuthServiceParams params, Callback<CommonOAuthServiceResult> callback);

}

Request parameters

Item

Type

Description

Required

params

CommonOAuthServiceParams

Parameters that are required to obtain the authorization code.

M

callback

Callback

The callback to be invoked after the process to obtain the authorization code ends. See Callback for details.

M

Callback

Item

Type

Description

Required

result

CommonOAuthServiceResult

The result information that is required if the authorization is successful.

O

errorCode

String

The error code that is required if the authorization fails.

O

errorMessage

String

The error message that is required if the request fails.

O

Response parameters

N/A

Sample

Definition of YOUR_OAUTH_SERVICE_CLASS:

copy
public class YOUR_OAUTH_SERVICE_CLASS implements CommonOAuthService {
    
    public void getAuthCode(CommonOAuthServiceParams params, Callback<CommonOAuthResult>) {
         
        //Your logic
            
        //On success
        OAuthResult result = new OAuthResult();
        result.authCode = "XXX";
        callback.onSuccess(result);
        
        //On failure
        callback.onFailure(1001, "XXXX");
        
        
    }
    
}

Instance of YOUR_OAUTH_SERVICE_CLASS:

copy
AlipayPlusClient.getInstance().commonOAuthService = new YOUR_OAUTH_SERVICE_CLASS();