factory() public static method

factory method: returns an instance of UsBankAccount to the requesting method, with populated properties
public static factory ( $attributes ) : UsBankAccount
return UsBankAccount
コード例 #1
0
 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new UsBankAccount object and encapsulates
  * it inside a Result\Successful object, or
  * encapsulates a Errors object inside a Result\Error
  * alternatively, throws an Unexpected exception if the response is invalid.
  *
  * @ignore
  * @param array $response gateway response values
  * @return Result\Successful|Result\Error
  * @throws Exception\Unexpected
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['usBankAccount'])) {
         // return a populated instance of UsBankAccount
         return new Result\Successful(UsBankAccount::factory($response['usBankAccount']));
     } else {
         if (isset($response['apiErrorResponse'])) {
             return new Result\Error($response['apiErrorResponse']);
         } else {
             throw new Exception\Unexpected('Expected US bank account or apiErrorResponse');
         }
     }
 }
コード例 #2
0
 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new CreditCard or PayPalAccount object
  * and encapsulates it inside a Result\Successful object, or
  * encapsulates a Errors object inside a Result\Error
  * alternatively, throws an Unexpected exception if the response is invalid.
  *
  * @ignore
  * @param array $response gateway response values
  * @return Result\Successful|Result\Error
  * @throws Exception\Unexpected
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['creditCard'])) {
         return new Result\Successful(CreditCard::factory($response['creditCard']), 'paymentMethod');
     } else {
         if (isset($response['paypalAccount'])) {
             return new Result\Successful(PayPalAccount::factory($response['paypalAccount']), "paymentMethod");
         } else {
             if (isset($response['coinbaseAccount'])) {
                 return new Result\Successful(CoinbaseAccount::factory($response['coinbaseAccount']), "paymentMethod");
             } else {
                 if (isset($response['applePayCard'])) {
                     return new Result\Successful(ApplePayCard::factory($response['applePayCard']), "paymentMethod");
                 } else {
                     if (isset($response['androidPayCard'])) {
                         return new Result\Successful(AndroidPayCard::factory($response['androidPayCard']), "paymentMethod");
                     } else {
                         if (isset($response['amexExpressCheckoutCard'])) {
                             return new Result\Successful(AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']), "paymentMethod");
                         } else {
                             if (isset($response['europeBankAccount'])) {
                                 return new Result\Successful(EuropeBankAccount::factory($response['europeBankAccount']), "paymentMethod");
                             } else {
                                 if (isset($response['usBankAccount'])) {
                                     return new Result\Successful(UsBankAccount::factory($response['usBankAccount']), "paymentMethod");
                                 } else {
                                     if (isset($response['venmoAccount'])) {
                                         return new Result\Successful(VenmoAccount::factory($response['venmoAccount']), "paymentMethod");
                                     } else {
                                         if (isset($response['paymentMethodNonce'])) {
                                             return new Result\Successful(PaymentMethodNonce::factory($response['paymentMethodNonce']), "paymentMethodNonce");
                                         } else {
                                             if (isset($response['apiErrorResponse'])) {
                                                 return new Result\Error($response['apiErrorResponse']);
                                             } else {
                                                 if (is_array($response)) {
                                                     return new Result\Successful(UnknownPaymentMethod::factory($response), "paymentMethod");
                                                 } else {
                                                     throw new Exception\Unexpected('Expected payment method or apiErrorResponse');
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }