/** @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'));
 }
Example #2
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]);
 }