$publishableKey = TWITTER_STRIPE_PUBLISHABLE_KEY; // Assigned by Stripe $processorUserId = TWITTER_STRIPE_USER_ID; // Assigned by Stripe $error = ''; $success = ''; $client = new RESTClient(); $messageFactory = new MessageFactory(); $signer = new RequestSigner(); $responseHandlerFactory = new ResponseHandlerFactory(); $factory = new ProcessorFactory(); $processor = $factory->getProcessor('default', $client, $messageFactory, $signer, $responseHandlerFactory, $host); $merchant = new Merchant(); $merchant->setAccountId($accountId); // OAuth $oAuth = $merchant->getOAuth(); $oAuth->setConsumerKey($consumerKey); $oAuth->setConsumerSecret($consumerSecret); $oAuth->setOAuthToken($oAuthToken); $oAuth->setOAuthTokenSecret($oAuthTokenSecret); $error = ''; $success = ''; $credentials = new Credentials(); $credentials->setAuthToken($authToken); $credentials->setPublishableKey($publishableKey); $credentials->setProcessorUserId($processorUserId); $gateway = new Gateway(); $gateway->setCredentials($credentials); $merchant->setGateway($gateway); if ($_POST) { $m = $_POST['merchant'];
/** * @param AntiMattr\Twitter\Marketplace\Model\Merchant $merchant * * @throws AntiMattr\Twitter\Marketplace\Exception\AbstractAuthException */ private function checkMerchantCredentials(Merchant $merchant) { $oAuth = $merchant->getOAuth(); $consumerKey = $oAuth->getConsumerKey(); $consumerSecret = $oAuth->getConsumerSecret(); $oAuthToken = $oAuth->getOAuthToken(); $oAuthTokenSecret = $oAuth->getOAuthTokenSecret(); if (!isset($consumerKey) || !isset($consumerSecret) || !isset($oAuthToken) || !isset($oAuthTokenSecret)) { $oauth = array('consumerKey' => isset($consumerKey) ? true : null, 'consumerSecret' => isset($consumerSecret) ? true : null, 'oAuthToken' => isset($oAuthToken) ? true : null, 'oAuthTokenSecret' => isset($oAuthTokenSecret) ? true : null); // Raise exception if any required credentials are missing $missing = array_filter($oauth, function ($item) { return null === $item ? true : false; }); $message = sprintf('OAuth requires: %s.', implode(", ", array_keys($missing))); throw new OAuthException($message); } }