php - Codeigniter - digital goods paypal library subscription response null -
i working on subscription system web, using paypal digital goods classes (https://github.com/thenbrent/paypal-digital-goods), , made custom library called 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 1 of 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"; } } } and here controller functions made payment possible
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 paypal response or migrate paypal object { $allvariables = get_defined_vars(); $data["variables"] = $allvariables; $this->load->view('paypal/pagado'); } it works great until subsciption/payment done, don't know how paypal response or migrate paypal object between controllers, appreciated.
update
i made changes, , progress, gives me error
( ! ) fatal error: uncaught exception 'exception' message 'calling paypal action createrecurringpaymentsprofile has failed: profile description invalid' in g:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224 ( ! ) exception: calling paypal action createrecurringpaymentsprofile has failed: profile description invalid in g:\wamp\www\serviciosycomprasx\application\third_party\paypal\paypal-digital-goods.class.php on line 224 and here controller accepts payment (where erro triggers obvious :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); }
i did it, using code inside views, not how done, worked finally
Comments
Post a Comment