0

我正在尝试按照文档在本文档中为 Simple Order 生成 p12 密钥: https ://developer.cybersource.com/library/documentation/dev_guides/security_keys/creating_and_using_security_keys.pdf

但是,文档似乎与网络资源管理 UI 的功能相去甚远。我确实得到了一个 p12 密钥,它已添加到我的本地密钥库(macos)中。但是,当将此密钥用于以下情况时,通信似乎失败:

There was an unexpected error (type=Internal Server Error, status=500).
io.sphere.sdk.client.BadGatewayException: detailMessage: {"statusCode":502,"message":"The extension returned update actions that could not be executed.","errors":[{"code":"ExtensionUpdateActionsFailed","message":"The extension returned update actions that could not be executed.","extensionErrors":[{"code":"InvalidOperation","message":"Field definition for 'reason' does not exist on type 'isv_payment_failure'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension"},{"code":"RequiredField","message":"A value is required for field 'reasonCode'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension","field":"reasonCode"},{"code":"RequiredField","message":"A value is required for field 'transactionId'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension","field":"transactionId"}]}]} summary: POST https://api.europe-west1.gcp.commercetools.com/cys/me/payments/8dd08a81-df1f-42f8-9bce-eca95fbf9b98 failed with response code 502 on 2020-11-25T12:49:09.730464Z http response formatted body: { "statusCode" : 502, "message" : "The extension returned update actions that could not be executed.", "errors" : [ { "code" : "ExtensionUpdateActionsFailed", "message" : "The extension returned update actions that could not be executed.", "extensionErrors" : [ { "code" : "InvalidOperation", "message" : "Field definition for 'reason' does not exist on type 'isv_payment_failure'.", "action" : { "action" : "addInterfaceInteraction", "type" : { "typeId" : "type", "key" : "isv_payment_failure" }, "fields" : { "reason" : "com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'" } }, "extensionId" : "3275732b-0798-45f7-a1c9-af03102309dc", "extensionKey" : "isv_payment_update_extension" }, { "code" : "RequiredField", "message" : "A value is required for field 'reasonCode'.", "action" : { "action" : "addInterfaceInteraction", "type" : { "typeId" : "type", "key" : "isv_payment_failure" }, "fields" : { "reason" : "com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'" } }, "extensionId" : "3275732b-0798-45f7-a1c9-af03102309dc", "extensionKey" : "isv_payment_update_extension", "field" : "reasonCode" }, { "code" : "RequiredField", "message" : "A value is required for field 'transactionId'.", "action" : { "action" : "addInterfaceInteraction", "type" : { "typeId" : "type", "key" : "isv_payment_failure" }, "fields" : { "reason" : "com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'" } }, "extensionId" : "3275732b-0798-45f7-a1c9-af03102309dc", "extensionKey" : "isv_payment_update_extension", "field" : "transactionId" } ] } ] } http response: io.sphere.sdk.http.HttpResponseImpl@4d23eda6[statusCode=502,headers={date=[Wed, 25 Nov 2020 12:49:09 GMT], content-length=[1588], server=[istio-envoy], x-envoy-upstream-service-time=[896], Alt-Svc=[clear], access-control-allow-headers=[Accept, Authorization, Content-Type, Origin, User-Agent, X-Correlation-ID], x-correlation-id=[cys/42d52d8f-4f20-4965-b645-c80fcf384b3b], x-http-status-caused-by-extension=[true], access-control-allow-methods=[GET, POST, DELETE, OPTIONS], Via=[1.1 google], access-control-allow-origin=[*], access-control-max-age=[299], content-type=[application/json; charset=utf-8], server-timing=[projects;dur=895]},associatedRequest=<null>,textInterpretedBody={"statusCode":502,"message":"The extension returned update actions that could not be executed.","errors":[{"code":"ExtensionUpdateActionsFailed","message":"The extension returned update actions that could not be executed.","extensionErrors":[{"code":"InvalidOperation","message":"Field definition for 'reason' does not exist on type 'isv_payment_failure'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension"},{"code":"RequiredField","message":"A value is required for field 'reasonCode'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension","field":"reasonCode"},{"code":"RequiredField","message":"A value is required for field 'transactionId'.","action":{"action":"addInterfaceInteraction","type":{"typeId":"type","key":"isv_payment_failure"},"fields":{"reason":"com.cybersource.ws.client.ClientException: Exception while obtaining private key from KeyStore with alias, 'test_ct_02'"}},"extensionId":"3275732b-0798-45f7-a1c9-af03102309dc","extensionKey":"isv_payment_update_extension","field":"transactionId"}]}]}] SDK: 1.44.0 project: cys endpoint: POST /me/payments/8dd08a81-df1f-42f8-9bce-eca95fbf9b98 Java: 11.0.9.1 cwd: /Users/yoann.esnaud/workspace/cymbal/simulator sphere request: isv.commercetools.simulator.sphere.sdk.commands.payment.MyPaymentUpdateCommand@513b57f3 http request: HttpRequestImpl[httpMethod=POST,url=https://api.europe-west1.gcp.commercetools.com/cys/me/payments/8dd08a81-df1f-42f8-9bce-eca95fbf9b98,headers={Authorization=[**removed from output**], User-Agent=[commercetools-jvm-sdk/1.44.0 (AHC/2.1) Java/11.0.9.1+1 (Mac OS X; x86_64)], Accept-Encoding=[gzip], X-Correlation-ID=[cys/42d52d8f-4f20-4965-b645-c80fcf384b3b]},body=io.sphere.sdk.http.StringHttpRequestBody@5f7b5b49[body={"version":2,"actions":[{"action":"addTransaction","transaction":{"amount":{"type":"centPrecision","centAmount":549,"currencyCode":"GBP"},"state":"Initial","type":"Authorization"}}]}]] http request formatted body: { "version" : 2, "actions" : [ { "action" : "addTransaction", "transaction" : { "amount" : { "type" : "centPrecision", "centAmount" : 549, "currencyCode" : "GBP" }, "state" : "Initial", "type" : "Authorization" } } ] } additional notes: [] Javadoc: http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/client/BadGatewayException.html}

谁能帮助如何生成和使用 p12 密钥?

谢谢。

4

1 回答 1

0

我按照这些步骤创建了一个 P12 证书来生成 .p12 密钥。

但是,要使用它(在 ASP.NET 中),请使用 Simple Order API...

在您的项目中创建一个名为“Cyber​​SourceKeys”的文件夹,并将 [merchantid].p12 密钥添加到其中。

创建配置对象,确保设置“KeysDirectory”属性:

var configs = new Configuration
{
    MerchantID = "your_merchant_id",
    KeysDirectory = System.Web.Hosting.HostingEnvironment.MapPath("~/CyberSourceKeys"),
    ServerURL = "https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor"
};

创建请求对象:

var cyberSourceRequest = new RequestMessage
{
    merchantID = "your_merchant_id",
    //fill out the rest of the object
};

调用 API,传入两个变量:

var reply = SoapClient.RunTransaction(configs, cyberSourceRequest);

我使用了此处找到的文档(搜索“keysdirectory”):Simple Order API Development Guide

步骤 4 找到 cybs.keysDirectory 字段并将其值更改为包含您的安全密钥的目录。例如,如果您的密钥在 c:\keys 中,请将字段更改为 .

于 2021-02-19T16:52:20.173 回答