factory() 공개 정적인 메소드

factory method: returns an instance of Transaction to the requesting method, with populated properties
public static factory ( $attributes ) : Transaction
리턴 Transaction
예제 #1
1
 public function testIsset()
 {
     $t = Braintree\Transaction::factory(['creditCard' => ['expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100'], 'customer' => [], 'billing' => [], 'descriptor' => [], 'shipping' => [], 'subscription' => ['billingPeriodStartDate' => '1983-07-12'], 'statusHistory' => []]);
     $this->assertTrue(isset($t->creditCard));
     $this->assertFalse(empty($t->creditCard));
 }
예제 #2
0
 /**
  * overrides default constructor
  * @ignore
  * @param array $response gateway response array
  */
 public function __construct($response)
 {
     $this->_attributes = $response;
     $this->_set('errors', new ErrorCollection($response['errors']));
     if (isset($response['verification'])) {
         $this->_set('creditCardVerification', new CreditCardVerification($response['verification']));
     } else {
         $this->_set('creditCardVerification', null);
     }
     if (isset($response['transaction'])) {
         $this->_set('transaction', Transaction::factory($response['transaction']));
     } else {
         $this->_set('transaction', null);
     }
     if (isset($response['subscription'])) {
         $this->_set('subscription', Subscription::factory($response['subscription']));
     } else {
         $this->_set('subscription', null);
     }
     if (isset($response['merchantAccount'])) {
         $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount']));
     } else {
         $this->_set('merchantAccount', null);
     }
 }
예제 #3
0
 public function test__isset()
 {
     $transaction = Braintree\Transaction::factory(['creditCard' => ['expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100', 'cardType' => 'MasterCard']]);
     $this->assertEquals('MasterCard', $transaction->creditCardDetails->cardType);
     $this->assertFalse(empty($transaction->creditCardDetails->cardType));
     $this->assertTrue(isset($transaction->creditCardDetails->cardType));
     $transaction = Braintree\Transaction::factory(['creditCard' => ['expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100']]);
     $this->assertTrue(empty($transaction->creditCardDetails->cardType));
     $this->assertFalse(isset($transaction->creditCardDetails->cardType));
 }
 public function testHandle()
 {
     $paymentDO = $this->getMock(PaymentDataObjectInterface::class);
     $paymentInfo = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock();
     $handlingSubject = ['payment' => $paymentDO];
     $transaction = \Braintree\Transaction::factory(['id' => 1]);
     $response = ['object' => new \Braintree\Result\Successful($transaction, 'transaction')];
     $subjectReader = $this->getMockBuilder(SubjectReader::class)->disableOriginalConstructor()->getMock();
     $subjectReader->expects(static::once())->method('readPayment')->with($handlingSubject)->willReturn($paymentDO);
     $paymentDO->expects(static::atLeastOnce())->method('getPayment')->willReturn($paymentInfo);
     $subjectReader->expects(static::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $paymentInfo->expects(static::once())->method('setTransactionId')->with(1);
     $paymentInfo->expects(static::once())->method('setIsTransactionClosed')->with(false);
     $paymentInfo->expects(static::once())->method('setShouldCloseParentTransaction')->with(false);
     $handler = new TransactionIdHandler($subjectReader);
     $handler->handle($handlingSubject, $response);
 }
예제 #5
0
 /**
  * Get items
  *
  * @param array $transaction
  * @dataProvider getConfigDataProvider
  */
 public function testGetCustomAttributes($transaction)
 {
     $this->transactionStub = Transaction::factory($transaction);
     $fields = TransactionMap::$simpleFieldsMap;
     $fieldsQty = count($fields);
     $this->attributeValueFactoryMock->expects($this->exactly($fieldsQty))->method('create')->willReturnCallback(function () {
         return new AttributeValue();
     });
     $map = new TransactionMap($this->attributeValueFactoryMock, $this->transactionStub);
     /** @var AttributeValue[] $result */
     $result = $map->getCustomAttributes();
     $this->assertEquals($fieldsQty, count($result));
     $this->assertInstanceOf(AttributeValue::class, $result[1]);
     $this->assertEquals($transaction['id'], $result[0]->getValue());
     $this->assertEquals($transaction['paypalDetails']->paymentId, $result[4]->getValue());
     $this->assertEquals($transaction['createdAt']->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT), $result[6]->getValue());
     $this->assertEquals(implode(', ', $transaction['refundIds']), $result[11]->getValue());
 }
 /**
  * @ignore
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['subscription'])) {
         return new Result\Successful(Subscription::factory($response['subscription']));
     } else {
         if (isset($response['transaction'])) {
             // return a populated instance of Transaction, for subscription retryCharge
             return new Result\Successful(Transaction::factory($response['transaction']));
         } else {
             if (isset($response['apiErrorResponse'])) {
                 return new Result\Error($response['apiErrorResponse']);
             } else {
                 throw new Exception\Unexpected("Expected subscription, transaction, or apiErrorResponse");
             }
         }
     }
 }
예제 #7
0
 /**
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 private function getBraintreeTransactionMock()
 {
     $transaction = \Braintree\Transaction::factory([]);
     $transaction->_set('riskData', RiskData::factory(['id' => 'test-id', 'decision' => 'test-decision']));
     return $transaction;
 }
 /**
  * Create Braintree transaction
  * @return MockObject
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['id' => self::TRANSACTION_ID, 'creditCardDetails' => $this->getCreditCardDetails()];
     $transaction = Transaction::factory($attributes);
     return $transaction;
 }
 /**
  * Create Braintree transaction
  * @return Transaction
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['id' => '23ui8be', 'paypal' => ['paymentId' => 'u239dkv6n2lds', 'payerEmail' => '*****@*****.**']];
     $transaction = Transaction::factory($attributes);
     return $transaction;
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Helper\SubjectReader::readPayPal
  */
 public function testReadPayPal()
 {
     $paypal = ['paymentId' => '3ek7dk7fn0vi1', 'payerEmail' => '*****@*****.**'];
     $transaction = Transaction::factory(['id' => '4yr95vb', 'paypal' => $paypal]);
     static::assertEquals($paypal, $this->subjectReader->readPayPal($transaction));
 }
 /**
  * Create Braintree transaction
  * @return \Braintree\Transaction
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['creditCard' => ['bin' => '5421', 'cardType' => 'American Express', 'expirationMonth' => 12, 'expirationYear' => 21, 'last4' => 1231]];
     $transaction = Transaction::factory($attributes);
     return $transaction;
 }
 /**
  * Create Braintree transaction
  * @return Transaction
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['id' => self::TRANSACTION_ID, 'avsPostalCodeResponseCode' => 'M', 'avsStreetAddressResponseCode' => 'M', 'cvvResponseCode' => 'M', 'processorAuthorizationCode' => 'W1V8XK', 'processorResponseCode' => '1000', 'processorResponseText' => 'Approved'];
     return Transaction::factory($attributes);
 }
예제 #13
0
 public function testInitializationWithoutArguments()
 {
     $transaction = Braintree\Transaction::factory([]);
     $this->assertTrue($transaction instanceof Braintree\Transaction);
 }
 /**
  * Create Braintree transaction
  * @return MockObject
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['id' => self::TRANSACTION_ID, 'threeDSecureInfo' => $this->getThreeDSecureInfo()];
     $transaction = Transaction::factory($attributes);
     return $transaction;
 }
예제 #15
0
 /**
  * Create Braintree transaction
  * @return MockObject
  */
 private function getBraintreeTransaction()
 {
     $attributes = ['id' => self::TRANSACTION_ID];
     $transaction = Transaction::factory($attributes);
     return $transaction;
 }