Codeigniter - 数字商品贝宝库订阅响应空
Codeigniter - digital goods paypal library subscription response null
我在订阅系统网站上工作,我正在使用 Paypal Digital Goods 类 (https://github.com/thenbrent/paypal-digital-goods),并制作了一个名为 paypal2
的自定义库
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Paypal2
{
public function DatosPaypal($arreglo = array(), $produccion)
{
if (count($arreglo)>0)
{
$idCliente = $arreglo['idcliente'];
$descripcion = $arreglo['descripcion'];
$precio = $arreglo['precio'];
$pagado = $arreglo['pagado'];
$cancelado = $arreglo['cancelado'];
$notificar = $arreglo['notificar'];
$moneda = $arreglo['moneda'];
$usuario = $arreglo['usuario'];
$clave = $arreglo['clave'];
$llave = $arreglo['llave'];
if (!class_exists('PayPal_Digital_Goods',false))
{
require_once APPPATH.'third_party/paypal/paypal-digital-goods.class.php';
if ($produccion == true) {
PayPal_Digital_Goods_Configuration::environment( 'live' );
}
PayPal_Digital_Goods_Configuration::username( $usuario );
PayPal_Digital_Goods_Configuration::password( $clave );
PayPal_Digital_Goods_Configuration::signature( $llave );
PayPal_Digital_Goods_Configuration::return_url( $pagado );
PayPal_Digital_Goods_Configuration::cancel_url( $cancelado );
PayPal_Digital_Goods_Configuration::notify_url( $notificar );
PayPal_Digital_Goods_Configuration::currency( $moneda ); // 3 char character code, must be one of the values here: https://developer.paypal.com/docs/classic/api/currency_codes/
if (!class_exists('PayPal_Subscription', false))
{
require_once APPPATH.'third_party/paypal/paypal-subscription.class.php';
$subscription_details = array(
'description' => $descripcion,
'initial_amount' => $precio,
'amount' => $precio,
'period' => 'Month',
'frequency' => '1',
'total_cycles' => '0',
'user_id' => $idCliente
);
$paypal_subscription = new PayPal_Subscription( $subscription_details );
$respuesta = $paypal_subscription;
return $respuesta;
}
}
}
else
{
return "ERROR";
}
}
}
这是使支付成为可能的控制器功能
function AjaxPagoSubscripcion($plan) //<-Works great
{
$this->load->library('paypal2');
$this->load->model('Usuarios_model');
$this->config->load('PayPal2');
$arreglo = $this->Usuarios_model->DatosPagoSubscripcion($plan);
$PaypalObject = $this->paypal2->DatosPaypal($arreglo, $this->config->config['PPproduction_mode']);
$this->config->set_item('PayPalObject', $PaypalObject);
$data['PayPal'] = $PaypalObject->print_buy_button();
$this->load->view('usuarios/pruebas');
}
function pagos2() //<-Don't know how to get the paypal response or migrate Paypal object
{
$allvariables = get_defined_vars();
$data["Variables"] = $allvariables;
$this->load->view('paypal/pagado');
}
在 subsciption/payment 完成之前效果很好,我不知道如何获得 paypal 响应或在控制器之间迁移 paypal 对象,非常感谢任何帮助。
更新
我做了一些改变,取得了一些进展,但现在它给我这个错误
( ! ) Fatal error: Uncaught exception 'Exception' with message 'Calling PayPal with action CreateRecurringPaymentsProfile has Failed: Profile description is invalid' in G:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224
( ! ) Exception: Calling PayPal with action CreateRecurringPaymentsProfile has Failed: Profile description is invalid in G:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224
这里是接受付款的控制器(错误触发明显 :D )
public function pagado($plan)
{
$this->load->library('paypal2');
$this->load->model('Usuarios_model');
$this->config->load('PayPal2');
$arreglo = $this->Usuarios_model->DatosPagoSubscripcion($plan);
//echo $arreglo->precio;
//echo "<pre>",print_r($arreglo),"</pre>"; exit();
$PaypalObject = $this->paypal2->DatosPaypal($arreglo, $this->config->config['PPproduction_mode']);
$prueba = $PaypalObject->start_subscription();
echo "<pre>",print_r($prueba),"</pre>"; exit();
//$data['PayPal'] = $prueba;
//$data['main_content'] = 'paypal/pagado';
//$this->load->view('includes/'.$this->config->config["tema"].'/template' , $data);
}
终于搞定了,用views里面的代码,不是怎么搞的,总算搞定了
我在订阅系统网站上工作,我正在使用 Paypal Digital Goods 类 (https://github.com/thenbrent/paypal-digital-goods),并制作了一个名为 paypal2
的自定义库if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Paypal2
{
public function DatosPaypal($arreglo = array(), $produccion)
{
if (count($arreglo)>0)
{
$idCliente = $arreglo['idcliente'];
$descripcion = $arreglo['descripcion'];
$precio = $arreglo['precio'];
$pagado = $arreglo['pagado'];
$cancelado = $arreglo['cancelado'];
$notificar = $arreglo['notificar'];
$moneda = $arreglo['moneda'];
$usuario = $arreglo['usuario'];
$clave = $arreglo['clave'];
$llave = $arreglo['llave'];
if (!class_exists('PayPal_Digital_Goods',false))
{
require_once APPPATH.'third_party/paypal/paypal-digital-goods.class.php';
if ($produccion == true) {
PayPal_Digital_Goods_Configuration::environment( 'live' );
}
PayPal_Digital_Goods_Configuration::username( $usuario );
PayPal_Digital_Goods_Configuration::password( $clave );
PayPal_Digital_Goods_Configuration::signature( $llave );
PayPal_Digital_Goods_Configuration::return_url( $pagado );
PayPal_Digital_Goods_Configuration::cancel_url( $cancelado );
PayPal_Digital_Goods_Configuration::notify_url( $notificar );
PayPal_Digital_Goods_Configuration::currency( $moneda ); // 3 char character code, must be one of the values here: https://developer.paypal.com/docs/classic/api/currency_codes/
if (!class_exists('PayPal_Subscription', false))
{
require_once APPPATH.'third_party/paypal/paypal-subscription.class.php';
$subscription_details = array(
'description' => $descripcion,
'initial_amount' => $precio,
'amount' => $precio,
'period' => 'Month',
'frequency' => '1',
'total_cycles' => '0',
'user_id' => $idCliente
);
$paypal_subscription = new PayPal_Subscription( $subscription_details );
$respuesta = $paypal_subscription;
return $respuesta;
}
}
}
else
{
return "ERROR";
}
}
}
这是使支付成为可能的控制器功能
function AjaxPagoSubscripcion($plan) //<-Works great
{
$this->load->library('paypal2');
$this->load->model('Usuarios_model');
$this->config->load('PayPal2');
$arreglo = $this->Usuarios_model->DatosPagoSubscripcion($plan);
$PaypalObject = $this->paypal2->DatosPaypal($arreglo, $this->config->config['PPproduction_mode']);
$this->config->set_item('PayPalObject', $PaypalObject);
$data['PayPal'] = $PaypalObject->print_buy_button();
$this->load->view('usuarios/pruebas');
}
function pagos2() //<-Don't know how to get the paypal response or migrate Paypal object
{
$allvariables = get_defined_vars();
$data["Variables"] = $allvariables;
$this->load->view('paypal/pagado');
}
在 subsciption/payment 完成之前效果很好,我不知道如何获得 paypal 响应或在控制器之间迁移 paypal 对象,非常感谢任何帮助。
更新
我做了一些改变,取得了一些进展,但现在它给我这个错误
( ! ) Fatal error: Uncaught exception 'Exception' with message 'Calling PayPal with action CreateRecurringPaymentsProfile has Failed: Profile description is invalid' in G:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224
( ! ) Exception: Calling PayPal with action CreateRecurringPaymentsProfile has Failed: Profile description is invalid in G:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224
这里是接受付款的控制器(错误触发明显 :D )
public function pagado($plan)
{
$this->load->library('paypal2');
$this->load->model('Usuarios_model');
$this->config->load('PayPal2');
$arreglo = $this->Usuarios_model->DatosPagoSubscripcion($plan);
//echo $arreglo->precio;
//echo "<pre>",print_r($arreglo),"</pre>"; exit();
$PaypalObject = $this->paypal2->DatosPaypal($arreglo, $this->config->config['PPproduction_mode']);
$prueba = $PaypalObject->start_subscription();
echo "<pre>",print_r($prueba),"</pre>"; exit();
//$data['PayPal'] = $prueba;
//$data['main_content'] = 'paypal/pagado';
//$this->load->view('includes/'.$this->config->config["tema"].'/template' , $data);
}
终于搞定了,用views里面的代码,不是怎么搞的,总算搞定了