public function createToken() { $wepay = Utils::setupWePay($this->accountGateway); $token = intval($this->input['sourceToken']); if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) { // Persist bank details $this->tokenResponse = $wepay->request('/payment_bank/persist', ['client_id' => WEPAY_CLIENT_ID, 'client_secret' => WEPAY_CLIENT_SECRET, 'payment_bank_id' => $token]); } else { // Authorize credit card $tokenResponse = $wepay->request('credit_card/authorize', ['client_id' => WEPAY_CLIENT_ID, 'client_secret' => WEPAY_CLIENT_SECRET, 'credit_card_id' => $token]); // Update the callback uri and get the card details $tokenResponse = $wepay->request('credit_card/modify', ['client_id' => WEPAY_CLIENT_ID, 'client_secret' => WEPAY_CLIENT_SECRET, 'credit_card_id' => $token, 'auto_update' => WEPAY_AUTO_UPDATE, 'callback_uri' => $this->accountGateway->getWebhookUrl()]); $this->tokenResponse = $wepay->request('credit_card', ['client_id' => WEPAY_CLIENT_ID, 'client_secret' => WEPAY_CLIENT_SECRET, 'credit_card_id' => $token]); } return parent::createToken(); }
public function createToken() { if ($customer = $this->customer()) { $customerReference = $customer->token; } else { $data = $this->paymentDetails(); $tokenResponse = $this->gateway()->createCustomer(['customerData' => $this->customerData()])->send(); if ($tokenResponse->isSuccessful()) { $customerReference = $tokenResponse->getCustomerData()->id; } else { return false; } } if ($customerReference) { $data['customerId'] = $customerReference; if ($this->isGatewayType(GATEWAY_TYPE_PAYPAL)) { $data['paymentMethodNonce'] = $this->input['sourceToken']; } $tokenResponse = $this->gateway->createPaymentMethod($data)->send(); if ($tokenResponse->isSuccessful()) { $this->tokenResponse = $tokenResponse->getData()->paymentMethod; } else { return false; } } return parent::createToken(); }
public function createToken() { $invoice = $this->invitation->invoice; $client = $invoice->client; $data = $this->paymentDetails(); $data['description'] = $client->getDisplayName(); if (!empty($data['plaidPublicToken'])) { $plaidResult = $this->getPlaidToken($data['plaidPublicToken'], $data['plaidAccountId']); unset($data['plaidPublicToken']); unset($data['plaidAccountId']); $data['token'] = $plaidResult['stripe_bank_account_token']; } // if a customer already exists link the token to it if ($customer = $this->customer()) { $data['customerReference'] = $customer->token; } $tokenResponse = $this->gateway()->createCard($data)->send(); if ($tokenResponse->isSuccessful()) { $this->tokenResponse = $tokenResponse->getData(); return parent::createToken(); } else { throw new Exception($tokenResponse->getMessage()); } }