我们在PayPal的支付过程中遇到了问题。有时用户在被重定向到PayPal时会出现错误,但大多数情况下不会。因为这似乎并不取决于他们使用的设备,我不知道该怎么做。这个问题出现在每第三次paypal支付,如果客户再次发送订单,它在第二次或第三次尝试。
我们使用PayPal PHP管理器由杰里米Desvaux在一个非基于购物软件的网站。这意味着没有框架,一切都是由我们的开发人员编写的。
有谁说自己是paypal天才来帮助我们吗?
尝试使用PayPal付款时错误消息:
在php代码致命错误:不能使用类型为PayPal'Api'Links的对象作为数组/Checkout.php第721行
正如您所看到的,在第一行中有一个注释,这是我们的开发人员通过使用getApprovalLink方法来修复该问题的尝试。
//$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第一次重定向崩溃,第二次重定向用户成功
编辑:这是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;
}
}
编辑2:
现在我使用$payment->links->getHref()
而不是$payment->links[1]["href"]
,我得到了以下错误:
致命错误:在非对象上调用成员函数getHref() . ./Checkout.php 联机 722
这很奇怪,因为它看起来既不是对象的方法,也不是数组。
有什么想法吗?
可以张贴Paypal'Api'Links类吗?当链接是一个对象时,您试图将其作为数组访问。这意味着Links属性设置不正确,或者需要将其视为对象而不是数组。