├── CHANGELOG.md ├── LICENSE ├── MangoPay ├── AVSResult.php ├── Address.php ├── ApiBankAccounts.php ├── ApiBankingAliases.php ├── ApiCardPreAuthorizations.php ├── ApiCardRegistrations.php ├── ApiCards.php ├── ApiClients.php ├── ApiConversions.php ├── ApiDeposits.php ├── ApiDisputeDocuments.php ├── ApiDisputes.php ├── ApiEvents.php ├── ApiHooks.php ├── ApiIdentityVerification.php ├── ApiKycDocuments.php ├── ApiMandates.php ├── ApiPayIns.php ├── ApiPayOuts.php ├── ApiRecipients.php ├── ApiRefunds.php ├── ApiRegulatory.php ├── ApiReports.php ├── ApiRepudiations.php ├── ApiResponses.php ├── ApiTransfers.php ├── ApiUboDeclarations.php ├── ApiUsers.php ├── ApiVirtualAccounts.php ├── ApiWallets.php ├── Autoloader.php ├── BankAccount.php ├── BankAccountDetails.php ├── BankAccountDetailsCA.php ├── BankAccountDetailsGB.php ├── BankAccountDetailsIBAN.php ├── BankAccountDetailsOTHER.php ├── BankAccountDetailsUS.php ├── BankingAlias.php ├── BankingAliasIBAN.php ├── BankingAliasOTHER.php ├── BankingAliasType.php ├── Billing.php ├── Birthplace.php ├── BrowserInfo.php ├── BusinessRecipient.php ├── BusinessRecipientPropertySchema.php ├── BusinessType.php ├── CancelDeposit.php ├── Card.php ├── CardInfo.php ├── CardPreAuthorization.php ├── CardPreAuthorizationPaymentStatus.php ├── CardPreAuthorizationStatus.php ├── CardRegistration.php ├── CardRegistrationStatus.php ├── CardValidation.php ├── CardValidationStatus.php ├── CardValidity.php ├── Check.php ├── CheckData.php ├── Client.php ├── ClientLogoUpload.php ├── CompanyNumber.php ├── CompanyNumberDetails.php ├── Conversion.php ├── ConversionQuote.php ├── ConversionRate.php ├── CountryAuthorization.php ├── CountryAuthorizationData.php ├── CreateCardPreAuthorizedDepositPayIn.php ├── CreateClientWalletsInstantConversion.php ├── CreateClientWalletsQuotedConversion.php ├── CreateDeposit.php ├── CreateInstantConversion.php ├── CreateQuotedConversion.php ├── CurrencyIso.php ├── DebitedBankAccount.php ├── DeclaredUbo.php ├── DeclaredUboStatus.php ├── Deposit.php ├── DepositStatus.php ├── Dispute.php ├── DisputeDocument.php ├── DisputeDocumentPage.php ├── DisputeDocumentStatus.php ├── DisputeDocumentType.php ├── DisputeReason.php ├── DisputeReasonType.php ├── DisputeStatus.php ├── DisputeType.php ├── DocumentPageConsult.php ├── EMoney.php ├── Event.php ├── EventType.php ├── FallbackReason.php ├── FilterBankAccounts.php ├── FilterBase.php ├── FilterCards.php ├── FilterDisputeDocuments.php ├── FilterDisputes.php ├── FilterEvents.php ├── FilterKycDocuments.php ├── FilterPreAuthorizations.php ├── FilterRecipients.php ├── FilterRefunds.php ├── FilterReports.php ├── FilterTransactions.php ├── FilterWallets.php ├── FundsType.php ├── Hook.php ├── HookStatus.php ├── HookValidity.php ├── IdentityVerification.php ├── IndividualRecipient.php ├── IndividualRecipientPropertySchema.php ├── InstantPayout.php ├── InternationalAccount.php ├── InternationalAccountDetails.php ├── KeyValueArray.php ├── KycDocument.php ├── KycDocumentRefusedReasonType.php ├── KycDocumentStatus.php ├── KycDocumentType.php ├── KycLevel.php ├── KycPage.php ├── LegalPersonType.php ├── LegalRepresentative.php ├── Libraries │ ├── ApiBase.php │ ├── ApiOAuth.php │ ├── AuthenticationHelper.php │ ├── AuthorizationTokenManager.php │ ├── Configuration.php │ ├── DefaultStorageStrategy.php │ ├── Document.php │ ├── Dto.php │ ├── EntityBase.php │ ├── Error.php │ ├── Exception.php │ ├── HttpBase.php │ ├── HttpCurl.php │ ├── HttpResponse.php │ ├── IStorageStrategy.php │ ├── Logs.php │ ├── OAuthToken.php │ ├── RequestType.php │ ├── ResponseException.php │ ├── RestTool.php │ ├── Upload.php │ └── UrlTool.php ├── LineItem.php ├── LocalAccount.php ├── LocalAccountDetails.php ├── LocalAccountDetailsBankingAlias.php ├── Mandate.php ├── MandateStatus.php ├── MangoPayApi.php ├── Money.php ├── NaturalUserCapacity.php ├── Pagination.php ├── PayIn.php ├── PayInCardTemplateURLOptions.php ├── PayInExecutionDetails.php ├── PayInExecutionDetailsDirect.php ├── PayInExecutionDetailsExternalInstruction.php ├── PayInExecutionDetailsWeb.php ├── PayInExecutionType.php ├── PayInPaymentDetails.php ├── PayInPaymentDetailsApplePay.php ├── PayInPaymentDetailsBancontact.php ├── PayInPaymentDetailsBankWire.php ├── PayInPaymentDetailsBlik.php ├── PayInPaymentDetailsCard.php ├── PayInPaymentDetailsDirectDebit.php ├── PayInPaymentDetailsDirectDebitDirect.php ├── PayInPaymentDetailsGiropay.php ├── PayInPaymentDetailsGooglePay.php ├── PayInPaymentDetailsIdeal.php ├── PayInPaymentDetailsKlarna.php ├── PayInPaymentDetailsMbway.php ├── PayInPaymentDetailsMultibanco.php ├── PayInPaymentDetailsPayByBank.php ├── PayInPaymentDetailsPayconiq.php ├── PayInPaymentDetailsPaypal.php ├── PayInPaymentDetailsPreAuthorized.php ├── PayInPaymentDetailsSatispay.php ├── PayInPaymentDetailsSwish.php ├── PayInPaymentDetailsTwint.php ├── PayInPaymentType.php ├── PayInRecurring.php ├── PayInRecurringRegistration.php ├── PayInRecurringRegistrationGet.php ├── PayInRecurringRegistrationRequestResponse.php ├── PayInRecurringRegistrationUpdate.php ├── PayInStatus.php ├── PayInTemplateURLOptions.php ├── PayInWebExtendedView.php ├── PayOut.php ├── PayOutEligibilityRequest.php ├── PayOutEligibilityResponse.php ├── PayOutPaymentDetails.php ├── PayOutPaymentDetailsBankWire.php ├── PayOutPaymentRef.php ├── PayOutPaymentType.php ├── PayOutStatus.php ├── PayPalWebTracking.php ├── PayinsLinked.php ├── PaymentData.php ├── PaymentMethodMetadata.php ├── PayoutMethods.php ├── PendingUserAction.php ├── PersonType.php ├── PlatformCategorization.php ├── RateLimit.php ├── Recipient.php ├── RecipientAddressPropertySchema.php ├── RecipientPropertySchema.php ├── RecipientSchema.php ├── RecurringPayInCIT.php ├── RecurringPayInCurrentState.php ├── RecurringPayInMIT.php ├── RecurringPayPalPayInCIT.php ├── RecurringPayPalPayInMIT.php ├── Refund.php ├── RefundReasonDetails.php ├── RefundStatus.php ├── ReportRequest.php ├── ReportStatus.php ├── ReportType.php ├── Repudiation.php ├── Response.php ├── ScopeBlocked.php ├── Sector.php ├── SecurityInfo.php ├── SettlementTransfer.php ├── Shipping.php ├── ShippingAddress.php ├── ShippingPreference.php ├── SortDirection.php ├── Sorting.php ├── Transaction.php ├── TransactionNature.php ├── TransactionStatus.php ├── TransactionType.php ├── Transfer.php ├── Ubo.php ├── UboDeclaration.php ├── UboDeclarationRefusedOrIncompleteReasonType.php ├── UboDeclarationRefusedReasonType.php ├── UboDeclarationStatus.php ├── UboRefusedReasonType.php ├── UpdateDeposit.php ├── User.php ├── UserBlockStatus.php ├── UserCategory.php ├── UserEnrollmentResult.php ├── UserLegal.php ├── UserLegalSca.php ├── UserNatural.php ├── UserNaturalSca.php ├── VirtualAccount.php ├── VirtualAccountAddress.php ├── VirtualAccountAvailabilities.php ├── VirtualAccountAvailability.php ├── VirtualAccountCapabilities.php ├── VirtualAccountOwner.php ├── VirtualAccountPurpose.php ├── VirtualAccountStatus.php └── Wallet.php ├── README.md ├── composer.json └── tests ├── Cases ├── BankAccountsTest.php ├── BankingAliasTest.php ├── Base.php ├── CardPreAuthorizationsTest.php ├── CardRegistrationsTest.php ├── CardsTest.php ├── ClientTest.php ├── ConfigurationTest.php ├── Constants.php ├── ConversionsTest.php ├── DepositTest.php ├── DisputesTest.php ├── ErrorTests.php ├── EventsTest.php ├── HooksTest.php ├── IdempotencyTest.php ├── IdentityVerificationTest.php ├── KycDocumentsTest.php ├── MandatesTest.php ├── PayInsTest.php ├── PayOutsTest.php ├── RateLimitTest.php ├── RecipientsTest.php ├── RefundsTest.php ├── RegulatoryTest.php ├── ReportsTest.php ├── TokensTest.php ├── TransfersTest.php ├── UboDeclarationsTest.php ├── UsersTest.php ├── VirtualAccountsTest.php └── WalletsTest.php ├── Mocks └── MockStorageStrategy.php └── TestKycPageFile.png /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Mangopay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /MangoPay/AVSResult.php: -------------------------------------------------------------------------------- 1 | IsEmpty($this->AddressLine1) 49 | && $this->IsEmpty($this->AddressLine2) 50 | && $this->IsEmpty($this->City) 51 | && $this->IsEmpty($this->Region) 52 | && $this->IsEmpty($this->PostalCode) 53 | && $this->IsEmpty($this->Country); 54 | } 55 | 56 | private function IsEmpty($value) 57 | { 58 | return is_null($value) || empty($value); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MangoPay/ApiBankAccounts.php: -------------------------------------------------------------------------------- 1 | GetList('transactions_get_for_bank_account', $pagination, '\MangoPay\Transaction', $bankAccountId, $filter, $sorting); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MangoPay/ApiCardPreAuthorizations.php: -------------------------------------------------------------------------------- 1 | CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization', null, null, $idempotencyKey); 18 | } 19 | 20 | /** 21 | * Get pre-authorization object 22 | * @param string $cardPreAuthorizationId PreAuthorization identifier 23 | * @return \MangoPay\CardPreAuthorization Card registration object returned from API 24 | */ 25 | public function Get($cardPreAuthorizationId) 26 | { 27 | return $this->GetObject('preauthorization_get', '\MangoPay\CardPreAuthorization', $cardPreAuthorizationId); 28 | } 29 | 30 | /** 31 | * Update pre-authorization object 32 | * @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to save 33 | * @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API 34 | */ 35 | public function Update($cardPreAuthorization) 36 | { 37 | return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization'); 38 | } 39 | 40 | public function GetTransactions($cardPreAuthorizationId, & $pagination = null, $filter = null, $sorting = null) 41 | { 42 | return $this->GetList('preauthorization_transactions_get', $pagination, '\MangoPay\Transaction', $cardPreAuthorizationId, $filter, $sorting); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MangoPay/ApiCardRegistrations.php: -------------------------------------------------------------------------------- 1 | CreateObject('cardregistration_create', $cardRegistration, '\MangoPay\CardRegistration', null, null, $idempotencyKey); 18 | } 19 | 20 | /** 21 | * Get card registration 22 | * @param string $cardRegistrationId Card Registration identifier 23 | * @return \MangoPay\CardRegistration Card registration object returned from API 24 | */ 25 | public function Get($cardRegistrationId) 26 | { 27 | return $this->GetObject('cardregistration_get', '\MangoPay\CardRegistration', $cardRegistrationId); 28 | } 29 | 30 | /** 31 | * Update card registration 32 | * @param \MangoPay\CardRegistration $cardRegistration Card registration object to save 33 | * @return \MangoPay\CardRegistration Card registration object returned from API 34 | */ 35 | public function Update($cardRegistration) 36 | { 37 | return $this->SaveObject('cardregistration_save', $cardRegistration, '\MangoPay\CardRegistration'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MangoPay/ApiDisputeDocuments.php: -------------------------------------------------------------------------------- 1 | GetObject('disputes_document_get', 'MangoPay\DisputeDocument', $documentId); 23 | } 24 | 25 | /** 26 | * Gets dispute's documents for client 27 | * @param \MangoPay\Pagination $pagination Pagination object 28 | * @param \MangoPay\Sorting $sorting Object to sorting data 29 | * @param \MangoPay\FilterKycDocuments $filter Filtering object 30 | * @return \MangoPay\DisputeDocument[] List of dispute documents returned from API 31 | */ 32 | public function GetAll(& $pagination = null, $sorting = null, $filter = null) 33 | { 34 | return $this->GetList('disputes_document_all', $pagination, 'MangoPay\DisputeDocument', null, $filter, $sorting); 35 | } 36 | 37 | /** 38 | * Creates temporary URLs where each page of a dispute document can be viewed. 39 | * 40 | * @param string $documentId Identification of the document whose pages to view 41 | * @param \MangoPay\Pagination $pagination Pagination object 42 | * @return \MangoPay\DocumentPageConsult[] Array of consults for viewing the dispute document's pages 43 | */ 44 | public function CreateDisputeDocumentConsult($documentId, & $pagination = null) 45 | { 46 | return $this->GetList('disputes_document_create_consult', $pagination, 'MangoPay\DocumentPageConsult', $documentId, null, null); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /MangoPay/ApiEvents.php: -------------------------------------------------------------------------------- 1 | GetList('events_all', $pagination, '\MangoPay\Event', null, $filter, $sorting); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MangoPay/ApiHooks.php: -------------------------------------------------------------------------------- 1 | CreateObject('hooks_create', $hook, '\MangoPay\Hook', null, null, $idempotencyKey); 19 | } 20 | 21 | /** 22 | * Get hook 23 | * @param string $hookId Hook identifier 24 | * @return \MangoPay\Hook Wallet object returned from API 25 | */ 26 | public function Get($hookId) 27 | { 28 | return $this->GetObject('hooks_get', '\MangoPay\Hook', $hookId); 29 | } 30 | 31 | /** 32 | * Save hook 33 | * @param \MangoPay\Hook $hook Hook object to save 34 | * @return \MangoPay\Hook Hook object returned from API 35 | */ 36 | public function Update($hook) 37 | { 38 | return $this->SaveObject('hooks_save', $hook, '\MangoPay\Hook'); 39 | } 40 | 41 | /** 42 | * Get all hooks 43 | * @param \MangoPay\Pagination $pagination Pagination object 44 | * @param \MangoPay\Sorting $sorting Sorting object 45 | * @return \MangoPay\Hook[] Array with objects returned from API 46 | * @throws Libraries\Exception 47 | */ 48 | public function GetAll(& $pagination = null, $sorting = null) 49 | { 50 | return $this->GetList('hooks_all', $pagination, '\MangoPay\Hook', null, null, $sorting); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MangoPay/ApiIdentityVerification.php: -------------------------------------------------------------------------------- 1 | CreateObject('identity_verification_create', $identityVerification, '\MangoPay\IdentityVerification', $userId, null, $idempotencyKey); 18 | } 19 | 20 | /** 21 | * Get IdentityVerification 22 | * @param string $id IdentityVerification identifier 23 | * @return \MangoPay\IdentityVerification IdentityVerification object returned from API 24 | */ 25 | public function Get($id) 26 | { 27 | return $this->GetObject('identity_verification_get', '\MangoPay\IdentityVerification', $id); 28 | } 29 | 30 | /** 31 | * Get all IdentityVerifications for a user 32 | * @param string $userId User identifier 33 | * @return \MangoPay\IdentityVerification[] IdentityVerification list returned from API 34 | */ 35 | public function GetAll($userId, $pagination = null, $filter = null, $sorting = null) 36 | { 37 | return $this->GetList('identity_verification_get_all', $pagination, '\MangoPay\IdentityVerification', $userId, $filter, $sorting); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MangoPay/ApiKycDocuments.php: -------------------------------------------------------------------------------- 1 | GetList('kyc_documents_all', $pagination, '\MangoPay\KycDocument', null, $filter, $sorting); 20 | } 21 | 22 | /** 23 | * Get KYC document 24 | * @param string $kycDocumentId Document identifier 25 | * @return \MangoPay\KycDocument Document returned from API 26 | */ 27 | public function Get($kycDocumentId) 28 | { 29 | return $this->GetObject('kyc_documents_get_alt', '\MangoPay\KycDocument', $kycDocumentId); 30 | } 31 | 32 | 33 | /** 34 | * Creates temporary URLs where each page of a KYC document can be viewed. 35 | * 36 | * @param string $kycDocumentId Identification of the document whose pages to view 37 | * @param \MangoPay\Pagination $pagination Pagination object 38 | * @return \MangoPay\DocumentPageConsult[] Array of consults for viewing the KYC document's pages 39 | * @throws Libraries\Exception 40 | */ 41 | public function CreateKycDocumentConsult($kycDocumentId, & $pagination = null) 42 | { 43 | return $this->GetList('kyc_documents_create_consult', $pagination, '\MangoPay\DocumentPageConsult', $kycDocumentId, null, null); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /MangoPay/ApiRefunds.php: -------------------------------------------------------------------------------- 1 | GetObject('refunds_get', '\MangoPay\Refund', $refundId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MangoPay/ApiRegulatory.php: -------------------------------------------------------------------------------- 1 | GetObject('country_authorization_get', '\MangoPay\CountryAuthorization', $countryCode, null, null, false); 19 | } 20 | 21 | /** 22 | * Get all countries authorizations 23 | * @param \MangoPay\Pagination $pagination 24 | * @param \MangoPay\Sorting $sorting 25 | * @return \MangoPay\CountryAuthorization[] 26 | * @throws Libraries\Exception 27 | */ 28 | public function GetAllCountryAuthorizations(& $pagination = null, $sorting = null) 29 | { 30 | return $this->GetList('country_authorization_all', $pagination, 'MangoPay\CountryAuthorization', null, null, $sorting, null, false); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MangoPay/ApiReports.php: -------------------------------------------------------------------------------- 1 | ReportType; 18 | 19 | if (is_null($type) || strlen($type) == 0) { 20 | throw new Libraries\Exception('Report type property is required when create a report request.'); 21 | } 22 | 23 | switch ($type) { 24 | case ReportType::Transactions: 25 | return $this->CreateObject('reports_transactions_create', $reportRequest, '\MangoPay\ReportRequest', $type, null, $idempotencyKey); 26 | case ReportType::Wallets: 27 | return $this->CreateObject('reports_wallets_create', $reportRequest, '\MangoPay\ReportRequest', $type, null, $idempotencyKey); 28 | default: 29 | throw new Libraries\Exception('Unexpected Report type. Wrong ReportType value.'); 30 | } 31 | } 32 | 33 | /** 34 | * Gets report request. 35 | * @param string $reportRequestId Report request identifier 36 | * @return \MangoPay\ReportRequest Report request instance returned from API 37 | */ 38 | public function Get($reportRequestId) 39 | { 40 | return $this->GetObject('reports_get', '\MangoPay\ReportRequest', $reportRequestId); 41 | } 42 | 43 | /** 44 | * Gets all report requests. 45 | * @param \MangoPay\Pagination $pagination Pagination object 46 | * @param \MangoPay\FilterTransactions $filter Object to filter data 47 | * @param \MangoPay\Sorting $sorting Object to sorting data 48 | * @return \MangoPay\ReportRequest Array with report requests 49 | */ 50 | public function GetAll(& $pagination = null, $filter = null, $sorting = null) 51 | { 52 | return $this->GetList('reports_all', $pagination, 'MangoPay\ReportRequest', null, $filter, $sorting); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MangoPay/ApiRepudiations.php: -------------------------------------------------------------------------------- 1 | GetObject('repudiation_get', '\MangoPay\Repudiation', $repudiationId); 16 | } 17 | 18 | /** 19 | * Retrieves a list of Refunds pertaining to a certain Repudiation 20 | * @param string $repudiationId Repudiation identifier 21 | * @param \MangoPay\Pagination $pagination Pagination object 22 | * @param \MangoPay\FilterRefunds $filter Filtering object 23 | * @param \MangoPay\Sorting $sorting Sorting object 24 | * @return \MangoPay\Refund[] 25 | */ 26 | public function GetRefunds($repudiationId, & $pagination = null, $filter = null, $sorting = null) 27 | { 28 | return $this->GetList('refunds_get_for_repudiation', $pagination, '\MangoPay\Repudiation', $repudiationId, $filter, $sorting); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MangoPay/ApiResponses.php: -------------------------------------------------------------------------------- 1 | GetObject('responses_get', 'MangoPay\Response', $idempotencyKey); 19 | 20 | // Same logic as RestTool::CheckResponseCode 21 | if ($response->StatusCode >= 200 && $response->StatusCode <= 299) { 22 | // Target the class to use from the SDK 23 | $className = $this->GetObjectForIdempotencyUrl($response->RequestURL); 24 | if (is_null($className) || empty($className) || is_null($response->Resource) || empty($response->Resource)) { 25 | return $response; 26 | } 27 | 28 | $response->Resource = $this->CastResponseToEntity($response->Resource, $className); 29 | return $response; 30 | } 31 | 32 | $response->Resource = $this->CastResponseToError($response->Resource); 33 | return $response; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MangoPay/ApiTransfers.php: -------------------------------------------------------------------------------- 1 | CreateObject('transfers_create', $transfer, '\MangoPay\Transfer', null, null, $idempotencyKey); 18 | } 19 | 20 | /** 21 | * Get transfer 22 | * @param string $transferId Transfer identifier 23 | * @return \MangoPay\Transfer Transfer object returned from API 24 | */ 25 | public function Get($transferId) 26 | { 27 | return $this->GetObject('transfers_get', '\MangoPay\Transfer', $transferId); 28 | } 29 | 30 | /** 31 | * Create refund for transfer object 32 | * @param string $transferId Transfer identifier 33 | * @param \MangoPay\Refund $refund Refund object to create 34 | * @return \MangoPay\Refund Object returned by REST API 35 | */ 36 | public function CreateRefund($transferId, $refund, $idempotencyKey = null) 37 | { 38 | return $this->CreateObject('transfers_createrefunds', $refund, '\MangoPay\Refund', $transferId, null, $idempotencyKey); 39 | } 40 | 41 | /** 42 | * Retrieve list of Refunds pertaining to a certain Transfer 43 | * @param string $transferId Transfer identifier 44 | * @param \MangoPay\Pagination $pagination Pagination object 45 | * @param \MangoPay\FilterRefunds $filter Filtering object 46 | * @param \MangoPay\Sorting $sorting Sorting object 47 | * @return \MangoPay\Refund[] List of the Transfer's Refunds 48 | */ 49 | public function GetRefunds($transferId, & $pagination = null, $filter = null, $sorting = null) 50 | { 51 | return $this->GetList('refunds_get_for_transfer', $pagination, '\MangoPay\Refund', $transferId, $filter, $sorting); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MangoPay/ApiVirtualAccounts.php: -------------------------------------------------------------------------------- 1 | CreateObject('virtual_account_create', $virtualAccount, '\MangoPay\VirtualAccount', $walletId, $idempotencyKey); 16 | } 17 | 18 | /** 19 | * @param string $walletId 20 | * @param string $virtualAccountId 21 | * @return \MangoPay\VirtualAccount 22 | */ 23 | public function Get($walletId, $virtualAccountId) 24 | { 25 | return $this->GetObject('virtual_account_get', '\MangoPay\VirtualAccount', $walletId, $virtualAccountId); 26 | } 27 | 28 | /** 29 | * @param \MangoPay\Pagination $pagination Pagination object 30 | * @param string $walletId 31 | * @return \MangoPay\VirtualAccount[] 32 | */ 33 | public function GetAll($walletId, $pagination = null, $sorting = null) 34 | { 35 | return $this->GetList('virtual_account_get_all', $pagination, '\MangoPay\VirtualAccount', $walletId, $sorting); 36 | } 37 | 38 | /** 39 | * @param string $walletId 40 | * @param string $virtualAccountId 41 | * @return \MangoPay\VirtualAccount 42 | */ 43 | public function Deactivate($walletId, $virtualAccountId) 44 | { 45 | $empty_object = new VirtualAccount(); 46 | return $this->SaveObject('virtual_account_deactivate', $empty_object, '\MangoPay\VirtualAccount', $walletId, $virtualAccountId); 47 | } 48 | 49 | /** 50 | * @return \MangoPay\VirtualAccountAvailabilities 51 | */ 52 | public function GetAvailabilities() 53 | { 54 | return $this->GetObject('virtual_account_get_availabilities', '\MangoPay\VirtualAccountAvailabilities'); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MangoPay/ApiWallets.php: -------------------------------------------------------------------------------- 1 | CreateObject('wallets_create', $wallet, '\MangoPay\Wallet', null, null, $idempotencyKey); 18 | } 19 | 20 | /** 21 | * Get wallet 22 | * @param string $walletId Wallet identifier 23 | * @param string $scaContext Optional. Possible values: USER_NOT_PRESENT, USER_PRESENT 24 | * In case USER_PRESENT is used and SCA is required, an error containing the RedirectUrl will be thrown 25 | * @return \MangoPay\Wallet Wallet object returned from API 26 | */ 27 | public function Get($walletId, $scaContext = null) 28 | { 29 | if ($scaContext != null) { 30 | return $this->GetObject('wallets_get_sca', '\MangoPay\Wallet', $walletId, $scaContext); 31 | } 32 | return $this->GetObject('wallets_get', '\MangoPay\Wallet', $walletId); 33 | } 34 | 35 | /** 36 | * Save wallet 37 | * @param Wallet $wallet Wallet object to save 38 | * @return \MangoPay\Wallet Wallet object returned from API 39 | */ 40 | public function Update($wallet) 41 | { 42 | return $this->SaveObject('wallets_save', $wallet, '\MangoPay\Wallet'); 43 | } 44 | 45 | /** 46 | * Get transactions for the wallet 47 | * @param string $walletId Wallet identifier 48 | * @param \MangoPay\Pagination $pagination Pagination object 49 | * @param \MangoPay\FilterTransactions $filter Object to filter data 50 | * @param \MangoPay\Sorting $sorting Object to sorting data 51 | * @return \MangoPay\Transaction[] Transactions for wallet returned from API 52 | */ 53 | public function GetTransactions($walletId, & $pagination = null, $filter = null, $sorting = null) 54 | { 55 | return $this->GetList('wallets_alltransactions', $pagination, '\MangoPay\Transaction', $walletId, $filter, $sorting); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MangoPay/Autoloader.php: -------------------------------------------------------------------------------- 1 | [ 66 | '_property_name' => 'Details', 67 | 'IBAN' => '\MangoPay\BankAccountDetailsIBAN', 68 | 'GB' => '\MangoPay\BankAccountDetailsGB', 69 | 'US' => '\MangoPay\BankAccountDetailsUS', 70 | 'CA' => '\MangoPay\BankAccountDetailsCA', 71 | 'OTHER' => '\MangoPay\BankAccountDetailsOTHER', 72 | ] 73 | ]; 74 | } 75 | 76 | /** 77 | * Get array with read-only properties 78 | * @return array 79 | */ 80 | public function GetReadOnlyProperties() 81 | { 82 | $properties = parent::GetReadOnlyProperties(); 83 | array_push($properties, 'UserId'); 84 | array_push($properties, 'Type'); 85 | return $properties; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /MangoPay/BankAccountDetails.php: -------------------------------------------------------------------------------- 1 | BUSINESS_VERIFICATION - Verification of the business entity of a Legal User.

18 | *

IDENTITY_DOCUMENT_VERIFICATION - Verification of the identity document of a Natural User or the legal representative of a Legal User.

19 | *

PERSONS_SIGNIFICANT_CONTROL - Verification of a person of significant control of a Legal User.

20 | * @var string 21 | */ 22 | public $Type; 23 | 24 | /** 25 | * Returned values: VALIDATED, REFUSED, REVIEW 26 | * @var string 27 | */ 28 | public $CheckStatus; 29 | 30 | /** 31 | * The date and time at which the check was created. 32 | * @var int 33 | */ 34 | public $CreationDate; 35 | 36 | /** 37 | * The date and time at which the check was last updated. 38 | * @var int 39 | */ 40 | public $LastUpdate; 41 | 42 | /** 43 | * The data points collected and verified during the check. 44 | * @var CheckData[] 45 | */ 46 | public $Data; 47 | 48 | /** 49 | * The data points collected and verified during the check. 50 | * @var CheckData[] 51 | */ 52 | public $Reasons; 53 | } 54 | -------------------------------------------------------------------------------- /MangoPay/CheckData.php: -------------------------------------------------------------------------------- 1 | '\MangoPay\CountryAuthorizationData' 42 | ]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MangoPay/CountryAuthorizationData.php: -------------------------------------------------------------------------------- 1 | The type of the client wallet to be debited:

13 | *

FEES – Fees Wallet, for fees collected by the platform.

14 | *

CREDIT – Repudiation Wallet, for funds related to dispute management.

15 | *

The amount and currency of the debited funds are defined by the quote.

16 | * @var string 17 | */ 18 | public $DebitedWalletType; 19 | 20 | /** 21 | * The sell funds 22 | * @var Money 23 | */ 24 | public $DebitedFunds; 25 | 26 | /** 27 | * Allowed values: FEES, CREDIT 28 | * 29 | *

The type of the client wallet to be credited:

30 | *

FEES – Fees Wallet, for fees collected by the platform.

31 | *

CREDIT – Repudiation Wallet, for funds related to dispute management.

32 | *

The amount and currency of the credited funds are defined by the quote.

33 | * @var string 34 | */ 35 | public $CreditedWalletType; 36 | 37 | /** 38 | * The buy funds 39 | * @var Money 40 | */ 41 | public $CreditedFunds; 42 | 43 | /** 44 | * Custom data. 45 | * @var string 46 | */ 47 | public $Tag; 48 | } 49 | -------------------------------------------------------------------------------- /MangoPay/CreateClientWalletsQuotedConversion.php: -------------------------------------------------------------------------------- 1 | The type of the client wallet to be debited:

22 | *

FEES – Fees Wallet, for fees collected by the platform.

23 | *

CREDIT – Repudiation Wallet, for funds related to dispute management.

24 | *

The amount and currency of the debited funds are defined by the quote.

25 | * @var string 26 | */ 27 | public $DebitedWalletType; 28 | 29 | /** 30 | * Allowed values: FEES, CREDIT 31 | * 32 | *

The type of the client wallet to be credited:

33 | *

FEES – Fees Wallet, for fees collected by the platform.

34 | *

CREDIT – Repudiation Wallet, for funds related to dispute management.

35 | *

The amount and currency of the credited funds are defined by the quote.

36 | * @var string 37 | */ 38 | public $CreditedWalletType; 39 | 40 | /** 41 | * Custom data. 42 | * @var string 43 | */ 44 | public $Tag; 45 | } 46 | -------------------------------------------------------------------------------- /MangoPay/CreateDeposit.php: -------------------------------------------------------------------------------- 1 | PENDING – The session is available on the HostedUrl, to which the user must be redirected to complete it.

16 | *

VALIDATED – The session was successful.

17 | *

REFUSED – The session was refused.

18 | *

REVIEW – The session is under manual review by Mangopay.

19 | *

OUT_OF_DATE – The session is no longer valid (likely due to expired documents used during the session).

20 | *

TIMEOUT – The session timed out due to inactivity.

21 | *

ERROR – The session was not completed because an error occurred.

22 | * @var string 23 | */ 24 | public $Status; 25 | 26 | /** 27 | * The URL to which the user is returned after the hosted identity verification session, regardless of the outcome. 28 | * @var string 29 | */ 30 | public $ReturnUrl; 31 | 32 | /** 33 | * @var int 34 | */ 35 | public $LastUpdate; 36 | 37 | /** 38 | * @var string 39 | */ 40 | public $UserId; 41 | 42 | /** 43 | * @var Check[] 44 | */ 45 | public $Checks; 46 | } 47 | -------------------------------------------------------------------------------- /MangoPay/IndividualRecipient.php: -------------------------------------------------------------------------------- 1 | IsEmpty($this->FirstName) 55 | && $this->IsEmpty($this->LastName) 56 | && $this->IsEmpty($this->ProofOfIdentity) 57 | && $this->IsEmpty($this->Email) 58 | && $this->IsEmpty($this->Birthday) 59 | && $this->IsEmpty($this->Nationality) 60 | && $this->IsEmpty($this->CountryOfResidence) 61 | && $this->IsEmpty($this->PhoneNumber) 62 | && $this->IsEmpty($this->PhoneNumberCountry); 63 | } 64 | 65 | private function IsEmpty($value) 66 | { 67 | return is_null($value) || empty($value); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /MangoPay/Libraries/ApiOAuth.php: -------------------------------------------------------------------------------- 1 | GetRequestUrl('authentication_oauth'); 17 | $requestType = $this->GetRequestType('authentication_oauth'); 18 | $requestData = [ 19 | 'grant_type' => 'client_credentials' 20 | ]; 21 | 22 | $rest = new RestTool($this->_root, false, false); 23 | $authHlp = new AuthenticationHelper($this->_root); 24 | 25 | $urlDetails = parse_url($this->_root->Config->BaseUrl); 26 | $rest->AddRequestHttpHeader('Host: ' . @$urlDetails['host']); 27 | $rest->AddRequestHttpHeader('Authorization: Basic ' . $authHlp->GetHttpHeaderBasicKey()); 28 | $rest->AddRequestHttpHeader('Content-Type: application/x-www-form-urlencoded'); 29 | if ($this->_root->Config->UKHeaderFlag) { 30 | $rest->AddRequestHttpHeader('x-tenant-id: uk'); 31 | } 32 | $response = $rest->Request($urlMethod, $requestType, $requestData); 33 | $token = $this->CastResponseToEntity($response, '\MangoPay\Libraries\OAuthToken'); 34 | $token->autentication_key = $authHlp->GetAutenticationKey(); 35 | 36 | return $token; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MangoPay/Libraries/AuthorizationTokenManager.php: -------------------------------------------------------------------------------- 1 | _root = $root; 19 | 20 | $this->RegisterCustomStorageStrategy(new DefaultStorageStrategy($this->_root->Config)); 21 | } 22 | 23 | /** 24 | * Gets the current authorization token. 25 | * In the very first call, this method creates a new token before returning. 26 | * If currently stored token is expired, this method creates a new one. 27 | * @return \MangoPay\Libraries\OAuthToken Valid OAuthToken instance. 28 | */ 29 | public function GetToken($autenticationKey) 30 | { 31 | $token = $this->_storageStrategy->Get(); 32 | 33 | if (is_null($token) || false === $token || $token->IsExpired() || $token->GetAutenticationKey() != $autenticationKey) { 34 | $this->StoreToken($this->_root->AuthenticationManager->CreateToken()); 35 | } 36 | 37 | return $this->_storageStrategy->Get(); 38 | } 39 | 40 | /** 41 | * Stores authorization token passed as an argument in the underlying 42 | * storage strategy implementation. 43 | * @param \MangoPay\Libraries\OAuthToken $token Token instance to be stored. 44 | */ 45 | public function StoreToken($token) 46 | { 47 | $this->_storageStrategy->Store($token); 48 | } 49 | 50 | /** 51 | * Registers custom storage strategy implementation. 52 | * By default, the DefaultStorageStrategy instance is used. 53 | * There is no need to explicitly call this method until some more complex 54 | * storage implementation is needed. 55 | * @param \MangoPay\Libraries\IStorageStrategy $customStorageStrategy IStorageStrategy interface implementation. 56 | */ 57 | public function RegisterCustomStorageStrategy($customStorageStrategy) 58 | { 59 | $this->_storageStrategy = $customStorageStrategy; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MangoPay/Libraries/Configuration.php: -------------------------------------------------------------------------------- 1 | Id = $id; 34 | } 35 | 36 | /** 37 | * Get array with read-only properties 38 | * @return array 39 | */ 40 | public function GetReadOnlyProperties() 41 | { 42 | return [ 'Id', 'CreationDate' ]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MangoPay/Libraries/Error.php: -------------------------------------------------------------------------------- 1 | Errors); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MangoPay/Libraries/Exception.php: -------------------------------------------------------------------------------- 1 | _root = $root; 29 | $this->logger = $root->getLogger(); 30 | } 31 | 32 | 33 | /** 34 | * @param RestTool $restTool 35 | * 36 | * @return HttpResponse 37 | */ 38 | abstract public function Request(RestTool $restTool); 39 | } 40 | -------------------------------------------------------------------------------- /MangoPay/Libraries/HttpResponse.php: -------------------------------------------------------------------------------- 1 | '; 13 | print $message . ': '; 14 | print_r($data); 15 | print '
-------------------------------'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MangoPay/Libraries/OAuthToken.php: -------------------------------------------------------------------------------- 1 | create_time = time() - 5; 46 | } 47 | 48 | /** 49 | * Check that current tokens are expire and return true if yes 50 | * @return bool 51 | */ 52 | public function IsExpired() 53 | { 54 | return (time() >= ($this->create_time + $this->expires_in)); 55 | } 56 | 57 | public function GetAutenticationKey() 58 | { 59 | return $this->autentication_key; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MangoPay/Libraries/RequestType.php: -------------------------------------------------------------------------------- 1 | 'OK', 16 | 204 => 'No Content', 17 | 206 => 'PartialContent', 18 | 400 => 'Bad request', 19 | 401 => 'Unauthorized', 20 | 403 => 'Prohibition to use the method', 21 | 404 => 'Not found', 22 | 405 => 'Method not allowed', 23 | 413 => 'Request entity too large', 24 | 422 => 'Unprocessable entity', 25 | 500 => 'Internal server error', 26 | 501 => 'Not implemented' 27 | ]; 28 | 29 | /** 30 | * Error details 31 | * @var Error 32 | */ 33 | private $_errorInfo; 34 | 35 | /** 36 | * Error code 37 | * @var int 38 | */ 39 | private $_code; 40 | 41 | /** 42 | * Request URL 43 | * @var string 44 | */ 45 | public $RequestUrl; 46 | 47 | /** 48 | * Construct 49 | * @param int $code Response code 50 | * @param Error $errorInfo Details with the error 51 | */ 52 | public function __construct($requestUrl, $code, $errorInfo = null) 53 | { 54 | $this->RequestUrl = $requestUrl; 55 | $this->_code = $code; 56 | 57 | if (isset($this->_responseCodes[$code])) { 58 | $errorMsg = $this->_responseCodes[$code]; 59 | } else { 60 | $errorMsg = 'Unknown response error'; 61 | } 62 | 63 | if (!is_null($errorInfo)) { 64 | $errorMsg .= '. ' . $errorInfo->Message; 65 | $this->_errorInfo = $errorInfo; 66 | } 67 | 68 | parent::__construct($errorMsg, $code); 69 | } 70 | 71 | /** 72 | * Get Error object returned by REST API 73 | * @return Error 74 | */ 75 | public function GetErrorDetails() 76 | { 77 | return $this->_errorInfo; 78 | } 79 | 80 | /** 81 | * Get Error code returned by REST API 82 | * @return int 83 | */ 84 | public function GetErrorCode() 85 | { 86 | return $this->_code; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /MangoPay/Libraries/Upload.php: -------------------------------------------------------------------------------- 1 | http url 39 | * prev => http url 40 | * next => http url 41 | * last => http url 42 | * ) 43 | * @var array 44 | */ 45 | public $Links = []; 46 | 47 | /** 48 | * Construct 49 | * @param int $page Number of page 50 | * @param int $itemsPerPage Number of items on one page 51 | */ 52 | public function __construct($page = 1, $itemsPerPage = 10) 53 | { 54 | $this->Page = $page; 55 | $this->ItemsPerPage = $itemsPerPage; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MangoPay/PayInCardTemplateURLOptions.php: -------------------------------------------------------------------------------- 1 | '\MangoPay\Billing', 77 | 'TemplateURLOptions' => '\MangoPay\PayInTemplateURLOptions' 78 | ]; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /MangoPay/PayInExecutionType.php: -------------------------------------------------------------------------------- 1 | '\MangoPay\Money' , 42 | 'DeclaredFees' => '\MangoPay\Money' , 43 | 'BankAccount' => '\MangoPay\BankAccount' 44 | ]; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /MangoPay/PayInPaymentDetailsBlik.php: -------------------------------------------------------------------------------- 1 | Allowed values: WEB, APP

24 | *

Default value: WEB

25 | *

The platform environment of the post-payment flow. The PaymentFlow value combines with the ReturnURL to manage the redirection behavior after payment:

26 | *

Set the value to APP to send the user to your platform’s mobile app

27 | *

Set the value to WEB to send the user to a web browser

28 | *

In both cases you need to provide the relevant ReturnURL, whether to your app or website.

29 | * @var string 30 | */ 31 | public $PaymentFlow; 32 | 33 | /** 34 | * Custom description to show on the user's bank statement. 35 | * It can be up to 10 char alphanumeric and space. 36 | * @var string 37 | */ 38 | public $StatementDescriptor; 39 | } 40 | -------------------------------------------------------------------------------- /MangoPay/PayInPaymentDetailsTwint.php: -------------------------------------------------------------------------------- 1 | [ 37 | '_property_name' => 'MeanOfPaymentDetails', 38 | PayOutPaymentType::BankWire => '\MangoPay\PayOutPaymentDetailsBankWire', 39 | // ...and more in future... 40 | ] 41 | ]; 42 | } 43 | 44 | /** 45 | * Get array with read-only properties 46 | * @return array 47 | */ 48 | public function GetReadOnlyProperties() 49 | { 50 | $properties = parent::GetReadOnlyProperties(); 51 | array_push($properties, 'PaymentType'); 52 | 53 | return $properties; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MangoPay/PayOutEligibilityRequest.php: -------------------------------------------------------------------------------- 1 | 12 | * Caution: Before redirecting the user on this URL, you must add the query parameter ReturnUrl with the percent-encoded URL to which you want the SCA session to return the user after authentication (whether successful or not). 13 | *

14 | * For more details, see How to redirect a user for an SCA session 15 | * @var string 16 | */ 17 | public $RedirectUrl; 18 | } 19 | -------------------------------------------------------------------------------- /MangoPay/PersonType.php: -------------------------------------------------------------------------------- 1 | > 44 | */ 45 | public $LocalBankTransfer; 46 | 47 | /** 48 | * @var array 49 | */ 50 | public $InternationalBankTransfer; 51 | 52 | /** 53 | * @var IndividualRecipientPropertySchema 54 | */ 55 | public $IndividualRecipient; 56 | 57 | /** 58 | * @var BusinessRecipientPropertySchema 59 | */ 60 | public $BusinessRecipient; 61 | 62 | public function GetSubObjects() 63 | { 64 | $subObjects = parent::GetSubObjects(); 65 | 66 | $subObjects['DisplayName'] = '\MangoPay\RecipientPropertySchema'; 67 | $subObjects['Currency'] = '\MangoPay\RecipientPropertySchema'; 68 | $subObjects['RecipientType'] = '\MangoPay\RecipientPropertySchema'; 69 | $subObjects['PayoutMethodType'] = '\MangoPay\RecipientPropertySchema'; 70 | $subObjects['RecipientScope'] = '\MangoPay\RecipientPropertySchema'; 71 | $subObjects['Tag'] = '\MangoPay\RecipientPropertySchema'; 72 | $subObjects['IndividualRecipient'] = '\MangoPay\IndividualRecipientPropertySchema'; 73 | $subObjects['BusinessRecipient'] = '\MangoPay\BusinessRecipientPropertySchema'; 74 | 75 | return $subObjects; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /MangoPay/RecurringPayInCIT.php: -------------------------------------------------------------------------------- 1 | '\MangoPay\Money' , 48 | 'Fees' => '\MangoPay\Money' 49 | ]; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /MangoPay/Shipping.php: -------------------------------------------------------------------------------- 1 | _sortFields[$fieldName] = $sortDirection; 34 | } 35 | 36 | /** 37 | * @deprecated Contains typo, kept for backward compatibility 38 | */ 39 | public function AddFiled($fieldName, $sortDirection) 40 | { 41 | //for backward compatibility from before typo fix 42 | $this->AddField($fieldName, $sortDirection); 43 | } 44 | /** 45 | * Get sort parametrs to URL 46 | * @return array 47 | */ 48 | public function GetSortParameter() 49 | { 50 | return [self::SortUrlParameterName => $this->_getFields()]; 51 | } 52 | 53 | private function _getFields() 54 | { 55 | $sortValues = ""; 56 | foreach ($this->_sortFields as $key => $value) { 57 | if (!empty($sortValues)) { 58 | $sortValues .= self::SortFieldSeparator; 59 | } 60 | 61 | $sortValues .= $key . ":" . $value; 62 | } 63 | 64 | return $sortValues; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /MangoPay/TransactionNature.php: -------------------------------------------------------------------------------- 1 | PersonType = $personType; 59 | } 60 | 61 | /** 62 | * Get array with read-only properties 63 | * @return array 64 | */ 65 | public function GetReadOnlyProperties() 66 | { 67 | $properties = parent::GetReadOnlyProperties(); 68 | array_push($properties, 'PersonType', 'TermsAndConditionsAcceptedDate'); 69 | 70 | return $properties; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /MangoPay/UserBlockStatus.php: -------------------------------------------------------------------------------- 1 | '\MangoPay\Money' ]; 41 | } 42 | 43 | /** 44 | * Get array with read-only properties 45 | * @return array 46 | */ 47 | public function GetReadOnlyProperties() 48 | { 49 | $properties = parent::GetReadOnlyProperties(); 50 | array_push($properties, 'Balance'); 51 | 52 | return $properties; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mangopay/php-sdk-v2", 3 | "description": "PHP SDK for MANGOPAY", 4 | "minimum-stability": "stable", 5 | "license": "MIT", 6 | "require": { 7 | "php": ">=5.6", 8 | "ext-curl": "*", 9 | "ext-openssl": "*", 10 | "psr/log": "^1.0|^2.0|^3.0", 11 | "ext-json": "*" 12 | }, 13 | "autoload": { 14 | "psr-4": { 15 | "MangoPay\\": "MangoPay" 16 | } 17 | }, 18 | "autoload-dev": { 19 | "psr-4": { 20 | "MangoPay\\Tests\\": "tests" 21 | } 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit": ">=5.7.27 <10", 25 | "friendsofphp/php-cs-fixer": "^2.18" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/Cases/BankingAliasTest.php: -------------------------------------------------------------------------------- 1 | getJohnsBankingAliasIBAN(); 15 | 16 | $this->assertNotNull($bankingAliasIBAN->Id); 17 | } 18 | 19 | public function test_BankingAliasGB_Create() 20 | { 21 | $bankingAliasGB = $this->getJohnsBankingAliasGB(); 22 | 23 | $this->assertNotNull($bankingAliasGB->Id); 24 | $this->assertTrue($bankingAliasGB->Type==BankingAliasType::GB); 25 | } 26 | 27 | public function test_BankingAlias_Get() 28 | { 29 | $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); 30 | 31 | $getBankingAliasIBAN = $this->_api->BankingAliases->Get($bankingAliasIBAN->Id); 32 | 33 | $this->assertSame($bankingAliasIBAN->Id, $getBankingAliasIBAN->Id); 34 | } 35 | 36 | public function test_BankingAlias_Update() 37 | { 38 | $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); 39 | $bankingAliasIBAN->Active = false; 40 | 41 | $saveBankingAliasIBAN = $this->_api->BankingAliases->Update($bankingAliasIBAN); 42 | 43 | $this->assertSame($bankingAliasIBAN->Id, $saveBankingAliasIBAN->Id); 44 | $this->assertSame(false, $saveBankingAliasIBAN->Active); 45 | } 46 | 47 | public function test_BankingAlias_All() 48 | { 49 | $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); 50 | $pagination = new \MangoPay\Pagination(1, 1); 51 | 52 | $list = $this->_api->BankingAliases->GetAll($bankingAliasIBAN->WalletId, $pagination); 53 | 54 | $this->assertInstanceOf('MangoPay\BankingAliasIBAN', $list[0]); 55 | $this->assertSame($bankingAliasIBAN->Id, $list[0]->Id); 56 | $this->assertSame(1, $pagination->Page); 57 | $this->assertSame(1, $pagination->ItemsPerPage); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/Cases/ConfigurationTest.php: -------------------------------------------------------------------------------- 1 | _api->Config->ClientId = "test_asd"; 15 | $this->_api->Config->ClientPassword = "00000"; 16 | 17 | $this->expectException(ResponseException::class); 18 | $this->_api->Users->GetAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Cases/Constants.php: -------------------------------------------------------------------------------- 1 | expectException(ResponseException::class); 13 | 14 | try { 15 | $this->_api->Users->create(new UserNatural()); 16 | } catch (\Exception $exception) { 17 | self::assertStringContainsString('FirstName error:', $exception->getMessage()); 18 | self::assertStringContainsString('LastName error:', $exception->getMessage()); 19 | self::assertStringContainsString('Birthday error:', $exception->getMessage()); 20 | self::assertStringContainsString('Nationality error:', $exception->getMessage()); 21 | self::assertStringContainsString('CountryOfResidence error:', $exception->getMessage()); 22 | self::assertStringContainsString('Email error:', $exception->getMessage()); 23 | 24 | throw $exception; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/Cases/HooksTest.php: -------------------------------------------------------------------------------- 1 | getJohnHook(); 16 | 17 | $this->assertTrue($hook->Id > 0); 18 | } 19 | 20 | public function test_Hooks_Get() 21 | { 22 | $hook = $this->getJohnHook(); 23 | 24 | $getHook = $this->_api->Hooks->Get($hook->Id); 25 | 26 | $this->assertSame($hook->Id, $getHook->Id); 27 | } 28 | 29 | public function test_Hooks_Update() 30 | { 31 | $hook = $this->getJohnHook(); 32 | $hook->Url = "http://test123.com"; 33 | 34 | $saveHook = $this->_api->Hooks->Update($hook); 35 | 36 | $this->assertSame($hook->Id, $saveHook->Id); 37 | $this->assertSame("http://test123.com", $saveHook->Url); 38 | } 39 | 40 | public function test_Hooks_All() 41 | { 42 | $hook = $this->getJohnHook(); 43 | $pagination = new \MangoPay\Pagination(1, 1); 44 | $sorting = new Sorting(); 45 | $sorting->AddField("CreationDate", SortDirection::ASC); 46 | 47 | $list = $this->_api->Hooks->GetAll($pagination, $sorting); 48 | 49 | $this->assertInstanceOf('\MangoPay\Hook', $list[0]); 50 | $this->assertSame($hook->Id, $list[0]->Id); 51 | $this->assertSame(1, $pagination->Page); 52 | $this->assertSame(1, $pagination->ItemsPerPage); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Cases/IdentityVerificationTest.php: -------------------------------------------------------------------------------- 1 | getNewIdentityVerification(); 18 | self::assertNotNull($identityVerification); 19 | self::assertNotNull($identityVerification->HostedUrl); 20 | self::assertNotNull($identityVerification->ReturnUrl); 21 | self::assertEquals('PENDING', $identityVerification->Status); 22 | } 23 | 24 | public function test_IdentityVerification_Get() 25 | { 26 | $identityVerification = $this->getNewIdentityVerification(); 27 | $fetched = $this->_api->IdentityVerifications->Get($identityVerification->Id); 28 | 29 | self::assertNotNull($fetched); 30 | self::assertEquals($identityVerification->HostedUrl, $fetched->HostedUrl); 31 | self::assertEquals($identityVerification->ReturnUrl, $fetched->ReturnUrl); 32 | self::assertEquals($identityVerification->Status, $fetched->Status); 33 | } 34 | 35 | public function test_IdentityVerification_GetAll() 36 | { 37 | $this->getNewIdentityVerification(); 38 | $john = $this->getJohn(); 39 | $fetched = $this->_api->IdentityVerifications->GetAll($john->Id); 40 | 41 | self::assertNotNull($fetched); 42 | self::assertTrue(is_array($fetched)); 43 | self::assertTrue(sizeof($fetched) > 0); 44 | } 45 | 46 | private function getNewIdentityVerification() 47 | { 48 | if (self::$identityVerification == null) { 49 | $john = $this->getJohn(); 50 | $identityVerificationCreate = new IdentityVerification(); 51 | $identityVerificationCreate->ReturnUrl = "https://example.com"; 52 | $identityVerificationCreate->Tag = "Created by the PHP SDK"; 53 | self::$identityVerification = $this->_api->IdentityVerifications->Create($identityVerificationCreate, $john->Id); 54 | } 55 | return self::$identityVerification; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/Cases/MandatesTest.php: -------------------------------------------------------------------------------- 1 | getJohn(); 15 | 16 | $mandate = $this->getJohnsMandate(); 17 | 18 | $this->assertNotNull($mandate->Id); 19 | $this->assertEquals($john->Id, $mandate->UserId); 20 | $this->assertSame(MandateStatus::Created, $mandate->Status); 21 | } 22 | 23 | public function test_Mandates_Get() 24 | { 25 | $john = $this->getJohn(); 26 | $mandate = $this->getJohnsMandate(); 27 | 28 | $getMandate = $this->_api->Mandates->Get($mandate->Id); 29 | 30 | $this->assertSame($mandate->Id, $getMandate->Id); 31 | $this->assertEquals($john->Id, $getMandate->UserId); 32 | } 33 | 34 | public function test_Mandates_Cancel() 35 | { 36 | $mandate = $this->getJohnsMandate(); 37 | 38 | try { 39 | $this->_api->Mandates->Cancel($mandate->Id); 40 | 41 | $this->fail('Expected ResponseException when cancel a mandate with status CREATED'); 42 | } catch (\MangoPay\Libraries\ResponseException $exc) { 43 | $this->assertSame(400, $exc->getCode()); 44 | } 45 | } 46 | 47 | public function test_Mandates_GetAll() 48 | { 49 | $this->getJohnsMandate(); 50 | 51 | $pagination = new \MangoPay\Pagination(); 52 | $mandates = $this->_api->Mandates->GetAll($pagination); 53 | 54 | $this->assertTrue(count($mandates) > 0); 55 | } 56 | 57 | public function test_Mandate_GetTransactions() 58 | { 59 | $mandate = $this->getJohnsMandate(); 60 | $pagination = new \MangoPay\Pagination(); 61 | $filter = new \MangoPay\FilterTransactions(); 62 | 63 | $transactions = $this->_api->Mandates->GetTransactions($mandate->Id, $pagination, $filter); 64 | 65 | $this->assertNotNull($transactions); 66 | $this->assertTrue(is_array($transactions), 'Expected an array'); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tests/Cases/RateLimitTest.php: -------------------------------------------------------------------------------- 1 | assertNull($this->_api->RateLimits); 10 | $this->getJohnsCardPreAuthorization(); 11 | 12 | $rateLimits = $this->_api->RateLimits; 13 | 14 | $this->assertNotNull($rateLimits); 15 | $this->assertTrue(sizeof($rateLimits) > 0); 16 | } 17 | 18 | public function test_RateLimitsDoc() 19 | { 20 | $this->assertNull($this->_api->RateLimits); 21 | $this->getJohnsCardPreAuthorization(); 22 | 23 | $rateLimits = $this->_api->RateLimits; 24 | 25 | print "\nThere were " . $rateLimits[0]->CallsMade . " calls made in the last 15 minutes"; 26 | print "\nYou can do " . $rateLimits[0]->CallsRemaining . " more calls in the next 15 minutes"; 27 | print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[0]->ResetTimeTimestamp); 28 | print "\nThere were " . $rateLimits[2]->CallsMade . " calls made in the last 60 minutes"; 29 | print "\nYou can do " . $rateLimits[2]->CallsRemaining . " more calls in the next 60 minutes"; 30 | print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[2]->ResetTimeTimestamp); 31 | 32 | $this->assertNotNull($rateLimits); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/Cases/RefundsTest.php: -------------------------------------------------------------------------------- 1 | getNewTransfer(); 13 | $refund = $this->getNewRefundForTransfer($transfer); 14 | $user = $this->getJohn(); 15 | 16 | $getRefund = $this->_api->Refunds->Get($refund->Id); 17 | 18 | $this->assertEquals($refund->Id, $getRefund->Id); 19 | $this->assertEquals($transfer->Id, $getRefund->InitialTransactionId); 20 | $this->assertEquals($user->Id, $getRefund->AuthorId); 21 | $this->assertEquals('TRANSFER', $getRefund->Type); 22 | $this->assertInstanceOf('\MangoPay\RefundReasonDetails', $getRefund->RefundReason); 23 | } 24 | 25 | public function test_Refund_GetForPayIn() 26 | { 27 | $payIn = $this->getNewPayInCardDirect(); 28 | $refund = $this->getNewRefundForPayIn($payIn); 29 | $user = $this->getJohn(); 30 | 31 | $getRefund = $this->_api->Refunds->Get($refund->Id); 32 | 33 | $this->assertEquals($refund->Id, $getRefund->Id); 34 | $this->assertEquals($payIn->Id, $getRefund->InitialTransactionId); 35 | $this->assertEquals($user->Id, $getRefund->AuthorId); 36 | $this->assertEquals('PAYOUT', $getRefund->Type); 37 | $this->assertInstanceOf('\MangoPay\RefundReasonDetails', $getRefund->RefundReason); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Cases/RegulatoryTest.php: -------------------------------------------------------------------------------- 1 | _api->Regulatory->GetCountryAuthorizations("FR"); 13 | 14 | $this->assertNotNull($countryAuthorizations); 15 | $this->assertNotNull($countryAuthorizations->CountryCode); 16 | $this->assertNotNull($countryAuthorizations->CountryName); 17 | $this->assertNotNull($countryAuthorizations->LastUpdate); 18 | $this->assertNotNull($countryAuthorizations->Authorization); 19 | 20 | $this->assertNotNull($countryAuthorizations->Authorization->BlockBankAccountCreation); 21 | $this->assertNotNull($countryAuthorizations->Authorization->BlockPayout); 22 | $this->assertNotNull($countryAuthorizations->Authorization->BlockUserCreation); 23 | } 24 | 25 | public function test_getAllCountriesAuthorizations() 26 | { 27 | $countryAuthorizations = $this->_api->Regulatory->GetAllCountryAuthorizations(); 28 | 29 | $this->assertNotNull($countryAuthorizations); 30 | $this->assertTrue(count($countryAuthorizations) > 0); 31 | 32 | foreach ($countryAuthorizations as $authorization) { 33 | $this->assertNotNull($authorization->CountryCode); 34 | $this->assertNotNull($authorization->CountryName); 35 | $this->assertNotNull($authorization->LastUpdate); 36 | $this->assertNotNull($authorization->Authorization); 37 | 38 | $this->assertNotNull($authorization->Authorization->BlockBankAccountCreation); 39 | $this->assertNotNull($authorization->Authorization->BlockPayout); 40 | $this->assertNotNull($authorization->Authorization->BlockUserCreation); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/Mocks/MockStorageStrategy.php: -------------------------------------------------------------------------------- 1 |