如何将OAuth签名应用于Masterpass API合作伙伴钱包服务?

时间:2017-01-16 21:30:31

标签: java api mastercard

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

1 个答案:

答案 0 :(得分:0)

我以前申请签名的方式是:

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