예제 #1
0
 /** @test */
 function it_can_set_the_success_url()
 {
     $redirectFlow = new RedirectFlow();
     $return = $redirectFlow->setSuccessRedirectUrl('http://foo.com/redirect');
     $this->assertSame($redirectFlow, $return);
     $this->assertEquals('http://foo.com/redirect', $redirectFlow->getSuccessRedirectUrl());
 }
예제 #2
0
 /** @test */
 function it_can_be_created_from_an_api_response()
 {
     $redirectFlow = RedirectFlow::fromArray(['id' => 'RE123', 'created_at' => '2014-05-08T17:01:06.000Z', 'scheme' => 'bacs', 'session_token' => 'session_id', 'success_redirect_url' => 'http://www.mywebsite.com/success', 'redirect_url' => 'http://pay.gocardless.dev/flow/RE123', 'links' => ['creditor' => 'CR123', 'mandate' => 'MD123']]);
     $this->assertEquals('RE123', $redirectFlow->getId());
     $this->assertEquals('2014-05-08T17:01:06.000Z', $redirectFlow->getCreatedAt());
     $this->assertEquals('bacs', $redirectFlow->getScheme());
     $this->assertEquals('session_id', $redirectFlow->getSessionToken());
     $this->assertEquals('http://www.mywebsite.com/success', $redirectFlow->getSuccessRedirectUrl());
     $this->assertEquals('http://pay.gocardless.dev/flow/RE123', $redirectFlow->getRedirectUrl());
     $this->assertEquals('CR123', $redirectFlow->getLink('creditor'));
     $this->assertEquals('MD123', $redirectFlow->getLink('mandate'));
 }
예제 #3
0
 /**
  * @see https://developer.gocardless.com/pro/#redirect-flows-complete-a-redirect-flow
  *
  * @param string $id           Redirect Flow ID
  * @param string $sessionToken Session token used to create the flow
  *
  * @return RedirectFlow
  */
 public function completeRedirectFlow($id, $sessionToken)
 {
     try {
         $response = $this->client->post($this->url(self::REDIRECT_FLOWS, $id . '/actions/complete'), ['headers' => $this->headers(), 'body' => json_encode(['data' => ['session_token' => $sessionToken]])]);
         $response = json_decode($response->getBody()->getContents(), true);
     } catch (BadResponseException $ex) {
         $this->handleBadResponseException($ex);
     }
     return RedirectFlow::fromArray($response[self::REDIRECT_FLOWS]);
 }