nogle der kan hjælpe mig med at finde bug på dette script
- <?php
-
- /**
-
- * Purpose : Send Stripe Payment to sender to receiver
-
- * Auther : kps
-
- * Date : 26-05-2017
-
- **/
-
- require_once('stripe-php/init.php');
-
- \Stripe\Stripe::setApiKey("sk_test_X4DA7Ur92h2XHWBQuD2DoU07");
-
-
-
- class AcceptPaymentRequest extends DB
-
- {
-
-
-
-
-
- // Check Whether Token is valid or not if valid then return user_id otherwise return false.
-
- public function isValidToken($token)
-
- {
-
- $sel_token_check = "select * from user_meta where user_meta_value = :user_meta_value";
-
- $sel_token_param = array("user_meta_value"=>$token);
-
- $res = parent::selectQuery($sel_token_check,$sel_token_param);
-
-
-
- if(!empty($res))
-
- {
-
- return $res[0]['user_id'];
-
- } else {
-
- return false;
-
- }
-
- }
-
-
-
- //Fetched User Details By ID
-
- public function getUserDetails($user_id)
-
- {
-
- $sel_user_query = "SELECT * FROM users WHERE `user_id`=:user_id";
-
- $sel_user_param = array("user_id"=>$user_id);
-
- $user_details = parent::selectQuery($sel_user_query, $sel_user_param);
-
-
-
- return $user_details[0];
-
- }
-
-
-
-
-
- //Fetched Transacton details base on Transaction ID
-
- public function getTransactionDetails($transaction_id){
-
- $sel_query = "SELECT * FROM transection_details WHERE `id`=:id";
-
- $sel_param = array("id"=>$transaction_id);
-
- $res_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- return $res_details;
-
- }
-
-
-
- //Fetched Receiver Stripe ID base on user id
-
- public function getReceiverStripeID($user_id){
-
-
-
- $sel_query = "SELECT * FROM stripe_account_details WHERE `user_id`=:user_id";
-
- $sel_param = array("user_id"=>$user_id);
-
- $res_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- return $res_details[0]['stripe_user_id'];
-
- }
-
-
-
- //Fetched Card Details based on Card Id
-
- public function getCardDetails($card_id){
-
-
-
- $sel_query = "SELECT * FROM user_card_details WHERE `card_id`=:card_id";
-
- $sel_param = array("card_id"=>$card_id);
-
- $card_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- return $card_details;
-
- }
-
-
-
- //Generate Stripe Token
-
- public function getStripeToken($card_details){
-
-
-
- try{
-
- // Create Token for payment
-
- $token_obj = \Stripe\Token::create(array(
-
- "card" => array(
-
- "number" => $card_details['card_number'], //"4242424242424242",
-
- "exp_month" => $card_details['card_expire_month'], //5
-
- "exp_year" => $card_details['card_expire_year'], //2018,
-
- "cvc" => $card_details['card_cvv'] //"314"
-
- )
-
- ));
-
-
-
- return array("status"=>200,"token"=>$token_obj->id);
-
- } catch(\Stripe\Error\Card $e) {
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- if($err['type'] =='card_error' && $err['code'] == 'card_declined'){
-
- return array("status"=>500,"error_message"=>"There are problems with the your transfer.You are affiliated with SwippPay. The transfer may be blocked by us or you will not have money available on your payment card.");
-
- }
-
- } catch (Exception $e) {
-
- return array("status"=>500,"error_message"=>$e->getMessage());
-
- }
-
- }
-
-
-
- // Create Charge on Sender Stripe Account
-
- public function createStripeCharge($payble_amount,$currency_type,$token){
-
- //Send payment from sender to platfor
- if($currancy != 'usd'){
- //$payble_amount = round($payble_amount,2);
- $payble_amount = $this->convertCurrency($payble_amount,$currency_type,'usd');
- $payble_amount = round($payble_amount,2);
- }
- try{
-
- $charge = \Stripe\Charge::create(array(
-
- "amount" => $payble_amount * 100,
-
- "currency" => 'usd',
-
- "source" => $token
-
- ));
-
-
-
- //Insert Radar Details
-
- $ins_radar_query = "INSERT INTO radar_details (`charge_id`,`network_status`,`reason`,`risk_level`,`seller_message`) VALUES(:charge_id,:network_status,:reason,:risk_level,:seller_message)";
-
- $ins_radar_param = array("charge_id"=>$charge->id,"network_status"=>$charge->outcome->network_status,"reason"=>$charge->outcome->reason,"risk_level"=>$charge->outcome->risk_level,"seller_message"=>$charge->outcome->seller_message);
-
- $ins_radar_id = parent::insertQuery($ins_radar_query,$ins_radar_param);
-
-
-
- return array("status"=>1,"data"=>$charge);
-
- } catch(\Stripe\Error\Card $e) {
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- if($err['type'] =='card_error' && $err['code'] == 'card_declined'){
-
- return array("status"=>500,"error_message"=>"There are problems with the your transfer.
-
- You are affiliated with SwippPay. The transfer may be blocked by us or you will not have money available on your payment card.");
-
- }
-
- } catch(Exception $e) {
-
- return array("status"=>0,"message"=>$e->getMessage());
-
- }
-
- }
-
-
-
- //Check Payment Details into Payment Details Table
-
- public function checkPaymentEntry($transection_id,$sender_stripe_id,$payment_type = 1, $payment_status = 1){
-
-
-
- //Check Payment Data
-
- $sel_payment_query = "SELECT * FROM payment_details_table WHERE `transaction_id`=:transaction_id AND `stripe_user_id`=:stripe_user_id AND `payment_type`=:payment_type AND `payment_status`=:payment_status";
-
- $sel_payment_param = array(
-
- 'transaction_id' => $transection_id,
-
- 'stripe_user_id' => $sender_stripe_id,
-
- 'payment_type' => $payment_type,
-
- 'payment_status' => $payment_status
-
- );
-
- $res_payment_details = parent::selectQuery($sel_payment_query,$sel_payment_param);
-
- return $res_payment_details;
-
- }
-
-
-
- //Insert Payment Details into Payment Details Table
-
- public function insertPaymentEntry($transection_id,$sender_stripe_id,$payment_type,$payble_amount,$txn_id,$payment_status){
-
-
-
- //Insert Payment Data
-
- $ins_payment_query = "INSERT INTO payment_details_table (`transaction_id`,`stripe_user_id`, `payment_type`, `amount_payble`, `txn_id`, `payment_status`) VALUES(:transaction_id,:stripe_user_id,:payment_type,:amount_payble,:txn_id,:payment_status)";
-
- $ins_payment_param = array(
-
- 'transaction_id' => $transection_id,
-
- 'stripe_user_id' => $sender_stripe_id,
-
- 'payment_type' => $payment_type,
-
- 'amount_payble' => $payble_amount,
-
- 'txn_id' => $txn_id,
-
- 'payment_status' => $payment_status
-
- );
-
- $res_payment_id = parent::insertQuery($ins_payment_query,$ins_payment_param);
-
- return $res_payment_id;
-
- }
-
-
-
- //Create Transfer to Receiver Stripe Account
-
- public function createStripeTransfer($payble_amount,$currancy,$receiver_user){
-
- if($currancy != 'usd'){
-
- $payble_amount = round($payble_amount,2);
- $payble_amount = $this->convertCurrency($payble_amount,$currancy,'usd'); //Convert Any Currancy into USD
-
- $payble_amount = round($payble_amount,2);
-
- }
-
-
-
- try{
-
- //Send payment from plaform to receiver
-
- $transfer = \Stripe\Transfer::create(array(
-
- "amount" => (float)$payble_amount*100,
-
- "currency" => "usd",
-
- "destination" => $receiver_user
-
- ));
-
- //print_r($transfer);exit;
-
- return array("status"=>200,"transfer_id"=>$transfer->id);
-
-
-
- } catch (\Stripe\Error\Card $e) {
-
- // Since it's a decline, \Stripe\Error\Card will be caught
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (\Stripe\Error\RateLimit $e) {
-
- // Too many requests made to the API too quickly
-
-
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (\Stripe\Error\InvalidRequest $e) {
-
- // Invalid parameters were supplied to Stripe's API
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (\Stripe\Error\Authentication $e) {
-
- // Authentication with Stripe's API failed
-
- // (maybe you changed API keys recently)
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (\Stripe\Error\ApiConnection $e) {
-
- // Network communication with Stripe faile
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (\Stripe\Error\Base $e) {
-
- // Display a very generic error to the user, and maybe send
-
- // yourself an email
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
-
-
- } catch (Exception $e) {
-
- // Something else happened, completely unrelated to Stripe
-
- $body = $e->getJsonBody();
-
- $err = $body['error'];
-
- return array("status"=>$e->getHttpStatus(),"message"=>$err['message']);
-
- }
-
-
-
- }
-
-
-
- //Convert Any Currancy into USD
-
- public function convertCurrency($amount, $from, $to){
-
- //$url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
-
- //$url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
-
- $url = "https://finance.google.com/finance/converter?a=$amount&from=$from&to=$to";
-
- $timeOut = 0;
-
-
-
- $request = curl_init();
-
- curl_setopt ($request, CURLOPT_URL, $url);
-
- curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1);
-
- curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
-
- curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut);
-
-
-
- $response = curl_exec($request);
-
- curl_close($request);
-
-
-
-
-
- preg_match("/<span class=bld>(.*)<\/span>/",$response, $converted);
-
-
-
- $converted = preg_replace("/[^0-9.]/", "", $converted[1]);
-
- return $converted;
-
- }
-
-
-
-
-
- //Update Transaction Status
-
- public function updateTransactionStatus($transaction_id,$transaction_status,$date){
-
-
-
- //Update Transection
-
- $update_transaction_query = "UPDATE transection_details SET `transection_status`=:transection_status, `create_date`=:create_date WHERE `id`=:id";
-
- $update_transaction_param = array(
-
- 'transection_status' => $transaction_status,
-
- 'id' => $transaction_id,
-
- 'create_date' => date("Y-m-d H:i:s",strtotime($date))
-
- );
-
- $res_transaction = parent::updateQuery($update_transaction_query,$update_transaction_param);
-
-
-
- return $res_transaction;
-
- }
-
- //DELETE Transaction
-
- public function deleteTransactionStatus($transaction_id)
-
- {
-
- $update_transaction_query = "DELETE FROM transection_details WHERE `id`=:id ";
-
- $update_transaction_param = array(
-
- 'id' => $transaction_id
-
- );
-
- $res_transaction = parent::deleteQuery($update_transaction_query,$update_transaction_param);
-
-
-
- return $res_transaction;
-
- }
-
-
-
- //Check Payment Status
-
- public function checkPaymentStatus($transaction_id, $receiver_stripe_id){
-
-
-
- $sel_query = "SELECT * FROM payment_details_table WHERE `transaction_id`=:transaction_id AND `stripe_user_id`=:stripe_user_id";
-
- $sel_param = array("transaction_id"=>$transaction_id,"stripe_user_id"=>$receiver_stripe_id);
-
- $res_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- if(count($res_details) > 0)
-
- {
-
- return true;
-
-
-
- } else {
-
-
-
- return false;
-
- }
-
- }
-
-
-
- //Check Bank Account (External Account) connected with stripe account
-
- public function checkExternalAccountConnect($stripe_account_id){
-
-
-
- $sel_query = "SELECT * FROM stripe_account_details WHERE `stripe_user_id`=:stripe_user_id ";
-
- $sel_param = array("stripe_user_id"=>$stripe_account_id);
-
- $res_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- if($res_details[0]['stripe_bank_account_id'] != NULL && $res_details[0]['stripe_bank_account_id'] != ''){
-
-
-
- return true;
-
-
-
- } else {
-
-
-
- return false;
-
- }
-
- }
-
-
-
- //Fetched User ID using Stripe Account ID FROM Stripe Account Details Table
-
- public function getUserIDFromStripeId($stripe_user_id){
-
-
-
- $sel_query = "SELECT * FROM stripe_account_details WHERE `stripe_user_id`=:stripe_user_id ";
-
- $sel_param = array("stripe_user_id"=>$stripe_user_id);
-
- $res_details = parent::selectQuery($sel_query,$sel_param);
-
-
-
- return $res_details[0]['user_id'];
-
- }
-
-
-
- //Generate Bank Account Token
-
- public function generateBankToken($stripe_account_id){
-
-
-
- $user_id = $this->getUserIDFromStripeId($stripe_account_id);
-
-
-
- $user_details = $this->getUserDetails($user_id);
-
-
-
- if($user_details['user_country'] != '' || $user_details['user_country'] != NULL){
-
- $sel_country_query = "SELECT `country_sort_name` FROM country_sort_name WHERE `country_name` =:country_name";
-
- $sel_country_param = array("counrty_name"=>$user_details['user_country']);
-
- $country_details = parent::selectQuery($sel_country_query,$sel_country_param);
-
-
-
- if(count($country_details) > 0){
-
- $country_code = strtoupper($country_details[0]['country_sort_name']);
-
- } else {
-
- $country_code = 'US';
-
- }
-
- } else {
-
- $country_code = 'US';
-
- }
-
-
-
-
-
- try{
-
- $bank_token = \Stripe\Token::create(array(
-
-
-
- "bank_account" => array(
- "country" => 'US',
- "currency" => 'usd',
- "account_holder_name" => "William Williams",
- "account_holder_type" => "individual",
- "routing_number" => "110000000",
- "account_number" => "000123456789"
- )
- ));
-
- return $bank_token->id;
-
- } catch (Exception $e) {
-
- echo $e->getMessage();
-
- exit;
-
- }
-
- }
-
-
-
- //Update Stripe Account Details
-
- public function updateStripeAccountDetails($stripe_user_id,$stripe_acount_bank_id){
-
-
-
- $update_stripe_query = "UPDATE stripe_account_details SET `stripe_bank_account_id`=:stripe_bank_account_id WHERE `stripe_user_id`=:stripe_user_id ";
-
- $update_stripe_param = array("stripe_bank_account_id"=>$stripe_acount_bank_id,"stripe_user_id"=>$stripe_user_id);
-
- $update_stripe_result = parent::updateQuery($update_stripe_query,$update_stripe_param);
-
-
-
- if($update_stripe_result > 0)
-
- return true;
-
- else
-
- return false;
-
- }
-
-
-
- //Connect Bank Account With Stripe Account as a External Account.
-
- public function connectExternalAccount($stripe_user_id){
-
- try{
-
-
-
- $bank_token_id = $this->generateBankToken($stripe_user_id);
-
- $account = \Stripe\Account::retrieve($stripe_user_id);
-
- $bankAccount = $account->external_accounts->create(array("external_account" => $bank_token_id));
-
-
-
- /******Update Stripe Account Start *******/
-
-
-
- /*$user_id = $this->getUserIDFromStripeId($stripe_user_id);
-
- $user_details = $this->getUserDetails($user_id);
-
-
-
- //Accept Licence Stripe API Platform
-
- $account->tos_acceptance->date = time();
-
- $account->tos_acceptance->ip = $_SERVER['REMOTE_ADDR'];
-
-
-
- //Legal Entity Entry
-
- $birth_day_array = explode('-',$user_details['birth_date']);
-
- $account->legal_entity->dob->day = $birth_day_array[2];
-
- $account->legal_entity->dob->month = $birth_day_array[1];
-
- $account->legal_entity->dob->year = $birth_day_array[0];
-
- $account->legal_entity->first_name = ($user_details['user_name']!='')?$user_details['user_name']:$user_details['user_shop_name'];
-
- $account->legal_entity->last_name = ($user_details['user_name']!='')?$user_details['user_name']:$user_details['user_shop_name'];
-
- $account->legal_entity->type = "individual";
-
- $account->legal_entity->address->line1 = ($user_details['user_address'] != '')?$user_details['user_address']:"1234 Main Street";
-
- $account->legal_entity->address->postal_code = ($user_details['user_zipcode'] != '')?$user_details['user_zipcode']:94111;
-
- $account->legal_entity->address->city = ($user_details['user_city'] != '')?$user_details['user_city']:"San Francisco";
-
- //$account->legal_entity->address->state = "CA";
-
- $account->legal_entity->ssn_last_4 = substr($user_details['user_ssn_number'], -4);
-
- $account->legal_entity->personal_id_number = ($user_details['user_ssn_number'] != '')?$user_details['user_ssn_number']:123451234;
-
- $account->save();*/
-
- /******Update Stripe Account END *******/
-
-
-
- $updated_res = $this->updateStripeAccountDetails($stripe_user_id,$bankAccount->id);
-
-
-
- return array("status"=>200,"stripe_bank_account_id"=>$bankAccount->id);
-
-
-
- } catch (Exception $e) {
-
- return array("status"=>500,"error_message"=>$e->getMessage());
-
- }
-
- }
-
-
-
- //Insert Payout Details in payout Details table
-
- public function insertPayoutDetails($stripe_user_id,$amount,$currency,$payout_id,$payout_status)
-
- {
-
- $ins_payout_query = "INSERT INTO payout_details (`stripe_user_id`,`payout_amount`,`currancy`,`stripe_payout_id`,`payout_status`) VALUES(:stripe_user_id,:payout_amount,:currancy,:stripe_payout_id,:payout_status) ";
-
- $ins_payout_param = array("stripe_user_id"=>$stripe_user_id,"payout_amount"=>$amount,"currancy"=>$currency,"stripe_payout_id"=>$payout_id,"payout_status"=>$payout_status);
-
- $payout_id = parent::insertQuery($ins_payout_query,$ins_payout_param);
-
-
-
- return $payout_id;
-
- }
-
-
-
-
-
- // Make Bank Account Payout using stripe API Request
-
- public function makePayout($stripe_user_id,$amount,$currency = 'usd')
-
- {
-
- if($currency != 'usd'){
-
- $payble_amount = $this->convertCurrency($amount,$currency,'usd');
-
- $payble_amount = round($payble_amount,2);
-
- } else {
-
- $payble_amount = $amount;
-
- }
-
-
-
-
-
- try{
-
-
-
- $tr = \Stripe\Payout::create(
-
- array(
-
- "amount" => (float)$payble_amount*100,
-
- "currency" => "usd"
-
- ),
-
- array("stripe_account" => $stripe_user_id)
-
- );
-
-
-
- $payout_id = $this->insertPayoutDetails($stripe_user_id,$amount,$currency,$tr->id,$tr->status);
-
-
-
- return array("status"=>200,"payout_id"=>$payout_id);
-
-
-
- } catch (Exception $e){
-
- return array("status"=>500,"error_message"=>$e->getMessage());
-
- }
-
- }
-
-
-
-
-
- /* function sendMessage($token){
-
-
-
- $user_id = $this->isValidToken($token);
-
-
-
- $qry = "select * from users where user_id = :user_id";
-
- $param = array("user_id"=>$user_id);
-
- $result = parent::selectQuery($qry,$param);
-
-
-
- $username = ($result[0]['user_name'] != ' ')?$result[0]['user_name']:$result[0]['user_shop_name'];
-
-
-
- $content = array(
-
- "en" => "Accept Payment by ".$username
-
- );
-
-
-
- $fields = array(
-
- 'app_id' => "2215e06d-959c-430e-a424-b0ada21b1476",
-
- 'include_player_ids' => array($result[0]['user_onesignal_id']),
-
- 'data' => array("Name" =>$username,"Mobile No"=>$result[0]['user_number'],"user_email"=>$result[0]['user_email'],"user_image"=>$result[0]['user_image'],"birth_date"=>$result[0]['birth_date'],"user_address"=>$result[0]['user_address'],"user_zipcode"=>$result[0]['user_zipcode'],"user_city"=>$result[0]['user_city'],"user_country"=>$result[0]['user_country']),
-
- 'contents' => $content
-
- );
-
-
-
- $fields = json_encode($fields);
-
- /* print("\nJSON sent:\n");
-
- print($fields);
-
-
-
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
-
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
-
- 'Authorization: Basic ZmRjNGQzMGItNjcwZi00ZDY3LTliMGQtNWI5NmQ1MGIzNzdm'));
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
-
- curl_setopt($ch, CURLOPT_POST, TRUE);
-
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-
-
-
- $response = curl_exec($ch);
-
- curl_close($ch);
-
-
-
- return $response;
-
- } */
-
-
-
-
-
- function sendMessage($token,$transaction_id){
-
-
-
- $trasction_de = "select * from transection_details where id = :receiver_stripe_id and transaction_type != 1";
-
- $param = array("receiver_stripe_id"=>$transaction_id);
-
- $trasction_details = parent::selectQuery($trasction_de,$param);
-
- //print_r($transaction_details);exit;
-
-
-
-
-
- $user_id1 = $this->getUserIDFromStripeId($trasction_details[0]['receiver_stripe_id']);
- $sender_id = $this->getUserIDFromStripeId($trasction_details[0]['sender_stripe_id']);
-
-
- $user_details = $this->getUserDetails($user_id1);
- $sender_details = $this->getUserDetails($sender_id);
-
-
-
- //print_r($user_details['user_id']);
-
-
-
- //$user_id = $this->isValidToken($token);
-
-
-
- $qry = "select * from users where user_id = :user_id";
-
- $param = array("user_id"=>$user_details['user_id']);
-
- $result = parent::selectQuery($qry,$param);
-
-
-
- //$user_id = $this->isValidToken($token);
-
-
-
- /* $qry = "select * from users where user_id = :user_id";
-
- $param = array("user_id"=>$user_id);
-
- $result = parent::selectQuery($qry,$param); */
-
-
-
- $username = ($result[0]['user_name'] != ' ')?$result[0]['user_name']:$result[0]['user_shop_name'];
- $sendername = ($sender_details['user_name'] != ' ' && $sender_details['user_name'] != '' && $sender_details['user_name'] != null)?$sender_details['user_name']:$sender_details['user_shop_name'];
-
-
-
-
-
-
-
- $transaction_details = $this->getTransactionDetails($transaction_id);
-
- //print_r($transaction_details[0]['id']);
-
-
-
- $content = array(
-
- //"en" => "Your Payment Request accepted by ".$username
- "en" => "Your Payment Request accepted by ".$sendername
-
- );
-
-
-
- $fields = array(
-
- //'app_id' => "2215e06d-959c-430e-a424-b0ada21b1476",
-
- 'app_id' => "c168bd8b-1327-4fc6-9c59-a7ae9a770c93",
-
- 'include_player_ids' => array($result[0]['user_onesignal_id']),
-
- 'data' => array("user_name" =>$username,
-
- "user_number"=>$result[0]['user_number'],
-
- "user_image"=>$result[0]['user_image'],
-
- "receiver_amount"=>$transaction_details[0]['receiver_amount'],
-
- "card_id"=>$transaction_details[0]['card_id'],
-
- "transaction_id"=>$transaction_details[0]['id'],
-
- "transaction_type"=>$transaction_details[0]['transaction_type'],
-
- "currancy_type"=>$transaction_details[0]['currancy_type'],
-
- "create_date"=>$transaction_details[0]['create_date'],
-
- //"request_status"=>$transaction_details[0]['transection_status'],
-
- "request_status"=>"request_payment",
-
- "user_email"=>$result[0]['user_email'],
-
- "birth_date"=>$result[0]['birth_date'],
-
- "user_address"=>$result[0]['user_address'],
-
- "user_zipcode"=>$result[0]['user_zipcode'],
-
- "user_city"=>$result[0]['user_city'],
-
- "user_country"=>$result[0]['user_country'],
-
- "extra_image"=>$transaction_details[0]['image'],
-
- "extra_message"=>$transaction_details[0]['message'],
-
- "payble_amount"=>$transaction_details[0]['payble_amount']),
-
- 'contents' => $content,
-
- );
-
-
-
- $fields = json_encode($fields);
-
- /* print("\nJSON sent:\n");*/
-
- //print($fields);
-
-
-
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
-
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
-
- 'Authorization: Basic ZTY3NzIxMjctNjNlYS00NDIyLWIzMzUtZjJlZTA4NzlkOGIx'));
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
-
- curl_setopt($ch, CURLOPT_POST, TRUE);
-
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-
-
-
- $response = curl_exec($ch);
-
- curl_close($ch);
-
-
-
- return $response;
-
- }
-
-
-
- //Accept Payment Transfer Request
-
- public function acceptRequest($token, $transaction_id, $card_id, $status,$date)
-
- {
-
- // Check Token is Valid or Not
-
- if($user_id = $this->isValidToken($token)){
-
-
-
- $qry = "select * from users where user_id = :user_id";
-
- $param = array("user_id"=>$user_id);
-
- $result = parent::selectQuery($qry,$param);
-
-
-
- if($result[0]['user_status'] != 3){
-
-
-
- $transaction_details = $this->getTransactionDetails($transaction_id); // Get Transaction Details
-
-
-
- if(count($transaction_details) > 0){
-
-
-
- $receiver_stripe_id = $transaction_details[0]['receiver_stripe_id']; // Fetched Receiver Stripe Account ID
-
-
-
- $sender_user_id = $this->getUserIDFromStripeId($transaction_details[0]['sender_stripe_id']);
-
-
-
- if($user_id == $sender_user_id){
-
-
-
- if($status == 'accept')
-
- {
-
- $card_details = $this->getCardDetails($card_id); // Fetched Card Details
-
-
-
- $stripe_token = $this->getStripeToken($card_details[0]); //Generate Token for payment
-
-
-
- if($stripe_token['status'] == 500) {
-
- return array("status"=>array("response_code"=>500, "response_message"=>$strip_token['error_message']));
-
- }
-
-
-
- $chargeObj = $this->createStripeCharge($transaction_details[0]['payble_amount'],$transaction_details[0]['currancy_type'],$stripe_token['token']);
-
-
-
- if($chargeObj['status'] == 1) {
-
-
-
- $payment_id = $this->insertPaymentEntry($transaction_id,$transaction_details[0]['sender_stripe_id'],1,$transaction_details[0]['payble_amount'],$chargeObj['data']->id,$chargeObj['data']->paid);
-
-
-
- } else if($chargeObj['status'] == 0) {
-
-
-
- return array("status"=>array("response_code"=>"405", "response_message"=>$chargeObj['message']));
-
- }
-
-
-
- $transferObj = $this->createStripeTransfer($transaction_details[0]['receiver_amount'],$transaction_details[0]['currancy_type'],$receiver_stripe_id);
-
-
-
- if($transferObj['status'] == 200){
-
-
-
- $transfer_payment_id = $this->insertPaymentEntry($transaction_id,$receiver_stripe_id,2,$transaction_details[0]['receiver_amount'],$transferObj['transfer_id'],1);
-
-
-
- if($this->checkExternalAccountConnect($receiver_stripe_id)){
-
-
-
- $payout = $this->makePayout($receiver_stripe_id,$transaction_details[0]['receiver_amount'],$transaction_details[0]['currancy_type']);
-
- if($payout['status'] == 500) {
-
- $transaction_status = $this->updateTransactionStatus($transaction_id, 1, $date);
-
- return array("status"=>array("response_code"=>$payout['status'], "response_message"=>"Transfer Payment Successfully but not transfer from receiver bank account due to ".$payout['error_message']));
-
- }
-
- } else {
-
-
-
- $stripe_bank_account = $this->connectExternalAccount($receiver_stripe_id);
-
- if($stripe_bank_account['status'] == 200){
-
- $payout_id = $this->makePayout($receiver_stripe_id,$transaction_details[0]['receiver_amount'],$transaction_details[0]['currancy_type']);
-
- if($payout_id['status'] == 500) {
-
- $transaction_status = $this->updateTransactionStatus($transaction_id, 1,$date);
-
- return array("status"=>array("response_code"=>$payout_id['status'], "response_message"=>"Transfer Payment Successfully but not transfer from receiver bank account due to ".$payout_id['error_message']));
-
- }
-
- } else {
-
- $transaction_status = $this->updateTransactionStatus($transaction_id, 1, $date);
-
- return array("status"=>array("response_code"=>$stripe_bank_account['status'], "response_message"=>"Transfer Payment Successfully but not transfer from receiver bank account due to ".$stripe_bank_account['error_message']));
-
- }
-
-
-
- }
-
- }
-
- else
-
- return array("status"=>array("response_code"=>$transferObj['status'], "response_message"=>$transferObj['message']));
-
-
-
- $transaction_status = $this->updateTransactionStatus($transaction_id, 1, $date);
-
-
-
- return array("status"=>array("response_code"=>"201", "response_message"=>"Transfer Payment Successfully."));
-
-
-
- } else if ($status == 'rejected'){
-
-
-
- $result = $this->deleteTransactionStatus($transaction_details[0]['id']);
-
-
-
- if($result){
-
- return array("status"=>array("response_code"=>"201", "response_message"=>"Request Rejected Successfully."));
-
- }
-
- }
-
- } else {
-
- return array("status"=>array("response_code"=>"403", "response_message"=>"No Such Transaction Found For This User...!"));
-
- }
-
-
-
- } else {
-
- return array("status"=>array("response_code"=>"403", "response_message"=>"Transaction Not Found...!"));
-
- }
-
- } else {
-
- $msg = "Your account is suspended. Please contact customer service by email. info@swipp-pay.com !";
-
- return(array("status"=>array("response_code"=>'501',"response_message"=>$msg)));
-
- }
-
-
-
- } else {
-
- return array("status"=>array("response_code"=>"403", "response_message"=>"Please Enter Valid Token...!"));
-
- }
-
- }
-
- }