REST API-MALFORMED_REQUEST问题

时间:2019-01-22 11:56:22

标签: php paypal-rest-sdk

REST API出现问题。其返回的MALFORMED_REQUEST:“传入的JSON请求未映射到API请求”,我无法弄清楚自己在做什么错。遍历了代码,似乎看不出问题出在哪里。我已经输出了异常中getData的内容,但是它并没有给我任何关于问题可能出在哪里的想法。我敢肯定它会很简单,但是我找不到它。

我已经输出了异常中getData的内容,但是除了错误本身之外,它没有让我知道问题可能在哪里

java.lang.IllegalStateException: C (result) array is not F order or is a view. Nd4j.gemm requires the result array to be F order and not a view. C (result) array: [Rank: 2,Offset: 0 Order: f Shape: [10,1],  stride: [1,10]]
    at org.nd4j.base.Preconditions.throwStateEx(Preconditions.java:641)
    at org.nd4j.base.Preconditions.checkState(Preconditions.java:304)
    at org.nd4j.linalg.factory.Nd4j.gemm(Nd4j.java:980)
    at org.deeplearning4j.nn.layers.recurrent.LSTMHelpers.backpropGradientHelper(LSTMHelpers.java:696)
    at org.deeplearning4j.nn.layers.recurrent.LSTM.backpropGradientHelper(LSTM.java:122)
    at org.deeplearning4j.nn.layers.recurrent.LSTM.backpropGradient(LSTM.java:93)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.calcBackpropGradients(MultiLayerNetwork.java:1826)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.computeGradientAndScore(MultiLayerNetwork.java:2644)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.computeGradientAndScore(MultiLayerNetwork.java:2587)
    at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore(BaseOptimizer.java:160)
    at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize(StochasticGradientDescent.java:63)
    at org.deeplearning4j.optimize.Solver.optimize(Solver.java:52)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fitHelper(MultiLayerNetwork.java:1602)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fit(MultiLayerNetwork.java:1521)
    at org.mmarini.lstmtest.TestTrainingTest.testBuild(TestTrainingTest.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:171)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:167)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:108)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

object(PayPal\Api\Item)#8 (1) { ["_propMap":"PayPal\Common\PayPalModel":private]=> array(5) { ["name"]=> string(29) "5155 Tranport Request Deposit" ["currency"]=> string(3) "EUR" ["quantity"]=> int(1) ["sku"]=> string(4) "5155" ["price"]=> string(2) "10" } } object(PayPal\Api\ItemList)#9 (1) { ["_propMap":"PayPal\Common\PayPalModel":private]=> array(1) { ["items"]=> array(1) { [0]=> object(PayPal\Api\Item)#8 (1) { ["_propMap":"PayPal\Common\PayPalModel":private]=> array(5) { ["name"]=> string(29) "5155 Tranport Request Deposit" ["currency"]=> string(3) "EUR" ["quantity"]=> int(1) ["sku"]=> string(4) "5155" ["price"]=> string(2) "10" } } } } } object(stdClass)#15 (4) { ["name"]=> string(17) "MALFORMED_REQUEST" ["message"]=> string(49) "Incoming JSON request does not map to API request" ["information_link"]=> string(74) "https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST" ["debug_id"]=> string(13) "7bd31dedb98ef" }

引导文件

use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
require 'ppbootstrap.php';
if (empty($_POST['item_number'])) {
    throw new Exception('This script should not be called directly, expected post data');
}

$currency = 'EUR';
$amountPayable = 10.00;
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$desc = $_POST['item_number'].' Tranport Request Deposit';
$inv = $_POST['item_number'];

//Create the item
$item = new Item();
$item->setName($desc)
    ->setCurrency($currency)
    ->setQuantity(1)
    ->setSku($inv)
    ->setPrice($amountPayable);

$itemList = new ItemList();
$itemList->setItems(array($item));
var_dump($item);
var_dump($itemList);


$amount = new Amount();
$amount->setCurrency($currency)
    ->setTotal($amountPayable);


$transaction = new Transaction();
$transaction->setAmount($amountPayable)
    ->setItemList($itemList)
    ->setDescription($desc)
    ->setInvoiceNumber($inv);


$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($paypalConfig['return_url'])
    ->setCancelUrl($paypalConfig['cancel_url']);


$payment = new Payment();
$payment->setIntent('sale')
    ->setPayer($payer)
    ->setTransactions(array($transaction))
    ->setRedirectUrls($redirectUrls);

$request = clone $payment;

try {
    $payment->create($apiContext);
} catch (PayPal\Exception\PayPalConnectionException $e) {


var_dump(json_decode($e->getData()));
//throw new Exception($e);
//echo $e->getCode(); 
//echo '<br /><br />';
//echo $e->getData();
//echo '<br /><br />';
//var_dump($request);
die($e);
}
header('location:' . $payment->getApprovalLink());
exit(1);

0 个答案:

没有答案