|
@@ -5,10 +5,54 @@ namespace App\Http\Controllers\Guest;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Models\Order;
|
|
|
+use Omnipay\Omnipay;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class OrderController extends Controller
|
|
|
{
|
|
|
+ public function alipayNotify (Request $request) {
|
|
|
+ Log::info('alipayNotifyData: ' . json_encode($_POST));
|
|
|
+ $gateway = Omnipay::create('Alipay_AopF2F');
|
|
|
+ $gateway->setSignType('RSA2');
|
|
|
+ $gateway->setAppId(config('v2board.alipay_appid'));
|
|
|
+ $gateway->setPrivateKey(config('v2board.alipay_privkey'));
|
|
|
+ $gateway->setAlipayPublicKey(config('v2board.alipay_pubkey'));
|
|
|
+ $request = $gateway->completePurchase();
|
|
|
+ $request->setParams($_POST);
|
|
|
+ try {
|
|
|
+
|
|
|
+ $response = $request->send();
|
|
|
+
|
|
|
+ if($response->isPaid()){
|
|
|
+ $order = Order::where('trade_no', $_POST['out_trade_no'])->first();
|
|
|
+ if (!$order) {
|
|
|
+ abort(500, 'ERROR');
|
|
|
+ }
|
|
|
+ if ($order->status !== 0) {
|
|
|
+ die('SUCCESS');
|
|
|
+ }
|
|
|
+ $order->status = 1;
|
|
|
+ if (!$order->save()) {
|
|
|
+ abort(500, 'ERROR');
|
|
|
+ }
|
|
|
+
|
|
|
+ * Payment is successful
|
|
|
+ */
|
|
|
+ die('success');
|
|
|
+ }else{
|
|
|
+
|
|
|
+ * Payment is not successful
|
|
|
+ */
|
|
|
+ die('fail');
|
|
|
+ }
|
|
|
+ } catch (Exception $e) {
|
|
|
+
|
|
|
+ * Payment is not successful
|
|
|
+ */
|
|
|
+ die('fail');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function stripeNotify (Request $request) {
|
|
|
Log::info('stripeNotifyData: ' . json_encode($request->input()));
|
|
|
|