dominservice / payu_marketplace
PAYU Marketplace 库
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-09-20 12:16:38 UTC
README
此库基于 "openpay/openpay",增加了市场卖家验证元素,以及市场服务本身。
该库目前正在建设中,请稍后再查看,它很快就会准备好。
记住!!
当通过 PayU 注册市场账户时,必须发送验证通知的 URL。此地址不能在面板中输入或通过 API 发送。PayU 员工必须手动输入此地址。
为了最大限度地缩短注册账户的时间,请准备公司文件、有效的电子邮件地址以及您的公司银行账户号码。
根据您的公司法律形式,准备以下文件。执行它们的扫描或拍照,并将它们保存到计算机上。在注册账户的第 5 步中,您将被要求上传包含文件副本的文件。注册将需要
- 个体工商户:公司所有者身份证扫描件,
- 合伙企业:NIP 和 REGON(如果不在 KRS 中可见),合伙企业协议扫描件,所有合伙人的身份证扫描件,
- 股份有限公司、有限责任公司、公开公司、合伙公司:NIP 和 REGON(如果不在 KRS 中可见),签署协议的人的身份证扫描件(在 KRS 中作为代表登记),
- 基金会或协会:NIP 和 REGON(如果不在 KRS 中可见),对于基金会,状态证明文件的扫描件,代表公司的人的身份证扫描件(在 KRS 中作为代表登记),
- 公共机构:NIP 和 REGON,代表公司的人的身份证扫描件,证明创建该实体的文件的扫描件。
PAYU Marketplace PHP 库提供对 REST API 2.1 的集成访问。
依赖项
文档
安装
将依赖项添加到您的项目中
composer require dominservice/payu_marketplace
使用方法
验证新卖家
验证类型
- PAYOUT_ACCOUNT_DATA - 由市场方初始化。此类型的验证应包含付款账户和卖家的数据(子商户)。如果此验证在 PayU 中初始化卖家,则需要卖家数据。如果是仅账户更新,则只需要账户数据。
- FULL - 需要卖家提供 AML4 和付款所有数据的验证,通常由市场方初始化。
- UPDATE - 通常由商家方初始化的验证,当卖家(子商户)更新其数据(例如公司地址)时。如果商家更改关键数据(例如税务编号、法律类型),则必须使用 FULL 验证。
- REVERIFICATION - 通常由 PayU 初始化的验证,当我们需要商家更新其数据(例如不再有效的文件)时。
- PERSONAL_ID_TAX_ID_CHANGE - 由市场方初始化。这允许更改个人客户的PERSONAL_ID或法人实体的TAX_IDs。一旦开始KYC验证流程,当前账户和支付将被锁定,直到验证完成。如果流程中断(例如,公司无法自行验证),PayU将恢复旧商户账户,从而解锁该账户上的支付。
您可以使用 \Dominservice\PayuMarketplace\Api\PayU 类提供正确的验证类型
\Dominservice\PayuMarketplace\Api\PayU::TYPE_PAYOUT_ACCOUNT_DATA; \Dominservice\PayuMarketplace\Api\PayU::TYPE_FULL; \Dominservice\PayuMarketplace\Api\PayU::TYPE_UPDATE; \Dominservice\PayuMarketplace\Api\PayU::TYPE_REVERIFICATION; \Dominservice\PayuMarketplace\Api\PayU::TYPE_PERSONAL_ID_TAX_ID_CHANGE;
默认类型是 FULL,
入门指南
如果您正在使用Composer,请使用自动加载功能
include "vendor/autoload.php"; use Dominservice\PayuMarketplace\Api\Configuration;
配置
重要:SDK仅与'REST API'(结账)销售点(POS)一起使用。如果您还没有PayU商户账户,请在生产环境中注册或在沙盒环境中注册
从商户面板(由openpayu/openpayu使用)的"配置密钥"示例
要配置OpenPayU环境,您必须在config.php文件中提供一系列必填数据。
生产环境配置
//set Production Environment Configuration::setEnvironment('secure'); //set POS ID and Second MD5 Key (from merchant admin panel) Configuration::setMerchantPosId('145227'); Configuration::setSignatureKey('13a980d4f851f3d9a1cfc792fb1f5e50'); //set Oauth Client Id and Oauth Client Secret (from merchant admin panel) Configuration::setOauthClientId('145227'); Configuration::setOauthClientSecret('12f071174cb7eb79d4aac5bc2f07563f');
沙盒环境配置
//set Sandbox Environment Configuration::setEnvironment('sandbox'); //set POS ID and Second MD5 Key (from merchant admin panel) Configuration::setMerchantPosId('300046'); Configuration::setSignatureKey('0c017495773278c50c7b35434017b2ca'); //set Oauth Client Id and Oauth Client Secret (from merchant admin panel) Configuration::setOauthClientId('300046'); Configuration::setOauthClientSecret('c8d4b7ac61758704f38ed5564d8c0ae0');
设置缓存目录
use Dominservice\PayuMarketplace\Api\Oauth\OauthCacheFile; if (!file_exists(__DIR__ . '/payu_cache')) { @mkdir(__DIR__ . '/payu_cache', 0777); } Configuration::setOauthTokenCache(new OauthCacheFile(__DIR__ . '/payu_cache'));
方法是通过在参数名前添加"set"或"get"来构建的,但有少数例外
例如,如果我们想添加"accountNumberFromBank"参数,我们必须提供以下方法
(new Seller->setAccountNumberFromBank('111111111111111111111111111'))
如果我们想获取该字段的值,我们必须这样做
(new Seller->grtAccountNumberFromBank())
否则,我们添加地址以及statementData->address
// (new Seller())->setAddress([country ISO code], [street], [zipcode], [city], [is account cloned]) (new Seller())->setAddress('PL', 'Zatylna 23/3', '00-001', 'Testowo', true|false) // (new Seller())->setStatementAddress([country ISO code], [street], [zipcode], [city]) (new Seller())->setStatementAddress('PL', 'Zatylna 23/3', '00-001', 'Testowo')
但如果我们想获取其中一个字段的值,我们都在两种情况下使用getAddress(),因为上述方法用于不同的CURL查询。
(new Seller())->getAddress()
对于'hasDocument'、'verified'、'foreign'字段,值必须是true或false,在immy中,如果我们输入任何内容,值将是true,如果我们不输入任何内容,值将是false。
对于'statementData'表中其他字段的其余部分,我们给出字段名作为值的示例。
测试
use Dominservice\PayuMarketplace\Api\Oauth\OauthGrantType; use Dominservice\PayuMarketplace\Api\PayU; use Dominservice\PayuMarketplace\Exception\ConfigException; use Dominservice\PayuMarketplace\Exception\PayuMarketplaceException; use Dominservice\PayuMarketplace\Exception\VerificationException; use Dominservice\PayuMarketplace\Marketplace; use Dominservice\PayuMarketplace\Api\Verification; use Dominservice\PayuMarketplace\Seller; (...) $sellerId = 'dso_seller_test'; $verificationId = null; $verificationStatus = null; $sellerInfo = (new Seller())->initializingVerification($sellerId); $response = $sellerInfo->getResponse(); if (!empty($response->verificationId)) { $verificationId = $response->verificationId; } if (!empty($response->status)) { $verificationStatus = $response->status; } if ($verificationId && $verificationStatus === 'WAITING_FOR_DATA') { $sellerVerification = (new Seller()) ->setAddress('PL', 'Zatylna 23/3', '00-001', 'Testowo') ->setVerificationId($verificationId) ->setSellerId($sellerId) ->setCompanyName('DSO-IT') ->setTaxId(6642146205) ->setLegalForm(PayU::LEGAL_FORM_SOLE_TRADER) // "legalForm value please place PRIVATE_PERSON or SOLE_TRADER." ->setGusCode('099') // https://stat.gov.pl/metainformacje/slownik-pojec/pojecia-stosowane-w-statystyce-publicznej/97,pojecie.html ->setRegistryNumber(123456789) // Polish REGON ->setRegistrationDate('2021-04-10') ->setEmail('biuro@dso.biz.pl') ->setPhone('555555555') ->setSellerData(); if (!$sellerVerification->getError()) { $associateId = $this->uuid(); $sellerAssociates = (new Seller()) ->setVerificationId($verificationId) ->setAssociateId($associateId) ->setAssociateType('REPRESENTATIVE') ->setAssociateName('Tom') ->setAssociateSurname('Smith') ->setAssociateCitizenship('PL') ->setAssociateIdentityNumber('02052145584') ->setAssociateBirthDate('2002-01-02') ->setSellerAssociates(); // $filename = $_FILES['file']['name']; // $filePath = $_FILES['file']['tmp_name']; // $filesize = $_FILES['file']['size']; $filename = 'przud'; $filePath = __DIR__ . '/test_dowód_przud.jpg'); $filesize = strlen(file_get_contents($filePath)); $filename2 = 'tył'; $filePath2 = __DIR__ . '/test_dowód_tył.jpg'); $filesize2 = strlen(file_get_contents($filePath2)); if (function_exists('curl_file_create')) { // php 5.5+ $cFile = curl_file_create($filePath); $cFile2 = curl_file_create($filePath2); } else { $cFile = '@' . realpath($filePath); $cFile2 = '@' . realpath($filePath2); } $sellerFiles = []; $sellerFile = (new Seller()) ->setVerificationId($verificationId) ->setSellerFile($filename, $cFile, $filesize); } if ($fileResponse = $sellerFile->getResponse()) { $sellerFiles[$filename] = $fileResponse->fileId; } $sellerFile = (new Seller()) ->setVerificationId($verificationId) ->setSellerFile($filename2, $cFile2, $filesize); } if ($fileResponse = $sellerFile->getResponse()) { $sellerFiles[$filename2] = $fileResponse->fileId; } if (!empty($sellerFiles)) { $sellerDocumentId = $this->uuid(); $sellerDocument = (new Seller()) ->setVerificationId($verificationId) ->setDocumentId($sellerDocumentId) ->setDocumentType('REGISTRY_DOCUMENT') ->setFiles($sellerFiles[$filename]) ->setFiles($sellerFiles[$filename2]) ->setSellerDocuments(); $associateDocumentId = $this->uuid(); $associateDocument = (new Seller()) ->setVerificationId($verificationId) ->setAssociateId($associateId) ->setDocumentId($associateDocumentId) ->setDocumentType('RESIDENCE_PERMIT') ->setDocumentNumber('QWE 111111') ->setFiles($sellerFiles[$filename]) ->setFiles($sellerFiles[$filename2]) ->setIssueDate('2022-01-02') ->setExpireDate('2032-01-02') ->setAssociateDocuments(); } } // $order = (new Marketplace()) // ->setNotifyUrl(route('payu_test_notify')) // ->setCustomer( // 'biuro@dso.biz.pl', // '555555555', // 'Tester', // 'Oblatywacz', // 'pl' // ) // ->setSellerFee($sellerId, 10) // ->setProduct($sellerId, 'Produkt testowy', 23, 5, date('Y-m-d')) // ->setShippingMethods($sellerId, 'PL', 12, 'Przewożnik A') // ->setCurrency('PLN') // ->setDescription('bla bla blaS') // ->createOrder(time());