我正在尝试集成 masterpass Api Partner 钱包,但没有关于应用 OAuth 签名方式的确切文档。你能帮我么?
问问题
437 次
1 回答
1
我用来应用签名的方式是:
我包括了 masterpass 商家 api,在 maven 存储库中可用:
<dependency>
<groupId>com.mastercard.masterpass.merchant</groupId>
<artifactId>mastercard-masterpass-merchant</artifactId>
<version>1.0.0</version>
</dependency>
然后需要加载ApiConfig并设置私钥、公钥、Host点和环境。
ApiConfig apiConfig = null;
try {
apiConfig = new ApiConfigBuilder()
.consumerKey(MASTERPASS_CONSUMER_KEY)
.privateKey(MASTERPASS_PRIVATE_KEY)
.hostUrl(MASTERPASS_HOST)
.name(MASTERPASSS_ENVIRONMENT).build();
} catch (Exception e) {
logger.error("[Error]Error loading masterpass Api Config: {}", e.getMessage());
}
配置完这些之后,现在就可以调用 ApiClient 表单 masterpass 库了:
ApiClient client = new ApiClient(apiConf);
ServiceRequest<?> request = new ServiceRequest<>();
request.contentType(MediaType.APPLICATION_XML);
request.requestBody(shippingAddressRequest);
ShippingAddressVerificationResponse response = null;
try {
response = client.call(masterpassEndpoint, request, HttpMethod.POST , ShippingAddressVerificationResponse.class);
} catch (Exception e) {
logger.error("[Error]ShippingAddressVerificationResponse]"+
"Error: There was an exception validating the shipping address: {}", e.getMessage() , e);
}
于 2017-01-16T21:41:30.470 回答