[英]Regarding using mock stripe for e2e tests
I came across stripe mock( https://github.com/stripe/stripe-mock ) recently, for local testing,我最近遇到了条纹模拟( https://github.com/stripe/stripe-mock ),用于本地测试,
public PaymentMethod createPaymentMethod(Card card) {
var paymentMethodParams =
PaymentMethodCreateParams.builder()
.setType(Type.CARD)
.setCard(
CardDetails.builder()
.setNumber(card.getNumber())
.setExpMonth((long) card.getExpiryMonth())
.setExpYear((long) card.getExpiryYear())
.setCvc(card.getCvv())
.build())
.build();
var response = testMode? "Make API call to mock stripe with params" : PaymentMethod.create(paymentMethodParams);
return response;
}
Now I do not want to manually make http call to stripe mock server with http client and request body, Is there a way to change something in RequestOptions
or use a different dependency to make the call?现在我不想使用 http 客户端和请求正文手动使 http 调用条带模拟服务器,有没有办法更改
RequestOptions
中的某些内容或使用不同的依赖项进行调用?
Basically, I dont want to do, something like基本上,我不想做,比如
String url = String.format("%s%s", Stripe.getApiBase(), String.format("/v1/payment_methods/%s", ApiResource.urlEncodeId(paymentMethod)));
just somehow override the stripe base API URL.只是以某种方式覆盖条带基础 API URL。
Stripe.overrideApiBase();
is something useful, but its static to stripe java library, I want normal stripe calls to go through, when my e2e tests are running.是有用的,但它的 static 对 java 库进行条带化,我希望在我的 e2e 测试运行时通过对 go 的正常条带调用。
Stripe.overrideApiBase()
is likely what you want; Stripe.overrideApiBase()
可能是您想要的; you'd just want to configure your app to only override it when running end to end tests.您只想将您的应用程序配置为仅在运行端到端测试时覆盖它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.