本文整理汇总了PHP中Braintree_Transaction::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Transaction::factory方法的具体用法?PHP Braintree_Transaction::factory怎么用?PHP Braintree_Transaction::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_Transaction
的用法示例。
在下文中一共展示了Braintree_Transaction::factory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
/**
* @ignore
*/
protected function _initialize($attributes)
{
$this->_attributes = $attributes;
$addOnArray = array();
if (isset($attributes['addOns'])) {
foreach ($attributes['addOns'] as $addOn) {
$addOnArray[] = Braintree_AddOn::factory($addOn);
}
}
$this->_attributes['addOns'] = $addOnArray;
$discountArray = array();
if (isset($attributes['discounts'])) {
foreach ($attributes['discounts'] as $discount) {
$discountArray[] = Braintree_Discount::factory($discount);
}
}
$this->_attributes['discounts'] = $discountArray;
if (isset($attributes['descriptor'])) {
$this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor']));
}
$statusHistory = array();
if (isset($attributes['statusHistory'])) {
foreach ($attributes['statusHistory'] as $history) {
$statusHistory[] = new Braintree_Subscription_StatusDetails($history);
}
}
$this->_attributes['statusHistory'] = $statusHistory;
$transactionArray = array();
if (isset($attributes['transactions'])) {
foreach ($attributes['transactions'] as $transaction) {
$transactionArray[] = Braintree_Transaction::factory($transaction);
}
}
$this->_attributes['transactions'] = $transactionArray;
}
示例2: _initialize
protected function _initialize($attributes)
{
$this->_attributes = $attributes;
if (isset($attributes['subject']['apiErrorResponse'])) {
$wrapperNode = $attributes['subject']['apiErrorResponse'];
} else {
$wrapperNode = $attributes['subject'];
}
if (isset($wrapperNode['subscription'])) {
$this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
}
if (isset($wrapperNode['merchantAccount'])) {
$this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
}
if (isset($wrapperNode['transaction'])) {
$this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
}
if (isset($wrapperNode['disbursement'])) {
$this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
}
if (isset($wrapperNode['partnerMerchant'])) {
$this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
}
if (isset($wrapperNode['errors'])) {
$this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
$this->_set('message', $wrapperNode['message']);
}
}
示例3: __construct
/**
* overrides default constructor
* @ignore
* @param array $response gateway response array
*/
public function __construct($response)
{
$this->_attributes = $response;
$this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
if (isset($response['verification'])) {
$this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
} else {
$this->_set('creditCardVerification', null);
}
if (isset($response['transaction'])) {
$this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
} else {
$this->_set('transaction', null);
}
if (isset($response['subscription'])) {
$this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
} else {
$this->_set('subscription', null);
}
if (isset($response['merchantAccount'])) {
$this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
} else {
$this->_set('merchantAccount', null);
}
}
示例4: _doTestRequest
private function _doTestRequest($testPath, $transactionId)
{
self::_checkEnvironment();
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath;
$response = $this->_http->put($path);
return Braintree_Transaction::factory($response['transaction']);
}
示例5: test__isset
function test__isset()
{
$transaction = Braintree_Transaction::factory(array('creditCard' => array('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(array('creditCard' => array('expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100')));
$this->assertTrue(empty($transaction->creditCardDetails->cardType));
$this->assertFalse(isset($transaction->creditCardDetails->cardType));
}
示例6: testIsset
function testIsset()
{
$t = Braintree_Transaction::factory(array('creditCard' => array('expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100'), 'customer' => array(), 'billing' => array(), 'descriptor' => array(), 'shipping' => array(), 'subscription' => array('billingPeriodStartDate' => '1983-07-12'), 'statusHistory' => array()));
$this->assertTrue(isset($t->creditCard));
$this->assertFalse(empty($t->creditCard));
}
示例7: _verifyGatewayResponse
/**
* generic method for validating incoming gateway responses
*
* creates a new Braintree_Transaction object and encapsulates
* it inside a Braintree_Result_Successful object, or
* encapsulates a Braintree_Errors object inside a Result_Error
* alternatively, throws an Unexpected exception if the response is invalid.
*
* @ignore
* @param array $response gateway response values
* @return object Result_Successful or Result_Error
* @throws Braintree_Exception_Unexpected
*/
private function _verifyGatewayResponse($response)
{
if (isset($response['transaction'])) {
// return a populated instance of Braintree_Transaction
return new Braintree_Result_Successful(Braintree_Transaction::factory($response['transaction']));
} else {
if (isset($response['apiErrorResponse'])) {
return new Braintree_Result_Error($response['apiErrorResponse']);
} else {
throw new Braintree_Exception_Unexpected("Expected transaction or apiErrorResponse");
}
}
}
示例8: testInitializationWithoutArguments
function testInitializationWithoutArguments()
{
$transaction = Braintree_Transaction::factory(array());
$this->assertTrue($transaction instanceof Braintree_Transaction);
}
示例9: testVoidInvalidState
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Some transactions are already settled or voided and cannot be voided.
*/
public function testVoidInvalidState()
{
$orderId = 1005;
$paymentObject = $this->setupPaymentObjectForVoid($orderId);
$transactions = ['1' => \Braintree_Transaction::factory(['id' => '1', 'status' => \Braintree_Transaction::SETTLED])];
$this->setupTransactionIds($orderId, array_keys($transactions));
$index = 0;
foreach ($transactions as $id => $transaction) {
$this->braintreeTransactionMock->expects($this->at($index))->method('find')->with($id)->willReturn($transaction);
$index++;
}
$this->model->void($paymentObject);
}
示例10: authorizeDataProvider
/**
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function authorizeDataProvider()
{
return ['paypal_payment_nonce' => ['config' => ['is3dSecureEnabled' => false, 'isFraudProtectionEnabled' => false, 'isDebugEnabled' => false, 'useVault' => false, 'getMerchantAccountId' => self::MERCHANT_ACCOUNT_ID], 'infoInstanceValueMap' => [['store_in_vault', null], ['payment_method_nonce', self::PAYMENT_METHOD_NONCE], ['device_data', 'fraud_detection_data']], 'expectedParams' => ['options' => ['addBillingAddressToPaymentMethod' => true], 'merchantAccountId' => self::MERCHANT_ACCOUNT_ID, 'paymentMethodNonce' => self::PAYMENT_METHOD_NONCE], 'braintree_response' => ['transaction' => \Braintree_Transaction::factory(['id' => self::AUTH_TRAN_ID, 'gatewayRejectionReason' => null, 'processorAuthorizationCode' => 'S02T5Q', 'processorResponseCode' => '1000', 'processorResponseText' => 'Approved', 'paypal' => ['payerEmail' => self::PAYER_EMAIL, 'paymentId' => self::PAYMENT_ID, 'authorizationId' => self::AUTHORIZATION_ID, 'payerId' => self::PAYER_ID, 'payerFirstName' => self::FNAME, 'payerLastName' => self::LNAME]])], 'expected_payment_fields' => ['status' => 'APPROVED', 'cc_trans_id' => self::AUTH_TRAN_ID, 'last_trans_id' => self::AUTH_TRAN_ID, 'transaction_id' => self::AUTH_TRAN_ID, 'is_transactioN_cloned' => 0, 'amount' => self::AUTH_AMOUNT, 'should_close_parent_transaction' => false, 'additional_information' => ['processorAuthorizationCode' => 'S02T5Q', 'processorResponseCode' => '1000', 'processorResponseText' => 'Approved', 'payerEmail' => self::PAYER_EMAIL, 'paymentId' => self::PAYMENT_ID, 'authorizationId' => self::AUTHORIZATION_ID, 'payerId' => self::PAYER_ID, 'payerFirstName' => self::FNAME, 'payerLastName' => self::LNAME]]], 'paypal_payment_nonce_fraud_protection' => ['config' => ['is3dSecureEnabled' => false, 'isFraudProtectionEnabled' => true, 'isDebugEnabled' => false, 'useVault' => false, 'getMerchantAccountId' => self::MERCHANT_ACCOUNT_ID], 'infoInstanceValueMap' => [['store_in_vault', null], ['payment_method_nonce', self::PAYMENT_METHOD_NONCE], ['device_data', 'fraud_detection_data']], 'expectedParams' => ['options' => ['addBillingAddressToPaymentMethod' => true], 'merchantAccountId' => self::MERCHANT_ACCOUNT_ID, 'paymentMethodNonce' => self::PAYMENT_METHOD_NONCE, 'deviceData' => 'fraud_detection_data'], 'braintree_response' => ['transaction' => \Braintree_Transaction::factory(['id' => self::AUTH_TRAN_ID, 'gatewayRejectionReason' => null, 'processorAuthorizationCode' => 'S02T5Q', 'processorResponseCode' => '1000', 'processorResponseText' => 'Approved', 'paypal' => ['payerEmail' => self::PAYER_EMAIL, 'paymentId' => self::PAYMENT_ID, 'authorizationId' => self::AUTHORIZATION_ID, 'payerId' => self::PAYER_ID, 'payerFirstName' => self::FNAME, 'payerLastName' => self::LNAME]])], 'expected_payment_fields' => ['status' => 'APPROVED', 'cc_trans_id' => self::AUTH_TRAN_ID, 'last_trans_id' => self::AUTH_TRAN_ID, 'transaction_id' => self::AUTH_TRAN_ID, 'is_transactioN_cloned' => 0, 'amount' => self::AUTH_AMOUNT, 'should_close_parent_transaction' => false, 'additional_information' => ['processorAuthorizationCode' => 'S02T5Q', 'processorResponseCode' => '1000', 'processorResponseText' => 'Approved', 'payerEmail' => self::PAYER_EMAIL, 'paymentId' => self::PAYMENT_ID, 'authorizationId' => self::AUTHORIZATION_ID, 'payerId' => self::PAYER_ID, 'payerFirstName' => self::FNAME, 'payerLastName' => self::LNAME]]]];
}
示例11: testGet_givesErrorIfInvalidProperty
function testGet_givesErrorIfInvalidProperty()
{
$t = Braintree_Transaction::factory(array('creditCard' => array('expirationMonth' => '05', 'expirationYear' => '2010', 'bin' => '510510', 'last4' => '5100'), 'customer' => array(), 'billing' => array(), 'descriptor' => array(), 'shipping' => array(), 'subscription' => array('billingPeriodStartDate' => '1983-07-12'), 'statusHistory' => array()));
$this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree_Transaction: foo');
$t->foo;
}
示例12: _verifyGatewayResponse
/**
* @ignore
*/
private static function _verifyGatewayResponse($response)
{
if (isset($response['subscription'])) {
return new Braintree_Result_Successful(self::factory($response['subscription']));
} else {
if (isset($response['transaction'])) {
// return a populated instance of Braintree_Transaction, for subscription retryCharge
return new Braintree_Result_Successful(Braintree_Transaction::factory($response['transaction']));
} else {
if (isset($response['apiErrorResponse'])) {
return new Braintree_Result_Error($response['apiErrorResponse']);
}
}
}
}