0
我使用快速结账REST API在Paypal上进行付款。我使用PHP中的CURL成功地检索了我的令牌。然而,实际上进行付款的下一部分不起作用。PHP | Paypal Rest API | java.lang.NullPointerException
我得到以下错误:
显示java.lang.NullPointerException(我beleive这个错误是来自PayPal?)
我曾尝试通过代码去,但我不明白我在做什么因为它都是简单的结构。
我的代码:
$payment_result_json = array(
"intent" => "sale",
"redirect_urls" => array("return_url" => "http://paypal/paypal_return.php", "cancel_url" => "http://paypal/paypal_cancel.php"),
"payer" => array("payment_method" => "paypal"),
"transactions" => array(
"amount" => array("amount" => array(
"total" => "1", "currency" => "USD", "details" => array(
"subtotal" => "1", "shipping" => "0", "tax" => "1", "shipping_discount" => "0"
)
)),
"item_list" => array("quantity" => "1", "name" => "Item 1", "price" => "1", "currency" => "USD", "description" => "item1 desc","tax" => "1"),
"description" => "Tutoring lesson"
));
$post_headers = array("Authorization: Bearer $retreived_access_token");
$ch = curl_init("https://api.sandbox.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $post_headers);
while(empty($payment_result)){
$payment_result = curl_exec($ch);
}
if(empty($payment_result)){
print curl_error($ch);
}else{
print $payment_result;
}
curl_close($ch);
$payment_result_json = json_decode($payment_result);
print_r($payment_result_json);