Laravel payhere integration
-
@root na, mata mage srver ekata payhere ganna one na, payhere site ekata mage data post karanna one,
mage steps thiyenne mehemai,
1.Cart table eke products thiyenawa, Checkout view ekedi me data view karanawa
- mama payhere checkout eka click karanawa,
//Ehanadi mn karanne {!! Form::Open(array('url' => '/payher_pap','id' => 'pay')) !!} //data tika controller ekata aragena cart eke tiyena data payhere table ekata save karagannawa //Ita passe thamai mata payhere.com site ekata amount ekai value ekai yawanna one //mata danaganna one controller eken amount ekai details tikai post method eken payhere ekata yawanna puluwanda kiyla,
-
Mama kalin post eke damma eka karanna checkout ekedi pay kiyala route ekak hadala eke view eke form eka JavaScript walin submit karanna
-
@root me widiyta JS walin payhere url ekt redirect krnna, tawa route ekk hdnna wenwa payment eka verify karnna
-
ow payment verify karanna route ekak one , payhere hena simple
-
@root
mama controller eken view ekata pahala thiyena widiyata data tika pass karanawa.controller
$payhere_currency = 'LKR'; $payhere_secret='***'; $merchant_id= '***'; $this->data = [ 'order' => $order, 'total' => $grand_total, 'merchant'=> $merchant_id, ]; return $this->view($response, 'payhere.twig');
view
<form action="https://sandbox.payhere.lk/pay/checkout" method="POST">
<input type="hidden" name="merchant_id" value="{{merchant}}"> <!-- Replace your Merchant ID -->
<input type="hidden" name="notify_url" value="{{'/payment/notify'|page}}">
<input type="hidden" name="cancel_url" value="{{'/payment/cancel'|page}}">
<input type="hidden" name="return_url" value="{{'/payment/return'|page}}">
<input type="text" name="order_id" value="{{order}}">
<input type="text" name="items" value="Door bell wireless"><br>
<input type="text" name="currency" value="LKR">
<input type="text" name="amount" value="{{grand_total}}">
<input type="submit" value="Continue to checkout" class="btn">
</form>payhere site ekata gihilla payhere eken ewanne "retutn" ekak.. "notify" ekak nemei
$app->POST('/payment/notif', PublicJobs::class . ':notify');
$app->POST('/payment/cancel', PublicJobs::class . ':cancel');
$app->POST('/payment/return', PublicJobs::class . ':return');mn me widiyata POST routes hadala thibunata payhere eken return karanne GET ekak.. notify funtion ekata calle wenneth ne.ai ehema wenne
-
-
Pahadili na, Payhere eken payment process eka pass karanawada? "Siteurl/Payment/return" me url return wenawada payment process eken passe?
-
@SI therune na machan, payhere site ekta redirect wenwda payment eka krnna?
-
![alt text]( image url)
site eken payhere ekata hariyata redirect wenawada? Ita passe Payhere eke methanata details fill karala pay click karata ube site eke url ekata "payhere/redirect" back wenawada
-
@alwismt pass wenawa eeth return karanne get ekak mn pahala ewannam return karana URL eka.. mage notify funtion eka call wenneth ne
-
@dev_lak ow payhere ekata yanawa payment okkoma update wenawa.. eeta passe apassata mage site ekata enakota mama dila thiyena POST URL ekata enawa.. eeth payhere eken ewanne GET url ekak a nisa "Method not allowed. Must be one of: POST" kiyanawa. anika mage notify funtion ekata calle wenneth ne
-
@alwismt ow oi tika wenawa. mage site ekata payhere eken ewanne GET ekak widiyata.. eeth mn hadala thiyenne POST URL ekak.pahala thiyenen mn hadapu URL 3
$app->POST('/payment/notif', PublicJobs::class . ':notify');
$app->POST('/payment/cancel', PublicJobs::class . ':cancel');
$app->POST('/payment/return', PublicJobs::class . ':return'); -
Pahadili, Localhost ekedi notify karaganna ba, return url eka ube browser eke load wenawa ube ube "host -dns" walat "localhost or test.lk" tiyena nisa but ubata data back wenne na me url walat data back wenna nam real ip ekak thought real domain ehekin ube lap ekata set karaganna one, ubata wifi router ekak tiyenawa nam ube network providerta call karala public ip ekak illaganin (free denawa) ita passe router ekata log wela port forwarding karapan ube lap eke local ipekata port 80 and 443 cloudflare use karala ube domain name eka ube gattu public ip ekata point karahan
-
This post is deleted! -
@SI macahn return url eka GET ekak tamai enne norify url eka tamai POST ekak enne
-
oyage return url eka GET ekak krnna,
-
Ita passe notify url eke process tika ube controller eke hadanna one, ubata payhere eken direct ewanne na notify url eka, blind karala ewanne eka nisa errors pennane na, ube route ekata /payment/notif dala controller ehekata pass krhn controller eken, uba ```
$merchant_id = $_POST['merchant_id']; $order_id = $_POST['order_id']; $payhere_amount = $_POST['payhere_amount']; $payhere_currency = $_POST['payhere_currency']; $status_code = $_POST['status_code']; $md5sig = $_POST['md5sig']; $merchant_secret = 'XXXXXXXXXXXXX'; // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page) $local_md5sig = strtoupper (md5 ( $merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret)) ) ); if (($local_md5sig === $md5sig) AND ($status_code == 2) ){ //TODO: Update your database as payment success } ubata data base eka update karaganna witari puluwan notify eken, redirect ekata ita passe hadaganin data base status eka anuwa
-
@alwismt mn live eke thamai me dewal karanne. domain eke nama test kiyala thiyenne. live eke notify funtion eka athule database update query ekak gahala thiyenawa. eeth update wenne ne..
-
@SI server eke access logs blpn, notify url ekata request awilla tynwda kyla
-
@dev_lak ow ehema karama nam prashne hari.. eeth mage notify funtion eka calle wenne ne.. eke thamai mn database update karala thiyenne. ai a?