必填字段缺失。 PHP Paypal REST API

问题描述:

我目前正在尝试使用PHP PayPal REST API。但是,似乎我无法通过交易传递项目列表,因为“缺少必填字段”。必填字段缺失。 PHP Paypal REST API

$item = new Item(); 
$item->setQuantity("1"); 
$item->setName("stuff"); 
$item->setPrice("305.00"); 
$item->setCurrency("USD"); 

$amount = new Amount(); 
$amount->setCurrency("USD"); 
$amount->setTotal("305.00"); 

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

$transaction = new Transaction(); 
$transaction->setAmount($amount); 
$transaction->setDescription("This is incredibly awesome."); 
$transaction->setItem_list($item_list); 

我充满所有PayPal的文档认为是“必需的”按文档(https://developer.paypal.com/webapps/developer/docs/api/#common-objects)在“通用对象”的字段。

例外:GOT HTTP响应代码400访问 https://api.sandbox.paypal.com/v1/payments/payment的时候,但我当我尝试重定向到贝宝开始交易我被抛出此错误。字符串(269) “{”name“:”VALIDATION_ERROR“,”details“:[{”field“:”transactions [0] .item_list.items [0] .sku“,”issue“:”Required field missing “}],” 消息 “:” 无效的请求 - 见 细节 “ ”information_link“:” https://developer.paypal.com/docs/api/#VALIDATION_ERROR “ ”debug_id“: ”9e292fc3a312d“}”

当我注释掉$交易 - > setItem_list( $ item_list);它工作正常。所以很明显,项目列表或项目中缺少某些内容。但我看不到什么。

任何想法?

错误点,你到这一点:

transactions[0].item_list.items[0].sku 

此申请似乎需要我认为它只是需要把SKU的产品阵列,从而让我们做吧: 尝试添加:

$item->setSKU("CODEHERE"); 

$item->setCurrency("USD"); 
+0

我不能相信我忘了那个。谢谢。 – Sefam 2013-04-18 06:12:15

+1

欢迎你的家伙 – Fabio 2013-04-18 06:13:16