PaytmController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Controllers\Payment;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\CheckoutController;
  5. use App\Http\Controllers\CustomerPackageController;
  6. use App\Http\Controllers\SellerPackageController;
  7. use App\Http\Controllers\SellerSpreadPackageController;
  8. use App\Http\Controllers\WalletController;
  9. use App\Models\SellerSpreadPackage;
  10. use Illuminate\Http\Request;
  11. use App\Models\CombinedOrder;
  12. use App\Models\Recharge;
  13. use App\Models\User;
  14. use App\Models\Wallet;
  15. use App\Models\CustomerPackage;
  16. use App\Models\SellerPackage;
  17. use PayPalCheckoutSdk\Core\PayPalHttpClient;
  18. use PayPalCheckoutSdk\Core\SandboxEnvironment;
  19. use PayPalCheckoutSdk\Core\ProductionEnvironment;
  20. use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
  21. use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
  22. use Session;
  23. use Cache;
  24. use Redirect;
  25. class PaytmController extends Controller
  26. {
  27. public function callback(Request $request){
  28. die;
  29. //dump(Cache::get('233223432'));die;
  30. $data=$request->toArray();
  31. Cache::put('233223432', $data);
  32. //验证签名
  33. $key='63110f813b2619cf47f83c40b36e7314';
  34. $sign=md5($data['merchant_no'].$data['params'].$data['sign_type'].$data['timestamp'].$key);
  35. if($sign==$data['sign']){ //验签成功
  36. $li=json_decode($data['params'],true);
  37. if($li['status']==1 && $li['success_time']>0){ //支付状态为1,且支付时间存在
  38. $review=Recharge::where('merchant_ref', $li['merchant_ref'])->get()[0];//查询订单
  39. if($review->status!=1){
  40. //修改订单状态
  41. $review->fee = $li['fee'];
  42. $review->daozhang_money = $li['pay_amount'];
  43. $review->system_ref = $li['system_ref'];
  44. $review->paytime = $li['paytime'];
  45. $review->updatetime = time();
  46. $review->status = 1;
  47. $review->save();
  48. $this->rujinmoney($review['userid'],$li['pay_amount'],$li['merchant_ref']);//给用户入金
  49. }
  50. }
  51. }
  52. return 'SUCCESS';
  53. }
  54. public function rujinmoney($userid,$number,$orderid){
  55. $user=User::find($userid);
  56. $user->balance=$user->balance+$number;
  57. $user->save();
  58. //记录钱包信息
  59. $wallet = new Wallet;
  60. $wallet->user_id = $userid;
  61. $wallet->amount = $number;
  62. $wallet->payment_method = '信用卡支付';
  63. $wallet->type = 1;
  64. $wallet->save();
  65. }
  66. }