AlipayLumenServiceProvider.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\common\components\alipay;
  3. use Illuminate\Support\ServiceProvider;
  4. use Setting;
  5. class AlipayLumenServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * boot process
  9. */
  10. public function boot()
  11. {
  12. }
  13. /**
  14. * Register the service provider.
  15. *
  16. * @return void
  17. */
  18. public function register()
  19. {
  20. $this->app->bind('alipay.mobile', function ($app)
  21. {
  22. $alipay = new Mobile\SdkPayment();
  23. $alipay->setPartner(Setting::get('alipay.partner_id'))
  24. ->setSellerId(Setting::get('alipay.seller_id'))
  25. ->setSignType(Setting::get('alipay-mobile.sign_type'))
  26. ->setPrivateKeyPath(Setting::get('alipay-mobile.private_key_path'))
  27. ->setPublicKeyPath(Setting::get('alipay-mobile.public_key_path'))
  28. ->setNotifyUrl(Setting::get('alipay-mobile.notify_url'));
  29. return $alipay;
  30. });
  31. $this->app->bind('alipay.web', function ($app)
  32. {
  33. $alipay = new Web\SdkPayment();
  34. $alipay->setPartner(Setting::get('alipay.partner_id'))
  35. ->setSellerId(Setting::get('alipay.seller_id'))
  36. ->setKey(Setting::get('alipay-web.key'))
  37. ->setSignType(Setting::get('alipay-web.sign_type'))
  38. ->setNotifyUrl(Setting::get('alipay-web.notify_url'))
  39. ->setReturnUrl(Setting::get('alipay-web.return_url'))
  40. ->setExterInvokeIp($app->request->getClientIp());
  41. return $alipay;
  42. });
  43. $this->app->bind('alipay.wap', function ($app)
  44. {
  45. $alipay = new Wap\SdkPayment();
  46. $alipay->setPartner(Setting::get('alipay.partner_id'))
  47. ->setSellerId(Setting::get('alipay.seller_id'))
  48. ->setKey(Setting::get('alipay-web.key'))
  49. ->setSignType(Setting::get('alipay-web.sign_type'))
  50. ->setNotifyUrl(Setting::get('alipay-web.notify_url'))
  51. ->setReturnUrl(Setting::get('alipay-web.return_url'))
  52. ->setExterInvokeIp($app->request->getClientIp());
  53. return $alipay;
  54. });
  55. }
  56. /**
  57. * Get the services provided by the provider.
  58. *
  59. * @return array
  60. */
  61. public function provides()
  62. {
  63. return [
  64. 'alipay.mobile',
  65. 'alipay.web',
  66. 'alipay.wap',
  67. ];
  68. }
  69. }