我在尝试通过Stripe将测试付款转帐到测试银行帐户时收到此错误
我的边缘代码:
<html>
<head>
<script type="text/javascript" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">
Stripe.setPublishableKey('//key//');
</script>
</head>
<body>
<form action="Payout" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-row">
<label>
<span>Card Number</span>
<input type="text" size="20" data-stripe="number">
</label>
</div>
<div class="form-row">
<label>
<span>Expiration (MM/YY)</span>
<input type="text" size="2" data-stripe="exp_month">
</label>
<span> / </span>
<input type="text" size="2" data-stripe="exp_year">
</div>
<div class="form-row">
<label>
<span>CVC</span>
<input type="text" size="4" data-stripe="cvc">
</label>
</div>
<input type="submit" class="submit" value="Submit Payment">
</form>
<script>
$(function() {
var $form = $('#payment-form');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from being submitted:
return false;
});
});
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
if (response.error) { // Problem!
// Show the errors on the form:
$form.find('.payment-errors').text(response.error.message);
$form.find('.submit').prop('disabled', false); // Re-enable submission
} else { // Token was created!
// Get the token ID:
var token = response.id;
// Insert the token ID into the form so it gets submitted to the server:
$form.append($('<input type="hidden" name="stripeToken">').val(token));
// Submit the form:
$form.get(0).submit();
}
};
</script>
</body>
</html>
我的servlet是:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
//processRequest(request, response);
Stripe.apiKey = "//test key//";
// Get the card details submitted by the form
String tokenID = request.getParameter("stripeToken");
// Create a Recipient
Map<String, Object> recipientParams = new HashMap<String, Object>();
recipientParams.put("name", "Lord");
recipientParams.put("type", "individual");
recipientParams.put("card", tokenID);
recipientParams.put("email", "test6@gmail.com");
Recipient recipient = Recipient.create(recipientParams);
Map<String, Object> transferParams = new HashMap<String, Object>();
transferParams.put("amount", 1000); // amount in cents
transferParams.put("currency", "usd");
transferParams.put("recipient", recipient);
transferParams.put("bank_account", "000123456789");
transferParams.put("statement_descriptor", "JULY SALES");
Transfer transfer = Transfer.create(transferParams);
System.out.print("hi");
RequestDispatcher view = request.getRequestDispatcher("index2.html");
view.forward(request, response);
} catch (AuthenticationException ex) {
Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvalidRequestException ex) {
Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
} catch (APIConnectionException ex) {
Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
} catch (CardException ex) {
Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
} catch (APIException ex) {
Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
}
}
我收到错误接收器未找到,我不明白为什么。有人可以帮忙吗?我对此深感震惊。
Stack Trace:
SEVERE: com.stripe.exception.InvalidRequestException: No such recipient: <com.stripe.model.Recipient@1975641541 id=rp_186thkGbhnSWFx0lIDZm2cmQ> JSON: {
"id": "rp_186thkGbhnSWFx0lIDZm2cmQ",
"active_account": null,
"cards": {
"data": [
{
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"currency": null,
"cvc_check": "pass",
"default_for_currency": null,
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2017,
"fingerprint": "qhUUS5Kf5JM2a8L8",
"funding": "debit",
"last4": "5556",
"name": null,
"recipient": "rp_186thkGbhnSWFx0lIDZm2cmQ",
"status": null,
"tokenization_method": null,
"type": null,
"id": "card_186thjGbhnSWFx0lu8w3m1Sq",
"object": "card",
"account": null,
"customer": null,
"metadata": {}
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/recipients/rp_186thkGbhnSWFx0lIDZm2cmQ/cards",
"count": null,
"request_options": null,
"request_params": null
},
"created": 1462244168,
"default_card": "card_186thjGbhnSWFx0lu8w3m1Sq",
"deleted": null,
"description": null,
"email": "test@gmail.com",
"livemode": false,
"metadata": {},
"migrated_to": null,
"name": "Lord Blue",
"type": "individual",
"verified": false
}; request-id: req_8Nf12m7y81JQlC
at com.stripe.net.LiveStripeResponseGetter.handleAPIError(LiveStripeResponseGetter.java:591)
at com.stripe.net.LiveStripeResponseGetter._request(LiveStripeResponseGetter.java:443)
at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:65)
at com.stripe.net.APIResource.request(APIResource.java:133)
at com.stripe.model.Transfer.create(Transfer.java:359)
at com.stripe.model.Transfer.create(Transfer.java:318)
at pay.Payout.doPost(Payout.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:724)
答案 0 :(得分:3)
看起来您尝试进行转移的方式已被弃用。
此处记录了这些内容:https://stripe.com/docs/sending-transfers
我能够使用以下步骤进行成功的测试转移:
当我没有足够的时候,我收到了这个错误:
com.stripe.exception.InvalidRequestException:资金不足 条纹帐户。在测试模式下,您可以为可用资金添加资金 通过创建费用来平衡(绕过您的未结余额) 4000 0000 0000 0077作为卡号。你可以使用 / v1 / balance endpoint可查看条带余额(有关详细信息, 见stripe.com/docs/api#balance)。; request-id:req _ ***************
我运行以下代码将1000美元存入我的手中:
grep
要创建新帐户,您需要注册您的平台,您可以在https://dashboard.stripe.com/account/applications/settings执行此操作。
如果没有,您将收到“invalid_request_error”
按照创建转移的新方法。通过查看github上的StripeTest.java,我能够找到它。
这是我的测试:
w3m -dump