/** * @param StripeCustomer $stripeCustomer * * @return Customer */ public function transform(StripeCustomer $stripeCustomer) { $customer = new Customer(); $createdAt = new \DateTime($stripeCustomer['created']); $customer->setId($stripeCustomer['id']); $customer->setCreatedAt($createdAt); $customer->setDescription($stripeCustomer['description']); $customer->setEmail($stripeCustomer['email']); $customer->setAccountBalance(StripeFactory::convertStripeAmountToFloat($stripeCustomer['account_balance'])); $customer->setCurrency($stripeCustomer['currency']); $customer->setDelinquent($stripeCustomer['delinquent']); $customer->setLiveMode($stripeCustomer['livemode']); $customer->setMetadata($stripeCustomer['metadata']->__toArray()); return $customer; }
/** * @param Customer $customer * @param int $amount * @param string $currency * @param string $description * * @return Charge */ public function createFromCustomer(Customer $customer, $amount = 0, $currency = CurrencyFactory::EURO_CURRENCY, $description = null) { $stripeCharge = StripeCharge::create(array('amount' => $amount, 'currency' => $currency, 'customer' => $customer->getId(), 'description' => $description)); $charge = $this->stripeToChargeTransformer->transform($stripeCharge); return $charge; }