我正在尝试集成masterpass Api合作伙伴钱包,但是没有关于应用OAuth签名方式的确切文档。你能帮我么?

最佳答案

我过去应用签名的方式是:

我包括在Maven存储库中可用的masterpass商人api:

    <dependency>
        <groupId>com.mastercard.masterpass.merchant</groupId>
        <artifactId>mastercard-masterpass-merchant</artifactId>
        <version>1.0.0</version>
    </dependency>


然后,您需要加载ApiConfig并设置私钥,公钥,主机点和环境。

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);
}

关于java - 如何将OAuth签名应用于Masterpass API合作伙伴钱包服务?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41685288/

10-11 04:20