Exemplo n.º 1
0
 /**
  * @test
  * @depends AliasCreationIsSuccessful
  */
 public function DirectLinkPaymentIsSuccessful($alias)
 {
     $passphrase = new Passphrase(PASSPHRASE_SHA_IN);
     $shaComposer = new AllParametersShaComposer($passphrase);
     $directLinkRequest = new DirectLinkPaymentRequest($shaComposer);
     $orderId = uniqid('order_');
     // create a unique order id
     $directLinkRequest->setOrderid($orderId);
     $alias = new Alias($alias);
     $directLinkRequest->setPspid(PSPID);
     $directLinkRequest->setUserId(USERID);
     $directLinkRequest->setPassword(PASSWORD);
     $directLinkRequest->setAlias($alias);
     $directLinkRequest->setAmount(100);
     $directLinkRequest->setCurrency('EUR');
     $directLinkRequest->setEci(new Eci(Eci::ECOMMERCE_RECURRING));
     $directLinkRequest->validate();
     $body = array();
     foreach ($directLinkRequest->toArray() as $key => $value) {
         $body[strtoupper($key)] = $value;
     }
     $body['SHASIGN'] = $directLinkRequest->getShaSign();
     $client = new Client($directLinkRequest->getOgoneUri());
     $request = $client->post(null, null, $body);
     $response = $request->send();
     $directLinkResponse = new DirectLinkPaymentResponse($response->getBody(true));
     $this->assertTrue($directLinkResponse->isSuccessful());
     return $alias;
 }
 /**
  * @test
  * @dataProvider provideFloats
  */
 public function CorrectlyConvertsFloatAmountsToInteger($string, $integer)
 {
     $xml = $this->provideXML($string);
     $paymentResponse = new DirectLinkPaymentResponse($xml);
     $this->assertEquals($integer, $paymentResponse->getParam('amount'));
 }