Example #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;
 }
Example #2
0
 /** @return DirectLinkPaymentRequest */
 protected function provideMinimalDirectLinkPaymentRequest()
 {
     $directLinkRequest = new DirectLinkPaymentRequest(new FakeShaComposer());
     $directLinkRequest->setPspid('123456');
     $directLinkRequest->setUserId('user_1234');
     $directLinkRequest->setPassword('abracadabra');
     $directLinkRequest->setAmount(100);
     $directLinkRequest->setCurrency('EUR');
     $directLinkRequest->setOrderid('999');
     return $directLinkRequest;
 }
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function IsInvalidWhenFieldsAreMissing()
 {
     $directLinkPaymentRequest = new DirectLinkPaymentRequest(new FakeShaComposer());
     $directLinkPaymentRequest->validate();
 }