public function build() { Tebru\assertNotNull($this->getAmount(), 'Amount must not be null'); Tebru\assertThat(null !== $this->getSource() || null !== $this->getCustomerId(), 'Source or Customer must not be null'); if (null === $this->getCurrency()) { $this->setCurrency('usd'); } $charge = new Charge(); $charge->setAmount($this->getAmount()); $charge->setCurrency($this->getCurrency()); $charge->setCustomerId($this->getCustomerId()); $charge->setDescription($this->getDescription()); $charge->setMetadata($this->getMetadata()); $charge->setStatementDescriptor($this->getStatementDescriptor()); $charge->setReceiptEmail($this->getReceiptEmail()); $charge->setDestination($this->getDestination()); $charge->setApplicationFee($this->getApplicationFee()); $charge->setShipping($this->getShipping()); $chargeRequest = new ChargeRequest(); $chargeRequest->setCapture($this->isCapture()); $source = $this->getSource(); if (is_string($source)) { $chargeRequest->setSourceId($source); } elseif ($source instanceof Card) { $chargeRequest->setCardSource($source); } elseif (null === $source) { } else { throw new LogicException('Source must be a string or Card object'); } $charge->setRequest($chargeRequest); return $charge; }
public function build() { Tebru\assertNotNull($this->getNumber(), 'Card number must not be null'); Tebru\assertNotNull($this->getExpMonth(), 'Expiration month must not be null'); Tebru\assertNotNull($this->getExpYear(), 'Expiration year must not be null'); if (null === $this->getObject()) { $this->setObject('card'); } if (null === $this->getCurrency()) { $this->setCurrency('usd'); } $card = new Card(); $card->setObject($this->getObject()); $card->setExpMonth($this->getExpMonth()); $card->setExpYear($this->getExpYear()); $card->setCurrency($this->getCurrency()); $card->setName($this->getName()); $card->setAddressLine1($this->getAddressLine1()); $card->setAddressLine2($this->getAddressLine2()); $card->setAddressCity($this->getAddressCity()); $card->setAddressState($this->getAddressState()); $card->setAddressZip($this->getAddressZip()); $card->setAddressCountry($this->getAddressCountry()); $cardRequest = new CardRequest(); $cardRequest->setNumber($this->getNumber()); $cardRequest->setCvc($this->getCvc()); $card->setRequest($cardRequest); return $card; }
public function build() { Tebru\assertNotNull($this->getDate(), 'Date is required'); Tebru\assertNotNull($this->getIp(), 'Ip is required'); $tosAcceptance = new TosAcceptance(); $tosAcceptance->setDate($this->getDate()); $tosAcceptance->setIp($this->getIp()); $tosAcceptance->setUserAgent($this->getUserAgent()); return $tosAcceptance; }
public function build() { Tebru\assertNotNull($this->getDay(), 'Day is required'); Tebru\assertNotNull($this->getMonth(), 'Month is required'); Tebru\assertNotNull($this->getYear(), 'Year is required'); $dob = new Dob(); $dob->setDay($this->getDay()); $dob->setMonth($this->getMonth()); $dob->setYear($this->getYear()); return $dob; }
public function build() { Tebru\assertNotNull($this->getName(), 'Name is required'); $shipping = new Shipping(); $shipping->setName($this->getName()); $shipping->setCarrier($this->getCarrier()); $shipping->setPhone($this->getPhone()); $shipping->setTrackingNumber($this->getTrackingNumber()); $shipping->setAddress($this->getAddress()); return $shipping; }
public function build() { Tebru\assertNotNull($this->getLine1(), 'Line 1 of Address is required'); $address = new Address(); $address->setLine1($this->getLine1()); $address->setLine2($this->getLine2()); $address->setCity($this->getCity()); $address->setState($this->getState()); $address->setPostalCode($this->getPostalCode()); $address->setCountry($this->getCountry()); return $address; }
public function build() { Tebru\assertNotNull($this->getSource(), 'Source must be set'); $card = new Card(); $card->setMetadata($this->getMetadata()); $card->setDefaultForCurrency($this->getDefaultForCurrency()); $cardRequest = new CardRequest(); $source = $this->getSource(); if (is_string($source)) { $cardRequest->setSourceId($source); } elseif ($source instanceof Card) { $cardRequest->setCardSource($source); } elseif (null === $source) { } else { throw new LogicException('Source must be a string or Card object'); } $card->setRequest($cardRequest); return $card; }
public function build() { Tebru\assertNotNull($this->getRoutingNumber(), 'Routing number is required'); Tebru\assertNotNull($this->getAccountNumber(), 'Account number is required'); if (null === $this->getCountry()) { $this->setCountry('US'); } if (null === $this->getCurrency()) { $this->setCurrency('usd'); } $bankAccount = new BankAccount(); $bankAccount->setObject('bank_account'); $bankAccount->setCountry($this->getCountry()); $bankAccount->setRoutingNumber($this->getRoutingNumber()); $bankAccountRequest = new BankAccountRequest(); $bankAccountRequest->setAccountNumber($this->getAccountNumber()); $bankAccount->setRequest($bankAccountRequest); return $bankAccount; }
/** * Build the request url * * @param array $body * @return array */ private function createRequestUrl(array $body) { Tebru\assertNotNull($this->uri, 'Request annotation not found (e.g. @GET, @POST)'); $baseUrl = null !== $this->baseUrl ? $this->baseUrl : '$this->baseUrl'; // request request params using http_build_query if we have a query map if (null !== $this->queryMap) { // if we have regular queries, add them to the query builder if (!empty($this->queries)) { $queryArray = $this->arrayToString($this->queries); $body[] = sprintf('$queryString = urldecode(http_build_query(%s + %s));', $queryArray, $this->queryMap); } else { $body[] = sprintf('$queryString = urldecode(http_build_query(%s));', $this->queryMap); } $body[] = sprintf('$requestUrl = %s . "%s?" . $queryString;', $baseUrl, $this->uri); // if we have queries, add them to the request url } elseif (!empty($this->queries)) { $queryString = urldecode(http_build_query($this->queries)); $body[] = sprintf('$requestUrl = %s . "%s" . "?%s";', $baseUrl, $this->uri, $queryString); } else { $body[] = sprintf('$requestUrl = %s . "%s";', $baseUrl, $this->uri); } return $body; }
/** * @expectedException \LogicException * @expectedExceptionMessage My test message */ public function testAssertNotNullMessage() { Tebru\assertNotNull(null, 'My %s message', 'test'); }