/**
  * @test
  */
 public function itShouldBeBankTransfer()
 {
     $paymentMethod = PaymentMethod::fromString(PaymentMethod::BANK_TRANSFER);
     $this->assertTrue($paymentMethod->isBankTransfer());
     $this->assertFalse($paymentMethod->isIdeal());
     $this->assertFalse($paymentMethod->isCreditCard());
 }
 /**
  * @test
  */
 public function itShouldFailWhenAnUnsupportedPaymentMethodIsProvided()
 {
     $paymentMethod = PaymentMethod::fromString(PaymentMethod::IDEAL);
     $reflectionClass = new \ReflectionClass('GingerPayments\\Payment\\Order\\Transaction\\PaymentMethod');
     $reflectionProperty = $reflectionClass->getProperty('value');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($paymentMethod, 'very-unsupported-method');
     $this->setExpectedException('InvalidArgumentException');
     PaymentMethodDetailsFactory::createFromArray($paymentMethod, []);
 }
示例#3
0
 /**
  * @param array $transaction
  * @return Transaction
  */
 public static function fromArray(array $transaction)
 {
     Guard::keyExists($transaction, 'payment_method');
     $paymentMethod = PaymentMethod::fromString($transaction['payment_method']);
     return new static($paymentMethod, PaymentMethodDetails\PaymentMethodDetailsFactory::createFromArray($paymentMethod, array_key_exists('payment_method_details', $transaction) ? $transaction['payment_method_details'] : []), array_key_exists('id', $transaction) ? Uuid::fromString($transaction['id']) : null, array_key_exists('created', $transaction) ? new Carbon($transaction['created']) : null, array_key_exists('modified', $transaction) ? new Carbon($transaction['modified']) : null, array_key_exists('completed', $transaction) ? new Carbon($transaction['completed']) : null, array_key_exists('status', $transaction) ? TransactionStatus::fromString($transaction['status']) : null, array_key_exists('reason', $transaction) ? Reason::fromString($transaction['reason']) : null, array_key_exists('currency', $transaction) ? Currency::fromString($transaction['currency']) : null, array_key_exists('amount', $transaction) ? TransactionAmount::fromInteger($transaction['amount']) : null, array_key_exists('expiration_period', $transaction) ? new \DateInterval($transaction['expiration_period']) : null, array_key_exists('description', $transaction) ? TransactionDescription::fromString($transaction['description']) : null, array_key_exists('balance', $transaction) ? Balance::fromString($transaction['balance']) : null, array_key_exists('payment_url', $transaction) ? Url::fromString($transaction['payment_url']) : null);
 }
 /**
  * @test
  */
 public function itShouldBeCreditCard()
 {
     $paymentMethod = PaymentMethod::fromString(PaymentMethod::CREDIT_CARD);
     $this->assertFalse($paymentMethod->isIdeal());
     $this->assertTrue($paymentMethod->isCreditCard());
 }