|
| 1 | +<?php |
| 2 | +require '../init.php'; |
| 3 | + |
| 4 | +use Request\marketplace\AlipayRegisterRequest; |
| 5 | +use Client\DefaultAlipayClient; |
| 6 | + |
| 7 | +const clientId = ""; |
| 8 | +const merchantPrivateKey = ""; |
| 9 | +const alipayPublicKey = ""; |
| 10 | +const gatewayUrl = ""; |
| 11 | + |
| 12 | +function register() |
| 13 | +{ |
| 14 | + $alipayRegisterRequest = new AlipayRegisterRequest(); |
| 15 | + $alipayRegisterRequest->setRegistrationRequestId('register_' . round(microtime(true) * 1000)); |
| 16 | + |
| 17 | + $settlementInfo = new \Model\SettlementInfo(); |
| 18 | + $settlementInfo->setSettlementCurrency("BRL"); |
| 19 | + $settlementBankAccount = new \Model\SettlementBankAccount(); |
| 20 | + $settlementBankAccount->setBranchCode("1231"); |
| 21 | + $settlementBankAccount->setRoutingNumber("12"); |
| 22 | + $settlementBankAccount->setBankRegion("BR"); |
| 23 | + $settlementBankAccount->setAccountType(\Model\AccountType::CHECKING); |
| 24 | + $settlementBankAccount->setAccountHolderTIN("12345678901"); |
| 25 | + $settlementBankAccount->setAccountHolderName("Timi"); |
| 26 | + $settlementBankAccount->setBankAccountNo("121232141"); |
| 27 | + $settlementBankAccount->setAccountHolderType(\Model\AccountHolderType::ENTERPRISE); |
| 28 | + $settlementInfo->setSettlementBankAccount($settlementBankAccount); |
| 29 | + $alipayRegisterRequest->setSettlementInfos([$settlementInfo]); |
| 30 | + |
| 31 | + |
| 32 | + $merchantInfo = new \Model\MerchantInfo(); |
| 33 | + $merchantInfo-> setLoginId( round( microtime( true) * 1000). "[email protected]"); |
| 34 | + $merchantInfo->setLegalEntityType(\Model\LegalEntityType::COMPANY); |
| 35 | + |
| 36 | + |
| 37 | + $company = new \Model\Company(); |
| 38 | + $company->setLegalName("legalName"); |
| 39 | + $address = new \Model\Address(); |
| 40 | + $address->setRegion("BR"); |
| 41 | + $company->setRegisteredAddress($address); |
| 42 | + $company->setCompanyType(\Model\CompanyType::LTDA); |
| 43 | + $address1 = new \Model\Address(); |
| 44 | + $address1->setRegion("BR"); |
| 45 | + $address1->setAddress1("address1"); |
| 46 | + $company->setOperatingAddress($address1); |
| 47 | + |
| 48 | + $attachment = new \Model\Attachment(); |
| 49 | + $attachment->setAttachmentName("1.jpg"); |
| 50 | + $attachment->setFileKey("test"); |
| 51 | + $attachment->setAttachmentType(\Model\AttachmentType::ARTICLES_OF_ASSOCIATION); |
| 52 | + $attachment1 = new \Model\Attachment(); |
| 53 | + $attachment1->setFileKey("23423tewgusdhghdsiughsud"); |
| 54 | + $attachment1->setAttachmentType(\Model\AttachmentType::ASSOCIATION_ARTICLE); |
| 55 | + $attachment1->setAttachmentName("2.jpg"); |
| 56 | + $company->setAttachments([$attachment]); |
| 57 | + $company->setOperatingAddress($address); |
| 58 | + |
| 59 | + $certificate = new \Model\Certificate(); |
| 60 | + $certificate->setCertificateNo("11321421"); |
| 61 | + $certificate->setCertificateType(\Model\CertificateType::ENTERPRISE_REGISTRATION); |
| 62 | + $company->setCertificates($certificate); |
| 63 | + |
| 64 | + $merchantInfo->setCompany($company); |
| 65 | + $merchantInfo->setReferenceMerchantId(round(microtime(true) * 1000)); |
| 66 | + |
| 67 | + $businessInfo = new \Model\BusinessInfo(); |
| 68 | + $businessInfo->setDoingBusinessAs("businessName_DBA"); |
| 69 | + $webSite = new \Model\WebSite(); |
| 70 | + $webSite->setUrl("www.alipay.com"); |
| 71 | + $businessInfo->setWebsites([$webSite]); |
| 72 | + $merchantInfo->setBusinessInfo($businessInfo); |
| 73 | + |
| 74 | + $entityAssociations = new \Model\EntityAssociations(); |
| 75 | + $individual = new \Model\Individual(); |
| 76 | + $certificate1 = new \Model\Certificate(); |
| 77 | + $certificate1->setCertificateNo("11124321421"); |
| 78 | + $certificate1->setCertificateType(\Model\CertificateType::CPF); |
| 79 | + $individual->setCertificates([$certificate1]); |
| 80 | + $userName = new \Model\UserName(); |
| 81 | + $userName->setFirstName("firstName"); |
| 82 | + $userName->setMiddleName("middleName"); |
| 83 | + $userName->setLastName("lastName"); |
| 84 | + $userName->setFullName("fullName"); |
| 85 | + $individual->setName($userName); |
| 86 | + $individual->setDateOfBirth("1990-01-01"); |
| 87 | + $entityAssociations->setIndividual($individual); |
| 88 | + $entityAssociations->setLegalEntityType(\Model\LegalEntityType::INDIVIDUAL); |
| 89 | + $entityAssociations->setAssociationType(\Model\AssociationType::LEGAL_REPRESENTATIVE); |
| 90 | + |
| 91 | + |
| 92 | + $entityAssociations1 = new \Model\EntityAssociations(); |
| 93 | + $individual1 = new \Model\Individual(); |
| 94 | + $certificate2 = new \Model\Certificate(); |
| 95 | + $certificate2->setFileKeys(["wetrewqratewtewgewgewg"]); |
| 96 | + $certificate2->setCertificateNo("11321421"); |
| 97 | + $certificate2->setCertificateType(\Model\CertificateType::CPF); |
| 98 | + $individual1->setCertificates([$certificate2]); |
| 99 | + $individual1->setName($userName); |
| 100 | + $individual1->setDateOfBirth("1990-01-01"); |
| 101 | + $entityAssociations1->setIndividual($individual1); |
| 102 | + $entityAssociations1->setLegalEntityType(\Model\LegalEntityType::INDIVIDUAL); |
| 103 | + $entityAssociations1->setAssociationType(\Model\AssociationType::UBO); |
| 104 | + |
| 105 | + |
| 106 | + $merchantInfo->setEntityAssociations([$entityAssociations,$entityAssociations1]); |
| 107 | + |
| 108 | + $alipayRegisterRequest->setMerchantInfo($merchantInfo); |
| 109 | + |
| 110 | + $alipayClient = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 111 | + $alipayResponse = $alipayClient->execute($alipayRegisterRequest); |
| 112 | + |
| 113 | + printf($alipayRegisterRequest->getMerchantInfo()->getReferenceMerchantId()); |
| 114 | + echo json_encode($alipayResponse); |
| 115 | + |
| 116 | +} |
| 117 | + |
| 118 | +function update($referenceMerchantId) |
| 119 | +{ |
| 120 | + $alipaySettlementInfoUpdateRequest = new \Request\marketplace\AlipaySettlementInfoUpdateRequest(); |
| 121 | + $alipaySettlementInfoUpdateRequest->setReferenceMerchantId($referenceMerchantId); |
| 122 | + $alipaySettlementInfoUpdateRequest->setUpdateRequestId("update_" . round(microtime(true) * 1000)); |
| 123 | + $alipaySettlementInfoUpdateRequest->setSettlementCurrency("BRL"); |
| 124 | + $settlementBankAccount = new \Model\SettlementBankAccount(); |
| 125 | + $settlementBankAccount->setBranchCode("1231"); |
| 126 | + $settlementBankAccount->setRoutingNumber("12"); |
| 127 | + $settlementBankAccount->setAccountType(\Model\AccountType::CHECKING); |
| 128 | + $settlementBankAccount->setAccountHolderTIN("1213214"); |
| 129 | + $settlementBankAccount->setAccountHolderName("Timi"); |
| 130 | + $settlementBankAccount->setBankAccountNo("121232141"); |
| 131 | + $settlementBankAccount->setAccountHolderType(\Model\AccountHolderType::ENTERPRISE); |
| 132 | + $alipaySettlementInfoUpdateRequest->setSettlementBankAccount($settlementBankAccount); |
| 133 | + |
| 134 | + $alipayClient = new DefaultAlipayClient("https://open-na.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 135 | + $alipayResponse = $alipayClient->execute($alipaySettlementInfoUpdateRequest); |
| 136 | + |
| 137 | + echo json_encode($alipayResponse); |
| 138 | +} |
| 139 | + |
| 140 | +function queryBalance($referenceMerchantId) |
| 141 | +{ |
| 142 | + $alipayInquireBalanceRequest = new \Request\marketplace\AlipayInquireBalanceRequest(); |
| 143 | + $alipayInquireBalanceRequest->setReferenceMerchantId($referenceMerchantId); |
| 144 | + |
| 145 | + $alipayClient = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 146 | + $alipayResponse = $alipayClient->execute($alipayInquireBalanceRequest); |
| 147 | + |
| 148 | + echo json_encode($alipayResponse); |
| 149 | +} |
| 150 | + |
| 151 | +function paymentId($paymentId) |
| 152 | +{ |
| 153 | + $alipaySettleRequest = new \Request\marketplace\AlipaySettleRequest(); |
| 154 | + $alipaySettleRequest->setPaymentId($paymentId); |
| 155 | + $alipaySettleRequest->setSettlementRequestId("settle_" . round(microtime(true) * 1000)); |
| 156 | + $settlementDetail = new \Model\SettlementDetail(); |
| 157 | + $settlementDetail->setSettleTo(\Model\SettleToType::SELLER); |
| 158 | + $amount = new \Model\Amount(); |
| 159 | + $amount->setValue("90"); |
| 160 | + $amount->setCurrency("BRL"); |
| 161 | + $settlementDetail->setSettlementAmount($amount); |
| 162 | + |
| 163 | + $settlementDetail1 = new \Model\SettlementDetail(); |
| 164 | + $settlementDetail1->setSettleTo(\Model\SettleToType::MARKETPLACE); |
| 165 | + $amount1 = new \Model\Amount(); |
| 166 | + $amount1->setValue("10"); |
| 167 | + $amount1->setCurrency("BRL"); |
| 168 | + $settlementDetail1->setSettlementAmount($amount); |
| 169 | + |
| 170 | + $alipaySettleRequest->setSettlementDetails([$settlementDetail, $settlementDetail1]); |
| 171 | + |
| 172 | + |
| 173 | + $alipayClient = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 174 | + $alipayResponse = $alipayClient->execute($alipaySettleRequest); |
| 175 | + |
| 176 | + echo json_encode($alipayResponse); |
| 177 | + |
| 178 | +} |
| 179 | + |
| 180 | + |
| 181 | +function createPayout() |
| 182 | +{ |
| 183 | + $alipayCreatePayoutRequest = new \Request\marketplace\AlipayCreatePayoutRequest(); |
| 184 | + $alipayCreatePayoutRequest->setTransferRequestId("transfer_" . round(microtime(true) * 1000)); |
| 185 | + |
| 186 | + $transferFromDetail = new \Model\TransferFromDetail(); |
| 187 | + $paymentMethod = new \Model\PaymentMethod(); |
| 188 | + $paymentMethod->setPaymentMethodId(round(microtime(true) * 1000)); |
| 189 | + $paymentMethod->setPaymentMethodType(\Model\WalletPaymentMethodType::BALANCE_ACCOUNT); |
| 190 | + $transferFromDetail->setTransferFromMethod($paymentMethod); |
| 191 | + $alipayCreatePayoutRequest->setTransferFromDetail($transferFromDetail); |
| 192 | + |
| 193 | + $transferToDetail = new \Model\TransferToDetail(); |
| 194 | + $paymentMethod1 = new \Model\PaymentMethod(); |
| 195 | + $paymentMethod1->setPaymentMethodId(round(microtime(true) * 1000)); |
| 196 | + $paymentMethod1->setPaymentMethodType(\Model\WalletPaymentMethodType::SETTLEMENT_CARD); |
| 197 | + $transferToDetail->setTransferToMethod($paymentMethod1); |
| 198 | + $transferToDetail->setTransferToCurrency("BRL"); |
| 199 | + $transferToDetail->setPurposeCode("GSD"); |
| 200 | + $transferToDetail->setTransferNotifyUrl("www.alipay.com"); |
| 201 | + $alipayCreatePayoutRequest->setTransferToDetail($transferToDetail); |
| 202 | + |
| 203 | + $alipayClient = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 204 | + $alipayResponse = $alipayClient->execute($alipayCreatePayoutRequest); |
| 205 | + |
| 206 | + echo json_encode($alipayResponse); |
| 207 | +} |
| 208 | + |
| 209 | +function createTransfer() |
| 210 | +{ |
| 211 | + $alipayCreateTransferRequest = new \Request\marketplace\AlipayCreateTransferRequest(); |
| 212 | + $alipayCreateTransferRequest->setTransferRequestId("transfer_" . round(microtime(true) * 1000)); |
| 213 | + |
| 214 | + $transferFromDetail = new \Model\TransferFromDetail(); |
| 215 | + $paymentMethod = new \Model\PaymentMethod(); |
| 216 | + $paymentMethod->setPaymentMethodId(round(microtime(true) * 1000)); |
| 217 | + $paymentMethod->setPaymentMethodType(\Model\WalletPaymentMethodType::BALANCE_ACCOUNT); |
| 218 | + $amount = new \Model\Amount(); |
| 219 | + $amount->setValue("100"); |
| 220 | + $amount->setCurrency("BRL"); |
| 221 | + $transferFromDetail->setTransferFromAmount($amount); |
| 222 | + $transferFromDetail->setTransferFromMethod($paymentMethod); |
| 223 | + $alipayCreateTransferRequest->setTransferFromDetail($transferFromDetail); |
| 224 | + |
| 225 | + $transferToDetail = new \Model\TransferToDetail(); |
| 226 | + $paymentMethod1 = new \Model\PaymentMethod(); |
| 227 | + $paymentMethod1->setPaymentMethodId(round(microtime(true) * 1000)); |
| 228 | + $paymentMethod1->setPaymentMethodType(\Model\WalletPaymentMethodType::BALANCE_ACCOUNT); |
| 229 | + $transferToDetail->setTransferToMethod($paymentMethod1); |
| 230 | + $transferToDetail->setTransferToCurrency("BRL"); |
| 231 | + $transferToDetail->setPurposeCode("GSD"); |
| 232 | + $transferToDetail->setTransferNotifyUrl("www.alipay.com"); |
| 233 | + $alipayCreateTransferRequest->setTransferToDetail($transferToDetail); |
| 234 | + |
| 235 | + $alipayClient = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientId); |
| 236 | + $alipayResponse = $alipayClient->execute($alipayCreateTransferRequest); |
| 237 | + |
| 238 | + echo json_encode($alipayResponse); |
| 239 | +} |
| 240 | + |
| 241 | +//register(); |
| 242 | +update("outmid_wangzunjiao_wzj_20240929_100432_437"); |
| 243 | + |
0 commit comments