1

我的订阅系统网络上工作,我使用贝宝数字商品类(https://github.com/thenbrent/paypal-digital-goods),并提出所谓paypal2笨 - 数字商品的PayPal图书馆订阅响应空

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 /支付完成后,我不知道如何让PayPal的响应或迁移控制器之间的贝宝的对象,任何帮助将是非常赞赏。

UPDATE

我做了一些改变,并取得了一些进展,但现在它给了我这个错误

(!) 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); 
    } 
+0

使用它,终于取得了一些进展,但我现在得到这个错误:配置文件描述无效 – 2015-04-01 22:12:36

回答

0

我终于做到了,使用的意见里面的代码,是不是怎么做,但终于摸索