Php 第一个PayPal重定向以错误结束”;无法使用类型为的对象。。。“作为数组”;
关于贝宝,我们的付款流程有问题。有时用户在被重定向到PayPal时会出错,大多数情况下不会。因为这似乎不取决于他们使用的设备,我不知道该怎么做。这个问题会在第三次PayPal付款时出现,如果客户再次发送订单,则会在第二次或第三次尝试时出现 我们在一个基于非商店软件的网站上使用Jeremy Desvaux的PayPal PHP管理器。这意味着没有框架,一切都是由我们的开发人员编写的 有没有人自称是贝宝天才来帮助我们 尝试使用PayPal支付时出现错误消息: 致命错误:无法将PayPal\Api\Links类型的对象用作中的数组 …/Checkout.php,第721行 PHP代码 正如您所看到的,在第一行中有一条注释,这是我们的开发人员尝试使用getApprovalLink方法修复该问题Php 第一个PayPal重定向以错误结束”;无法使用类型为的对象。。。“作为数组”;,php,redirect,paypal,Php,Redirect,Paypal,关于贝宝,我们的付款流程有问题。有时用户在被重定向到PayPal时会出错,大多数情况下不会。因为这似乎不取决于他们使用的设备,我不知道该怎么做。这个问题会在第三次PayPal付款时出现,如果客户再次发送订单,则会在第二次或第三次尝试时出现 我们在一个基于非商店软件的网站上使用Jeremy Desvaux的PayPal PHP管理器。这意味着没有框架,一切都是由我们的开发人员编写的 有没有人自称是贝宝天才来帮助我们 尝试使用PayPal支付时出现错误消息: 致命错误:无法将PayPal\Api\L
//$redirectUrl = $payment->getApprovalLink();
$redirectUrl = $payment->links[1]["href"];
$paymentID = $payment->id;
$sql = sprintf("INSERT INTO exampleTable VALUES (%d, '%s')", $this->exampleValue1, $exampleValue2);
$this->MainDB->query($sql);
header("Location: ".$redirectUrl);
exit;
break;
我还发现了一个问题,可能是关于同一个问题,但没有得到帮助的答案
编辑:
这是PayPal\Api\Links类
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class Links
*
*
*
* @package PayPal\Api
*
* @property string href
* @property string rel
* @property \PayPal\Api\HyperSchema targetSchema
* @property string method
* @property string enctype
* @property \PayPal\Api\HyperSchema schema
*/
class Links extends PayPalModel
{
/**
* Sets Href
*
* @param string $href
*
* @return $this
*/
public function setHref($href)
{
$this->href = $href;
return $this;
}
/**
* Gets Href
*
* @return string
*/
public function getHref()
{
return $this->href;
}
/**
* Sets Rel
*
* @param string $rel
*
* @return $this
*/
public function setRel($rel)
{
$this->rel = $rel;
return $this;
}
/**
* Gets Rel
*
* @return string
*/
public function getRel()
{
return $this->rel;
}
/**
* Sets TargetSchema
*
* @param \PayPal\Api\HyperSchema $targetSchema
*
* @return $this
*/
public function setTargetSchema($targetSchema)
{
$this->targetSchema = $targetSchema;
return $this;
}
/**
* Gets TargetSchema
*
* @return \PayPal\Api\HyperSchema
*/
public function getTargetSchema()
{
return $this->targetSchema;
}
/**
* Sets Method
*
* @param string $method
*
* @return $this
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}
/**
* Gets Method
*
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Sets Enctype
*
* @param string $enctype
*
* @return $this
*/
public function setEnctype($enctype)
{
$this->enctype = $enctype;
return $this;
}
/**
* Gets Enctype
*
* @return string
*/
public function getEnctype()
{
return $this->enctype;
}
/**
* Sets Schema
*
* @param \PayPal\Api\HyperSchema $schema
*
* @return $this
*/
public function setSchema($schema)
{
$this->schema = $schema;
return $this;
}
/**
* Gets Schema
*
* @return \PayPal\Api\HyperSchema
*/
public function getSchema()
{
return $this->schema;
}
}
您可以发布Paypal\Api\Links类吗。当链接是对象时,您尝试以数组的形式访问链接。这意味着Links属性设置不正确,或者需要将其视为对象而不是数组 嗨,勒沃尼尔森,谢谢你的留言。我编辑了这篇文章。根据方法名称和您希望从类中获得的内容,您应该调用getHref()方法。因此,请尝试$payment->links->getHref()而不是$payment->links[1][“href”]。只要设置了href属性,就应该返回所需的值。您可能还需要使用getSchema,我猜它返回http或https。但这里的问题似乎是将链接视为对象而不是数组。虽然它不能解释为什么它有时有效,而其他的却不行。除非代码只有在满足某些条件时才能运行。谢谢-我们将尝试一下,看看它是否有效。但是正如您已经提到的,它在第二次尝试中起作用是很奇怪的,因为指向href的方式仍然是一个数组<代码>$redirectUrl=$payment->links[1][“href”]代码>现在我使用了$payment->links->getHref()
而不是$payment->links[1][“href”]
我又遇到了一个错误。请参阅文章中的我的更新(编辑2)。