/** * @inheritdoc */ public function callPaymentRequest(PaymentRequestNeeds $needs) { try { if (!$needs->isVerified()) { throw new InvalidPaymentNeedsException(); } $response = $this->getClient()->PaymentRequest($this->serializePaymentRequest($needs)); if ($response->Status !== 100) { throw new PaymentGatewayResponseException(); } // Create PaymentResponse with // `payment_url` and `authority` fields return (new PaymentRequestResponse($this->generatePaymentUrl($response->Authority)))->set('authority', $response->Authority); } catch (\Exception $e) { if ($e instanceof PaymentGatewayException) { throw $e; } throw new PaymentGatewayBadRequestException($e->getMessage(), $e->getCode(), $e); } }