/** * Tests the exception trigger in the create request method * @test * @expectedException \Paymill\Services\PaymillException * @expectedExceptionMessage Undefined Error. This should not happen! */ public function createExceptionTest() { $outputArray = array(); $outputArray['header']['status'] = 500; $this->_getCurlMock($this->_client->getServiceResource() . $this->_client->getId(), $this->_client->parameterize("create"), "POST", $outputArray); $this->_client = $this->_request->create($this->_client); }
/** * Create new Transaction with a set of params * * @param string $amount amount as int (ex: 4200 for 42.00) * @param string $currency currency code (EUR, USD...) * @param string $token transaction token * @param string $description transaction description (optional, default "") * * @return \Paymill\Models\Response\Base * * @throws PaymillException if transaction creation fails */ public function create($amount, $currency, $token, $description = "") { $service = new Request($this->apiKey); $transaction = new RequestTransaction(); $transaction->setAmount($amount)->setCurrency($currency)->setToken($token)->setDescription($description); /** * @var \Paymill\Models\Response\Base $response */ $response = $service->create($transaction); return $response; }
/** * @param $email * @param $details * * @return bool|string */ public function createClient($email, $details) { $client = new \Paymill\Models\Request\Client(); $client->setEmail($email); $client->setDescription($details); try { $response = $this->request->create($client); } catch (\Paymill\Services\PaymillException $e) { s($e->getResponseCode()); s($e->getStatusCode()); s($e->getErrorMessage()); return false; } return $response->getId(); }
/** * {@inheritDoc} * * @param Transaction $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); if (!isset($details['token']) || empty($details['token'])) { throw new LogicException('The token has to be set.'); } try { $transaction = new \Paymill\Models\Request\Transaction(); $transaction->setAmount($details['amount'])->setCurrency($details['currency'])->setDescription($details['description'])->setToken($details['token']); $requestPaymill = new Request($this->api->getPrivateKey()); $requestPaymill->create($transaction); $responsePaymill = $requestPaymill->getLastResponse(); $details['http_status_code'] = 200; $details['transaction'] = $responsePaymill['body']['data']; } catch (PaymillException $e) { $details['http_status_code'] = $e->getStatusCode(); $details['error'] = $e->getResponseCode(); $details['errorMessage'] = $e->getMessage(); $details['errorResponse'] = $e->getRawObject(); } $request->setModel($details); }
public function paymill($token) { $apiKey = Config::get('paymill.test.private_key'); $request = new \Paymill\Request($apiKey); // var_dump($request); $transaction = Paymill::Transaction(); //return Paymill::Client('client_8127a65bf3c84676c918')->details(); //return Paymill::Payment()->create('098f6bcd4621d373cade4e832627b4f6'); $preAuth = new \Paymill\Models\Request\Preauthorization(); $preAuth->setToken($token)->setAmount(4200)->setCurrency('EUR')->setDescription('description example'); $response = $request->create($preAuth); // try { // Paymill::Transaction() // ->setAmount(4200) // ->setCurrency('EUR') // ->setPayment('pay_9266f049d59767f3175cc17a') // ->setDescription('Test Transaction') // ->create(); // } catch(PaymillException $e) { // $e->getResponseCode(); // $e->getStatusCode(); // $e->getErrorMessage(); // } }