· 6 years ago · Oct 03, 2019, 07:16 AM
1<?php if (! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
2/**
3 *
4 * @package Provab
5 * @subpackage Payu
6 * @author Pravinkumar P <pravinkumar.provab@gmail.com>
7 * @version V1
8 */
9
10// Stripe singleton
11// require(dirname(__FILE__) . '/stripe/lib/Stripe.php');
12
13// Utilities
14require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
15require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
16require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
17require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
18require(dirname(__FILE__) . '/lib/Util/Set.php');
19require(dirname(__FILE__) . '/lib/Util/Util.php');
20
21// HttpClient
22require(dirname(__FILE__) . '/lib/HttpClient/ClientInterface.php');
23require(dirname(__FILE__) . '/lib/HttpClient/CurlClient.php');
24
25// Errors
26require(dirname(__FILE__) . '/lib/Error/Base.php');
27require(dirname(__FILE__) . '/lib/Error/Api.php');
28require(dirname(__FILE__) . '/lib/Error/ApiConnection.php');
29require(dirname(__FILE__) . '/lib/Error/Authentication.php');
30require(dirname(__FILE__) . '/lib/Error/Card.php');
31require(dirname(__FILE__) . '/lib/Error/InvalidRequest.php');
32require(dirname(__FILE__) . '/lib/Error/Permission.php');
33require(dirname(__FILE__) . '/lib/Error/RateLimit.php');
34require(dirname(__FILE__) . '/lib/Error/SignatureVerification.php');
35
36// OAuth errors
37require(dirname(__FILE__) . '/lib/Error/OAuth/OAuthBase.php');
38require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidGrant.php');
39require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidRequest.php');
40require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidScope.php');
41require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php');
42require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php');
43
44// Plumbing
45require(dirname(__FILE__) . '/lib/ApiResponse.php');
46require(dirname(__FILE__) . '/lib/JsonSerializable.php');
47require(dirname(__FILE__) . '/lib/StripeObject.php');
48require(dirname(__FILE__) . '/lib/ApiRequestor.php');
49require(dirname(__FILE__) . '/lib/ApiResource.php');
50require(dirname(__FILE__) . '/lib/SingletonApiResource.php');
51require(dirname(__FILE__) . '/lib/AttachedObject.php');
52require(dirname(__FILE__) . '/lib/ExternalAccount.php');
53
54// Stripe API Resources
55require(dirname(__FILE__) . '/lib/Account.php');
56require(dirname(__FILE__) . '/lib/AlipayAccount.php');
57require(dirname(__FILE__) . '/lib/ApplePayDomain.php');
58require(dirname(__FILE__) . '/lib/ApplicationFee.php');
59require(dirname(__FILE__) . '/lib/ApplicationFeeRefund.php');
60require(dirname(__FILE__) . '/lib/Balance.php');
61require(dirname(__FILE__) . '/lib/BalanceTransaction.php');
62require(dirname(__FILE__) . '/lib/BankAccount.php');
63require(dirname(__FILE__) . '/lib/BitcoinReceiver.php');
64require(dirname(__FILE__) . '/lib/BitcoinTransaction.php');
65require(dirname(__FILE__) . '/lib/Card.php');
66require(dirname(__FILE__) . '/lib/Charge.php');
67require(dirname(__FILE__) . '/lib/Collection.php');
68require(dirname(__FILE__) . '/lib/CountrySpec.php');
69require(dirname(__FILE__) . '/lib/Coupon.php');
70require(dirname(__FILE__) . '/lib/Customer.php');
71require(dirname(__FILE__) . '/lib/Dispute.php');
72require(dirname(__FILE__) . '/lib/EphemeralKey.php');
73require(dirname(__FILE__) . '/lib/Event.php');
74require(dirname(__FILE__) . '/lib/FileUpload.php');
75require(dirname(__FILE__) . '/lib/Invoice.php');
76require(dirname(__FILE__) . '/lib/InvoiceItem.php');
77require(dirname(__FILE__) . '/lib/LoginLink.php');
78require(dirname(__FILE__) . '/lib/Order.php');
79require(dirname(__FILE__) . '/lib/OrderReturn.php');
80require(dirname(__FILE__) . '/lib/Payout.php');
81require(dirname(__FILE__) . '/lib/Plan.php');
82require(dirname(__FILE__) . '/lib/Product.php');
83require(dirname(__FILE__) . '/lib/Recipient.php');
84require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
85require(dirname(__FILE__) . '/lib/Refund.php');
86require(dirname(__FILE__) . '/lib/SKU.php');
87require(dirname(__FILE__) . '/lib/Source.php');
88require(dirname(__FILE__) . '/lib/Subscription.php');
89require(dirname(__FILE__) . '/lib/SubscriptionItem.php');
90require(dirname(__FILE__) . '/lib/ThreeDSecure.php');
91require(dirname(__FILE__) . '/lib/Token.php');
92require(dirname(__FILE__) . '/lib/Transfer.php');
93require(dirname(__FILE__) . '/lib/TransferReversal.php');
94
95// OAuth
96require(dirname(__FILE__) . '/lib/OAuth.php');
97
98// Webhooks
99require(dirname(__FILE__) . '/lib/Webhook.php');
100require(dirname(__FILE__) . '/lib/WebhookSignature.php');
101
102
103class Stripe {
104
105 static $apikey;
106 static $clientid;
107 static $url;
108
109 var $active_payment_system;
110
111 var $book_id = '';
112 var $book_origin = '';
113 var $pgi_amount = '';
114 var $name = '';
115 var $email = '';
116 var $phone = '';
117 var $productinfo = '';
118 public function __construct() {
119 $this->CI = &get_instance ();
120 $this->CI->load->helper('custom/payu_pgi_helper');
121 // $this->lo
122 $this->active_payment_system = $this->CI->config->item('active_payment_system');
123 }
124
125 function initialize($data)
126 {
127 if ($this->active_payment_system == 'test') {
128
129 self::$apikey = 'pk_test_7vzkIdr7MJfzAPgkFz9JtAwS00sdpGfDCf';//'pk_test_gxEaG8CYNYvXAyQwnuA5OmgX';
130 self::$clientid = 'sk_test_R83Uy4wfo32HeXMdn1jXagcx00LlwVGaEg';//'ca_B5w1hMVL00692Qxl2obf8USCihlh4bFy';
131 self::$url = 'https://connect.stripe.com/oauth/authorize';
132 } else {
133 //live
134 self::$apikey = '';
135 self::$clientid = '';
136 self::$url = 'https://connect.stripe.com/oauth/authorize';
137 }
138 $this->book_id = $data['txnid'];
139 $temp = str_replace('.', '', $data['pgi_amount']);
140 $this->pgi_amount = $temp;
141 $this->firstname = $data['firstname'];
142 $this->email = $data['email'];
143 $this->phone = $data['phone'];
144 $this->productinfo = $data['productinfo'];
145 }
146
147 function process_payment($book_id){
148 $surl = 'success';//base_url().'index.php/payment_gateway/success';
149 $furl = 'cancel';//base_url(). 'index.php/payment_gateway/cancel';
150 //payumoney base url
151 $PAYU_BASE_URL = "https://connect.stripe.com/oauth/authorize";
152
153 $post_data=array();
154 $post_data['apikey'] = self::$apikey;
155 $post_data['txnid'] = $this->book_id;
156 $post_data['amount'] = $this->pgi_amount;
157 $post_data['firstname'] = $this->firstname;
158 $post_data['email'] = $this->email;
159 $post_data['phone'] = $this->phone;
160 $post_data['productinfo'] = $this->productinfo;
161 $post_data['surl'] = $surl;
162 $post_data['furl'] = $furl;
163 $post_data['service_provider'] = 'stripe';
164 $post_data['pay_target_url'] = self::$url;
165 $post_data['client_id'] = self::$clientid;
166 $post_data['udf1'] = $book_id;
167 // debug($post_data);exit;
168 return $post_data;
169 }
170
171 // @var string The Stripe API key to be used for requests.
172 public static $apiKey = 'pk_test_cU1WxeTXfSGWfEnRehIUD9Y800SvTQeqHv';//'sk_test_MdP1j2oWguWcMbahEydz7VPB'
173
174 // @var string The Stripe client_id to be used for Connect requests.
175 public static $clientId = 'sk_test_zdHrj83d2IXPzl9vp4IbHfYQ00csNhOA4i';//'ca_B5w1hMVL00692Qxl2obf8USCihlh4bFy';
176
177 // @var string The base URL for the Stripe API.
178 public static $apiBase = 'https://api.stripe.com';
179
180 // @var string The base URL for the OAuth API.
181 public static $connectBase = 'https://connect.stripe.com';
182
183 // @var string The base URL for the Stripe API uploads endpoint.
184 public static $apiUploadBase = 'https://uploads.stripe.com';
185
186 // @var string|null The version of the Stripe API to use for requests.
187 public static $apiVersion = null;
188
189 // @var string|null The account ID for connected accounts requests.
190 public static $accountId = null;
191
192 // @var boolean Defaults to true.
193 public static $verifySslCerts = true;
194
195 // @var array The application's information (name, version, URL)
196 public static $appInfo = null;
197
198 // @var Util\LoggerInterface|null The logger to which the library will
199 // produce messages.
200 public static $logger = null;
201
202 const VERSION = '5.1.1';
203
204 /**
205 * @return string The API key used for requests.
206 */
207 public static function getApiKey()
208 {
209 return self::$apiKey;
210 }
211
212 /**
213 * @return string The client_id used for Connect requests.
214 */
215 public static function getClientId()
216 {
217 return self::$clientId;
218 }
219
220 /**
221 * @return Util\LoggerInterface The logger to which the library will
222 * produce messages.
223 */
224 public static function getLogger()
225 {
226 if (self::$logger == null) {
227 return new lib\Util\DefaultLogger();
228 }
229 return self::$logger;
230 }
231
232 /**
233 * @param Util\LoggerInterface $logger The logger to which the library
234 * will produce messages.
235 */
236 public static function setLogger($logger)
237 {
238 self::$logger = $logger;
239 }
240
241 /**
242 * Sets the API key to be used for requests.
243 *
244 * @param string $apiKey
245 */
246 public static function setApiKey($apiKey)
247 {
248 self::$apiKey = $apiKey;
249 }
250
251 /**
252 * Sets the client_id to be used for Connect requests.
253 *
254 * @param string $clientId
255 */
256 public static function setClientId($clientId)
257 {
258 self::$clientId = $clientId;
259 }
260
261 /**
262 * @return string The API version used for requests. null if we're using the
263 * latest version.
264 */
265 public static function getApiVersion()
266 {
267 return self::$apiVersion;
268 }
269
270 /**
271 * @param string $apiVersion The API version to use for requests.
272 */
273 public static function setApiVersion($apiVersion)
274 {
275 self::$apiVersion = $apiVersion;
276 }
277
278 /**
279 * @return boolean
280 */
281 public static function getVerifySslCerts()
282 {
283 return self::$verifySslCerts;
284 }
285
286 /**
287 * @param boolean $verify
288 */
289 public static function setVerifySslCerts($verify)
290 {
291 self::$verifySslCerts = $verify;
292 }
293
294 /**
295 * @return string | null The Stripe account ID for connected account
296 * requests.
297 */
298 public static function getAccountId()
299 {
300 return self::$accountId;
301 }
302
303 /**
304 * @param string $accountId The Stripe account ID to set for connected
305 * account requests.
306 */
307 public static function setAccountId($accountId)
308 {
309 self::$accountId = $accountId;
310 }
311
312 /**
313 * @return array | null The application's information
314 */
315 public static function getAppInfo()
316 {
317 return self::$appInfo;
318 }
319
320 /**
321 * @param string $appName The application's name
322 * @param string $appVersion The application's version
323 * @param string $appUrl The application's URL
324 */
325 public static function setAppInfo($appName, $appVersion = null, $appUrl = null)
326 {
327 if (self::$appInfo === null) {
328 self::$appInfo = array();
329 }
330 self::$appInfo['name'] = $appName;
331 self::$appInfo['version'] = $appVersion;
332 self::$appInfo['url'] = $appUrl;
333 }
334
335 function create($params = null, $options = null)
336 {
337 return lib\Charge::create($params, $options);
338 }
339
340}