/** * Send request to endpoints & receive data * * @param object $obj * * @return object Redirect */ public function initialize($obj) { $param = ["Method" => 'GetExpressCheckout', "version" => parent::API_VERSION, "apiusername" => $obj->getApiUsername(), "apipassword" => $obj->getApiPassword(), "apisignature" => $obj->getApiSignature(), 'TOKEN' => $this->session->get('token')]; $result = $this->sendRequest($this->getEndpoint($obj->getDev()), $param); if (empty($result)) { throw new EmptyResponseException('No Response returned'); } if ($result['Ack'] == 'fail') { throw new AckFailException($result['LONGMESSAGE0']); } return $result; }
/** * Send request to endpoints & receive data * * @param object $obj * @param array $data * * @return object Redirect */ public function initialize($obj, $data) { $param = ["Method" => 'SetExpressCheckout', "version" => parent::API_VERSION, "apiusername" => $obj->getApiUsername(), "apipassword" => $obj->getApiPassword(), "apisignature" => $obj->getApiSignature(), "paymentaction" => 'Sale', "returnUrl" => $obj->getReturnUrl(), "cancelUrl" => $obj->getCancelUrl(), "noShipping" => $obj->getNoShipping(), "PaymentRequest_ItemTotalAmt" => $data['amount'], "paymentRequest_Amt" => $data['amount'], "paymentaction" => 'Sale']; $param = array_merge($param, $obj->setItems($data['items'])); $result = $this->sendRequest($this->getEndpoint($obj->getDev()), $param); if (empty($result)) { throw new EmptyResponseException('No Response returned'); } if ($result['Ack'] == 'fail') { throw new AckFailException($result['LONGMESSAGE0']); } $this->session->set('token', $result['Token']); $this->session->set('paymentAmmount', $param['paymentRequest_Amt']); return Redirect::create($this->getLoginEndpoint($obj->getDev()) . urldecode($result['Token'])); }