예제 #1
0
 /**
  * Paystack constructor.
  *
  * @param $key
  */
 private function __construct($key)
 {
     $this->paystackHttpClient = $this->makePaystackHttpClient($key);
     $this->customerResource = new CustomerResource($this->paystackHttpClient);
     $this->customerModel = new Customer($this->customerResource);
     $this->transactionResource = new TransactionResource($this->paystackHttpClient);
     $this->planResource = new PlanResource($this->paystackHttpClient);
     $this->planModel = new Plan($this->planResource);
     $this->transactionHelper = TransactionHelper::make();
     $this->transactionHelper->setTransactionResource($this->transactionResource);
 }
예제 #2
0
 /**
  * Verify this transaction.
  */
 public function verify()
 {
     return TransactionHelper::make()->verify($this->get('reference'));
 }
 public function testGetTotalsThrowExceptions()
 {
     $invalidResponse = new \stdClass();
     $invalidResponse->message = 'Authorization Not Found';
     $mockTransactionResource = \Mockery::mock($this->transactionResource)->makePartial();
     $mockTransactionResource->shouldReceive('getTransactionTotals')->once()->andReturn(new PaystackUnauthorizedException($invalidResponse, 401));
     $this->setExpectedException(PaystackUnauthorizedException::class);
     $transactionHelper = Transaction::make();
     $transactionHelper->setTransactionResource($mockTransactionResource);
     $this->paystack->setTransactionHelper($transactionHelper);
     $this->paystack->transactionsTotals();
 }
 public function testVerifyTransactionThrowsException()
 {
     $invalidResponse = new \stdClass();
     $invalidResponse->message = 'Authorization Not Found';
     $mockTransactionResource = \Mockery::mock($this->transactionResource)->makePartial();
     $mockTransactionResource->shouldReceive('verify')->once()->andReturn(new PaystackUnauthorizedException($invalidResponse, 401));
     $this->setExpectedException(PaystackUnauthorizedException::class);
     $transactionHelper = Transaction::make();
     $transactionHelper->setTransactionResource($mockTransactionResource);
     $transactionHelper->verify($this->initOneTimeTransactionResourceResponseData['reference']);
 }