MMSService.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. declare(strict_types=1);
  3. namespace SixShop\Lakala\Service;
  4. use SixShop\Lakala\Config;
  5. use SixShop\Lakala\Enum\UploadFileType;
  6. use SixShop\Lakala\OpenAPISDK\V2\Api\V2LakalaApi;
  7. use SixShop\Lakala\OpenAPISDK\V2\Model\V2ModelRequest;
  8. class MMSService
  9. {
  10. private V2LakalaApi $v2LakalaApi;
  11. public function __construct(Config $config)
  12. {
  13. $this->v2LakalaApi = new V2LakalaApi($config->getV2Config());
  14. }
  15. /**
  16. * 卡BIN查询
  17. *
  18. * @param string $orderNo 订单编号(便于后续跟踪排查问题及核对报文) 14位年月日时(24小时制)分秒+8位的随机数(不重复)如:2021020112000012345678
  19. * @param string $cardNo 银行卡号
  20. * @param string $orgCode 机构代码
  21. * @param string $version 接口版本号 默认1.0
  22. * @return void
  23. */
  24. public function cardBin(string $orderNo, string $cardNo,string $orgCode = '1', string $version = '1.0')
  25. {
  26. $request = new V2ModelRequest();
  27. $request->setReqData([
  28. 'version' => $version,
  29. 'orderNo' => $orderNo,
  30. 'orgCode' => $orgCode,
  31. 'cardNo' => $cardNo,
  32. ]);
  33. $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/cardBin', $request);
  34. if ($response->getRespData()) {
  35. print_r($response->getRespData());
  36. } else {
  37. print_r($response);
  38. }
  39. echo $response->getRetCode();
  40. # 响应头信息
  41. print_r($response->getHeaders());
  42. # 响应原文
  43. echo $response->getOriginalText();
  44. }
  45. public function uploadFile(string $orderNo, UploadFileType $attType, string $attExtName, string $data, string $orgCode = '1', string $version = '1.0')
  46. {
  47. $request = new V2ModelRequest();
  48. $attContext = base64_encode($data);
  49. $request->setReqData([
  50. 'attContext' => $attContext,
  51. 'attType' => $attType->value,
  52. 'attExtName' => $attExtName,
  53. 'orderNo' => $orderNo,
  54. 'orgCode' => $orgCode,
  55. 'version' => $version,
  56. ]);
  57. $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/uploadFile', $request);
  58. print_r($response);
  59. echo $response->getRetCode();
  60. # 响应头信息
  61. print_r($response->getHeaders());
  62. # 响应原文
  63. echo $response->getOriginalText();
  64. }
  65. }