Merge branch 'master' into 'dev_production'
Master
See merge request !8
Showing
... | @@ -252,7 +252,7 @@ class Api extends CI_Controller { | ... | @@ -252,7 +252,7 @@ class Api extends CI_Controller { |
public function discover() { | public function discover() { | ||
$data = (array) json_decode(file_get_contents('php://input')); | $data = (array) json_decode(file_get_contents('php://input')); | ||
$data['auth_token'] = $this->auth_token; | //$data['auth_token'] = $this->auth_token; | ||
$res = $this->Api_model->discover($data); | $res = $this->Api_model->discover($data); | ||
if($res['status']!=0){ | if($res['status']!=0){ | ||
$this->response($res['data']); | $this->response($res['data']); | ||
... | @@ -264,7 +264,7 @@ class Api extends CI_Controller { | ... | @@ -264,7 +264,7 @@ class Api extends CI_Controller { |
public function event() { | public function event() { | ||
$data = (array) json_decode(file_get_contents('php://input')); | $data = (array) json_decode(file_get_contents('php://input')); | ||
$data['auth_token'] = $this->auth_token; | //$data['auth_token'] = $this->auth_token; | ||
$res = $this->Api_model->event($data); | $res = $this->Api_model->event($data); | ||
if($res['status']!=0){ | if($res['status']!=0){ | ||
$this->response($res['data']); | $this->response($res['data']); | ||
... | @@ -276,7 +276,7 @@ class Api extends CI_Controller { | ... | @@ -276,7 +276,7 @@ class Api extends CI_Controller { |
public function search() { | public function search() { | ||
$data = (array) json_decode(file_get_contents('php://input')); | $data = (array) json_decode(file_get_contents('php://input')); | ||
$data['auth_token'] = $this->auth_token; | //$data['auth_token'] = $this->auth_token; | ||
$res = $this->Api_model->search($data); | $res = $this->Api_model->search($data); | ||
if($res['status']!=0){ | if($res['status']!=0){ | ||
... | @@ -298,45 +298,127 @@ class Api extends CI_Controller { | ... | @@ -298,45 +298,127 @@ class Api extends CI_Controller { |
} | } | ||
} | } | ||
public function payNow($auth_token='',$amount=0,$booking_id='',$event_id=''){ | |||
if(empty($auth_token) || empty($amount) || empty($booking_id)){ | |||
redirect('http://localhost:4200/failure'); | |||
} | |||
$payData = array('auth_token'=>$auth_token,'amount'=>$amount,'booking_id'=>$booking_id); | |||
$res = $this->Api_model->payNow($payData); | |||
if($res['status']==1){ | |||
$this->paymentGateway($amount,$res['transaction_id'],$event_id,$booking_id); | |||
} | |||
else{ | |||
redirect('http://localhost:4200/failure?event_id='.$eventid); | |||
} | |||
} | |||
public function paymentSuccessUrl(){ | |||
$response = ''; | |||
$transaction_id = ''; | |||
BayanPayPayment(); | |||
$BayanPayArray = $this->bayanPayArray('0','0','0','0'); | |||
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray); | |||
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){ | |||
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv); | |||
$ref_id = explode('|',$response['Transaction_related_information']); | |||
$transaction_id = $ref_id[1]; | |||
$last_id = explode('|',$response['Merchant_Information']); | |||
$lastid = $last_id[1]; | |||
$eventid = $last_id[2]; | |||
$booking_id = $last_id[3]; | |||
$this->Api_model->update_payment($response,$transaction_id,$lastid,'1') ; | |||
redirect('http://localhost:4200/bookingdetails?booking_id='.$booking_id); | |||
} | |||
} | |||
public function paymentFailureUrl(){ | |||
$lastid = ''; | |||
$response = ''; | |||
$transaction_id = ''; | |||
BayanPayPayment(); | |||
$BayanPayArray = $this->bayanPayArray('0','0','0','0'); | |||
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray); | |||
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){ | |||
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv); | |||
$ref_id = explode('|',$response['Transaction_related_information']); | |||
$transaction_id = $ref_id[1]; | |||
$last_id = explode('|',$response['Merchant_Information']); | |||
$lastid = $last_id[1]; | |||
$eventid = $last_id[2]; | |||
$booking_id = $last_id[3]; | |||
$this->Api_model->update_payment($response,$transaction_id,$lastid,'0'); | |||
redirect('http://localhost:4200/failure?event_id='.$eventid); | |||
} | |||
} | |||
public function paymentGateway(){ | public function paymentGateway($amount='0',$lastid='0',$event_id='0',$booking_id='0'){ | ||
BayanPayPayment(); | BayanPayPayment(); | ||
$BayanPayArray = $this->bayanPayArray($amount,$lastid,$event_id,$booking_id); | |||
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray); | |||
$requestParameter = $BayanPayOnlineObject->BayanPostData; | |||
if($BayanPayOnlineObject->url){ | |||
$requestUrl = 'https://payments.bayanpay.sa/direcpay/secure/PaymentTxnServlet'; | |||
} | |||
else{ | |||
$requestUrl = 'https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet'; | |||
} | |||
$this->load->view('payment/payment',array('requestUrl'=>$requestUrl, | |||
'requestParameter'=>$requestParameter)); | |||
} | |||
$networkOnlineArray = | function baseurl(){ | ||
array('Network_Online_setting' => | if(isset($_SERVER['HTTPS'])) | ||
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; | |||
else | |||
$protocol = 'http'; | |||
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |||
} | |||
function bayanPayArray($amount = '0',$lastid='',$event_id='',$booking_id=''){ | |||
$BayanPayArray = | |||
array( | array( | ||
'BayanPay_Online_setting' => array( | |||
'merchantKey' => "+Hu4bL6iVk943JmFAvGtWEYMODFry4fad2I+iM0X2m0=", | 'merchantKey' => "+Hu4bL6iVk943JmFAvGtWEYMODFry4fad2I+iM0X2m0=", | ||
'merchantId' => '201901291000002', | 'merchantId' => '201901291000002', | ||
'collaboratorId' => 'NI', | 'collaboratorId' => 'BAYANPAY', | ||
'iv' => '0123456789abcdef', | 'iv' => '0123456789abcdef', | ||
'url' => false | 'url' => false// Set to false if you are using testing environment , set to true if you are using live environment | ||
), | ), | ||
'Block_Existence_Indicator' => array( | 'Block_Existence_Indicator' => array( | ||
'transactionDataBlock' => true, | 'transactionDataBlock' => true, | ||
'billingDataBlock' => true, | 'billingDataBlock' => true, | ||
'shippingDataBlock' => true, | 'shippingDataBlock' => true, | ||
'paymentDataBlock' => false, | 'paymentDataBlock' => false, | ||
'merchantDataBlock' => false, | 'merchantDataBlock' => true, | ||
'otherDataBlock' => false, | 'otherDataBlock' => false, | ||
'DCCDataBlock' => false | 'DCCDataBlock' => false | ||
), | ), | ||
'Field_Existence_Indicator_Transaction' => array( | 'Field_Existence_Indicator_Transaction' => array( | ||
'merchantOrderNumber' => time(), | 'merchantOrderNumber' => time(), | ||
'amount' => '100.00', | 'amount' => $amount, | ||
'successUrl' => $this->baseurl(), | 'successUrl' => base_url('Api/paymentSuccessUrl'), | ||
'failureUrl' => $this->baseurl(), | 'failureUrl' => base_url('Api/paymentFailureUrl'), | ||
'transactionMode' => 'INTERNET', | 'transactionMode' => 'INTERNET', | ||
'payModeType' => 'CC', | 'payModeType' => 'CC', | ||
'transactionType' => '01', | 'transactionType' => '01', | ||
'currency' => 'AED' | 'currency' => 'SAR' | ||
), | ), | ||
'Field_Existence_Indicator_Billing' => array( | 'Field_Existence_Indicator_Billing' => array( | ||
'billToFirstName' => 'Soloman', | 'billToFirstName' => 'Soloman', | ||
'billToLastName' => 'Vandy', | 'billToLastName' => 'Vandy', | ||
'billToStreet1' => '123,ParkStreet', | 'billToStreet1' => '123,ParkStreet', | ||
'billToStreet2' => 'Park Street', | 'billToStreet2' => 'Park Street', | ||
'billToCity' => 'Mumbai', | 'billToCity' => 'Riyadh', | ||
'billToState' => 'Maharashtra', | 'billToState' => 'Riyadh', | ||
'billtoPostalCode' => '400081', | 'billtoPostalCode' => '400081', | ||
'billToCountry' => 'IN', | 'billToCountry' => 'IN', | ||
'billToEmail' => '[email protected]', | 'billToEmail' => '[email protected]', | ||
... | @@ -350,8 +432,8 @@ class Api extends CI_Controller { | ... | @@ -350,8 +432,8 @@ class Api extends CI_Controller { |
'shipToLastName' => 'Vandy', | 'shipToLastName' => 'Vandy', | ||
'shipToStreet1' => '123ParkStreet', | 'shipToStreet1' => '123ParkStreet', | ||
'shipToStreet2' => 'parkstreet', | 'shipToStreet2' => 'parkstreet', | ||
'shipToCity' => 'Mumbai', | 'shipToCity' => 'Riyadh', | ||
'shipToState' => 'Maharashtra', | 'shipToState' => 'Riyadh', | ||
'shipToPostalCode' => '400081', | 'shipToPostalCode' => '400081', | ||
'shipToCountry' => 'IN', | 'shipToCountry' => 'IN', | ||
'shipToPhoneNumber1' => '', | 'shipToPhoneNumber1' => '', | ||
... | @@ -366,73 +448,33 @@ class Api extends CI_Controller { | ... | @@ -366,73 +448,33 @@ class Api extends CI_Controller { |
'CVV' => '123', // 4. CVV | 'CVV' => '123', // 4. CVV | ||
'cardHolderName' => 'Soloman', // 5. Card Holder Name | 'cardHolderName' => 'Soloman', // 5. Card Holder Name | ||
'cardType' => 'Visa', // 6. Card Type | 'cardType' => 'Visa', // 6. Card Type | ||
'custMobileNumber'=> '9820998209', // 7. Customer Mobile Number | 'custMobileNumber' => '9820998209', // 7. Customer Mobile Number | ||
'paymentID' => '123456', // 8. Payment ID | 'paymentID' => '123456', // 8. Payment ID | ||
'OTP' => '123456', // 9. OTP field | 'OTP' => '123456', // 9. OTP field | ||
'gatewayID' => '1026', // 10.Gateway ID | 'gatewayID' => '1026', // 10.Gateway ID | ||
'cardToken' => '1202' // 11.Card Token | 'cardToken' => '1202' // 11.Card Token | ||
), | ), | ||
'Field_Existence_Indicator_Merchant' => | 'Field_Existence_Indicator_Merchant' => array( | ||
array( | 'UDF1' => $lastid, | ||
'UDF1' => '115.121.181.112', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | 'UDF2' => $event_id, | ||
'UDF2' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | 'UDF3' => $booking_id | ||
'UDF3' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF4' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF5' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF6' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF7' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF8' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF9' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
'UDF10' => 'abc' // This is a ‘user-defined field’ that can be used to send additional information about the transaction. | |||
), | ), | ||
'Field_Existence_Indicator_OtherData' => | 'Field_Existence_Indicator_OtherData' => array( | ||
array( | |||
'custID' => '12345', | 'custID' => '12345', | ||
'transactionSource' => 'IVR', | 'transactionSource' => 'IVR', | ||
'productInfo' => 'Book', | 'productInfo' => 'Book', | ||
'isUserLoggedIn' => 'Y', | 'isUserLoggedIn' => 'Y', | ||
'itemTotal' => '500.00, 1000.00', | 'itemTotal' => '500.00, 1000.00', | ||
'itemCategory' => 'CD, Book', | 'itemCategory' => 'CD, Book', | ||
'ignoreValidationResult' => 'FALSE' | 'ignoreValidationResult'=> 'FALSE' | ||
), | ), | ||
'Field_Existence_Indicator_DCC' => | 'Field_Existence_Indicator_DCC' => array( | ||
array( | |||
'DCCReferenceNumber' => '09898787', // DCC Reference Number | 'DCCReferenceNumber' => '09898787', // DCC Reference Number | ||
'foreignAmount' => '240.00', // Foreign Amount | 'foreignAmount' => '240.00', // Foreign Amount | ||
'ForeignCurrency' => 'USD' // Foreign Currency | 'ForeignCurrency' => 'USD' // Foreign Currency | ||
) | ) | ||
); | ); | ||
return $BayanPayArray; | |||
$networkOnlineObject = new NetworkonlieBitmapPaymentIntegration($networkOnlineArray); | |||
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){ | |||
$response = $networkOnlineObject->decryptData($_REQUEST['responseParameter'],$networkOnlineObject->merchantKey,$networkOnlineObject->iv); | |||
$networkOnlineObject->AddLog('Network Online Response : '.print_r($response, TRUE),'16'); | |||
} | } | ||
$requestParameter = $networkOnlineObject->NeoPostData; | |||
// if($networkOnlineObject->url) | |||
// $requestUrl = 'https://www.timesofmoney.com/direcpay/secure/PaymentTxnServlet'; | |||
// else | |||
$requestUrl = 'https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet'; | |||
echo '<form action="'.$requestUrl.'" method="post" name="network_online_payment" | |||
id="network_online_payment"> | |||
<input type="hidden" name="requestParameter" value='.$requestParameter.'> | |||
<input type="submit" value="Submit"> | |||
</form>'; | |||
} | |||
function baseurl(){ | |||
if(isset($_SERVER['HTTPS'])) | |||
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; | |||
else | |||
$protocol = 'http'; | |||
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |||
} | |||
} | } | ||
?> | |||
\ No newline at end of file |
application/views/payment/payment.php
0 → 100644
Please
register
or
sign in
to comment