├── .gitignore ├── LICENSE ├── VERSION ├── changelog.md ├── composer.json ├── docs ├── delayed_capture.md ├── immediate_payment.md ├── payment_with_3dsecure_parameters.md ├── refund_payments.md └── reservation_payment.md ├── examples ├── example_capture_amount.php ├── example_complete_3ds_authenticated_payment.php ├── example_finish_reservation.php ├── example_get_payment_details.php ├── example_payee_transactions.php ├── example_recurring_payment_with_3dsecure.php ├── example_refund_payment.php ├── example_start_delayedcapture_payment.php ├── example_start_immediate_payment.php ├── example_start_payment_with_3dsecure_parameters.php └── example_start_reservation_payment.php ├── library ├── BarionClient.php ├── Enumerations │ ├── BarionEnvironment.php │ ├── CardType.php │ ├── Currency.php │ ├── FundingSourceType.php │ ├── PaymentStatus.php │ ├── PaymentType.php │ ├── QRCodeSize.php │ ├── RecurrenceResult.php │ ├── ThreeDSecure │ │ ├── AccountChangeIndicator.php │ │ ├── AccountCreationIndicator.php │ │ ├── AvailabilityIndicator.php │ │ ├── ChallengePreference.php │ │ ├── DeliveryTimeframeType.php │ │ ├── PasswordChangeIndicator.php │ │ ├── PaymentMethodIndicator.php │ │ ├── PurchaseType.php │ │ ├── ReOrderIndicator.php │ │ ├── RecurrenceType.php │ │ ├── ShippingAddressIndicator.php │ │ ├── ShippingAddressUsageIndicator.php │ │ └── SuspiciousActivityIndicator.php │ ├── TransactionStatus.php │ ├── TransactionType.php │ └── UILocale.php ├── Exceptions │ └── BarionException.php ├── Helpers │ ├── JSON.php │ └── StringExtension.php ├── Interfaces │ ├── IBarionModel.php │ ├── IItemContainer.php │ ├── IPayeeTransactionContainer.php │ └── IPaymentTransactionContainer.php ├── Models │ ├── BaseRequestModel.php │ ├── BaseResponseModel.php │ ├── Common │ │ ├── BankCardModel.php │ │ ├── FundingInformationModel.php │ │ ├── ItemModel.php │ │ ├── UserModel.php │ │ └── UserNameModel.php │ ├── Error │ │ └── ApiErrorModel.php │ ├── Payment │ │ ├── CancelAuthorizationRequestModel.php │ │ ├── CancelAuthorizationResponseModel.php │ │ ├── CaptureRequestModel.php │ │ ├── CaptureResponseModel.php │ │ ├── Complete3DSPaymentRequestModel.php │ │ ├── Complete3DSPaymentResponseModel.php │ │ ├── FinishReservationRequestModel.php │ │ ├── FinishReservationResponseModel.php │ │ ├── GetPaymentStateRequestModel.php │ │ ├── GetPaymentStateResponseModel.php │ │ ├── PayeeTransactionModel.php │ │ ├── PayeeTransactionToCaptureModel.php │ │ ├── PayeeTransactionToFinishModel.php │ │ ├── PaymentQRRequestModel.php │ │ ├── PaymentStateRequestModel.php │ │ ├── PaymentStateResponseModel.php │ │ ├── PaymentTransactionModel.php │ │ ├── PreparePaymentRequestModel.php │ │ ├── PreparePaymentResponseModel.php │ │ ├── TransactionDetailModel.php │ │ ├── TransactionResponseModel.php │ │ ├── TransactionToCaptureModel.php │ │ ├── TransactionToFinishModel.php │ │ └── TransactionToRefundModel.php │ ├── Refund │ │ ├── RefundRequestModel.php │ │ ├── RefundResponseModel.php │ │ └── RefundedTransactionModel.php │ └── ThreeDSecure │ │ ├── BillingAddressModel.php │ │ ├── GiftCardPurchaseModel.php │ │ ├── PayerAccountInformationModel.php │ │ ├── PurchaseInformationModel.php │ │ └── ShippingAddressModel.php ├── SSL │ ├── cacert.pem │ └── gd_bundle-g2.crt └── autoload.php └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## OS X 2 | .DS_Store 3 | 4 | /_ReSharper.Caches 5 | /.vs 6 | 7 | /vendor/ 8 | composer.lock 9 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 2.0.0 -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### v2.0.0 2024-07-16 4 | 5 | - Minimum supported PHP version increased to 8.2+ 6 | - Fully supported Composer-based autoloading 7 | - PSR-4 compliant file structure 8 | - Library is now properly namespaced under `Barion\` 9 | - Enumerations are using native enums in separate files 10 | - API calls now support header-based POSKey authentication 11 | - Allowed funding sources now include Apple Pay and Google Pay 12 | - PaymentState request is now implemented at API version 4 13 | - Added Spanish (es-ES) locale to the supported Barion Smart Gateway languages 14 | - Updated examples and docs 15 | - Added PHPDoc annotation 16 | - Client throws exception if PHP version is not sufficient or cURL extension is not available 17 | - Client throws exception if an incorrect API version is specified for a method 18 | - API version can now be set on-the-fly between calls 19 | 20 | ### [v1.4.11](https://github.com/barion/barion-web-php/releases/tag/v1.4.11) 2024-04-02 21 | 22 | - Updating bundled CA certificates 23 | 24 | ### [v1.4.10](https://github.com/barion/barion-web-php/releases/tag/v1.4.10) 2022-06-13 25 | 26 | - Fixed PaymentId parsing in API error models 27 | 28 | ### [v1.4.9](https://github.com/barion/barion-web-php/releases/tag/v1.4.9) 2022-06-09 29 | 30 | - Small fixes 31 | 32 | ### [v1.4.8](https://github.com/barion/barion-web-php/releases/tag/v1.4.8) 2022-06-09 33 | 34 | - Small fixes 35 | 36 | ### [v1.4.7](https://github.com/barion/barion-web-php/releases/tag/v1.4.7) 2022-05-25 37 | 38 | - Error response extended 39 | 40 | ### [v1.4.6](https://github.com/barion/barion-web-php/releases/tag/v1.4.6) 2021-04-28 41 | 42 | - CompletePayment response fix 43 | 44 | ### [v1.4.5](https://github.com/barion/barion-web-php/releases/tag/v1.4.5) 2021-04-15 45 | 46 | - Additional properties in the GetPaymentState response 47 | 48 | ### [v1.4.4](https://github.com/barion/barion-web-php/releases/tag/v1.4.4) 2021-01-17 49 | 50 | - RecurrenceType is fixed in GetPaymentState response 51 | 52 | ### [v1.4.3](https://github.com/barion/barion-web-php/releases/tag/v1.4.3) 2020-12-11 53 | 54 | - 3DS v2 token payment information added to the models 55 | 56 | ### [v1.4.2](https://github.com/barion/barion-web-php/releases/tag/v1.4.2) 2019-08-15 57 | 58 | - ADD: added RecurrenceType and ChallengePreference 3DS properties 59 | 60 | ### [v1.4.1](https://github.com/barion/barion-web-php/releases/tag/v1.4.1) 2019-08-14 61 | 62 | - FIX: fixed shipping address model parameters 63 | - ADD: detailed documentation for different payment scenarios 64 | 65 | ### [v1.4.0](https://github.com/barion/barion-web-php/releases/tag/v1.4.0) 2019-08-08 66 | 67 | - ADD: supporting payment properties related to 3D Secure authentication 68 | - ADD: support for Delayed Capture payment scenarios 69 | 70 | ### v1.3.2 2019-08-05 71 | 72 | - FIX: added shipping address model and fixed shipping address structure in examples 73 | 74 | ### [v1.3.1](https://github.com/barion/barion-web-php/releases/tag/v1.3.1) 2019-03-20 75 | 76 | - ADD: Greek locale support (el-GR) 77 | 78 | ### [v1.3](https://github.com/barion/barion-web-php/releases/tag/v1.3) 2019-03-12 79 | 80 | - ADD: CZK currency and czech locale 81 | 82 | ### [v1.2.9](https://github.com/barion/barion-web-php/releases/tag/v1.2.9) 2017-05-16 83 | 84 | - FIX: PaymenStateResponse extended to parse all the available fields 85 | 86 | ### [v1.2.8](https://github.com/barion/barion-web-php/releases/tag/v1.2.8) 2017-04-13 87 | 88 | - FIX: Refunded transactions parsed correctly 89 | 90 | ### [v1.2.7](https://github.com/barion/barion-web-php/releases/tag/v1.2.7) 2017-02-14 91 | 92 | - MERGE: Added FundingInformation and BankCard to PaymentStateResponse 93 | - MERGE: Added currency to PaymentStateResponseModel and TransactionDetailModel 94 | - Added "Expired", "PartiallySucceeded" and "InProgress" payment states to enumeration 95 | 96 | ### v1.2.5 2016-11-07 97 | 98 | - MERGE: Added currency handling to the start payment request model to handle EUR/USD currencies 99 | 100 | ### v1.2.4 2016-05-25 101 | 102 | - MERGE: Added parent constructor call to ResponseModels to get the Errors array initialized properly 103 | 104 | ### [v1.2.3](https://github.com/barion/barion-web-php/releases/tag/v1.2.3) 2016-01-14 105 | 106 | - FIX: Extra option for environments with SSL problems 107 | - FIX: Some issues with the models (finish reservation and QR models) 108 | 109 | ### v1.2.1 2016-01-11 110 | 111 | - FIX: Adding DIRECTORY_SEPARATOR to the path construction (thx to @zelding, based on: https://github.com/barion/barion-web-php/pull/1) 112 | 113 | ### v1.2.0 2016-01-11 114 | 115 | - SSL certificates included for the TEST environment 116 | - cURL errors are transferred to the client to help debugging 117 | - Removed end php tags 118 | - Added licencing headers 119 | 120 | ### v1.1.0 2015-11-27 121 | 122 | - Library class "Locale" renamed to "UILocale" 123 | - Minimized notices from uninitialized indices 124 | 125 | ### v1.0.1 2015-11-26 126 | 127 | - Fixed minor include path issues 128 | 129 | ### v1.0.0 2015-11-17 130 | 131 | - Initial release 132 | 133 | --- 134 | 135 | © 2017 Barion Payment Inc. 136 | All rights reserved. 137 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "barion/barion-web-php", 3 | "description": "PHP libary for Barion Smart Gateway API integration", 4 | "type": "library", 5 | "require": { 6 | "php": ">=8.2", 7 | "ext-curl": "*" 8 | }, 9 | "license": "Apache-2.0", 10 | "support": { 11 | "email": "devsupport@barion.com", 12 | "docs": "https://docs.barion.com", 13 | "chat": "https://discord.gg/rPkeS5fW" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Barion\\": "library/" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/payment_with_3dsecure_parameters.md: -------------------------------------------------------------------------------- 1 | # Example - parameters related to 3D Secure authentication 2 | 3 | From September 2019 it will be mandatory for online payments to comply with 3D Secure authentication whenever the bank card used for payment is protected by 3D Secure. 4 | The Barion library has been extended with support to special parameters related to 3D Secure authentication. 5 | 6 | The purpose of these parameters is to help the Barion API and the webshop cooperate on making the payment process as smooth and frictionless as possible. 7 | 8 | ### Constructing the payment request 9 | 10 | The process is identical to any other simple payment scenario, only the parameter count changed. 11 | 12 | There is one or more **ItemModel** describing the product, as usual: 13 | 14 | ```php 15 | $item = new ItemModel(); 16 | $item->Name = "TestItem"; 17 | $item->Description = "A test item for payment"; 18 | $item->Quantity = 1; 19 | $item->Unit = "pc"; 20 | $item->UnitPrice = 75; 21 | $item->ItemTotal = 75; 22 | $item->SKU = "ITEM-01"; 23 | ``` 24 | 25 | These items are then added to a transaction: 26 | 27 | ```php 28 | $trans = new PaymentTransactionModel(); 29 | $trans->POSTransactionId = "TRANS-01"; 30 | $trans->Payee = $myEmailAddress; 31 | $trans->Total = 75; 32 | $trans->Comment = "Test Transaction"; 33 | $trans->AddItem($item); 34 | ``` 35 | 36 | And here come the additional parameters. First, the shipping and billing addresses: 37 | 38 | ```php 39 | $shippingAddress = new ShippingAddressModel(); 40 | $shippingAddress->Country = "DE"; 41 | $shippingAddress->Region = null; 42 | $shippingAddress->City = "Berlin"; 43 | $shippingAddress->Zip = "10243"; 44 | $shippingAddress->Street = "Karl-Marx-Allee 93A"; 45 | $shippingAddress->Street2 = "1. ebene"; 46 | $shippingAddress->Street3 = ""; 47 | $shippingAddress->FullName = "Thomas Testing"; 48 | 49 | $billingAddress = new BillingAddressModel(); 50 | $billingAddress->Country = "DE"; 51 | $billingAddress->Region = null; 52 | $billingAddress->City = "Berlin"; 53 | $billingAddress->Zip = "10243"; 54 | $billingAddress->Street = "Karl-Marx-Allee 93A"; 55 | $billingAddress->Street2 = "1. ebene"; 56 | $billingAddress->Street3 = ""; 57 | ``` 58 | 59 | **NOTE:** the older version of the library used the shipping address as one simple string. This method will NO LONGER WORK, the address structure must fully comply with the API documentation. Please review any request assembling in your integration where you are handling a shipping address. 60 | 61 | The webshop should supply as much information about the account of the customer as it can. This is done in the **PayerAccountInformationModel**. 62 | 63 | ```php 64 | $payerAccountInfo = new PayerAccountInformationModel(); 65 | $payerAccountInfo->AccountId = "4444888888885559"; 66 | $payerAccountInfo->AccountCreated = $now; 67 | $payerAccountInfo->AccountCreationIndicator = AccountCreationIndicator::CreatedDuringThisTransaction; 68 | $payerAccountInfo->AccountLastChanged = $now; 69 | $payerAccountInfo->AccountChangeIndicator = AccountChangeIndicator::ChangedDuringThisTransaction; 70 | $payerAccountInfo->PasswordLastChanged = $now; 71 | $payerAccountInfo->PasswordChangeIndicator = PasswordChangeIndicator::NoChange; 72 | $payerAccountInfo->PurchasesInTheLastSixMonths = 6; 73 | $payerAccountInfo->ShippingAddressAdded = $now; 74 | $payerAccountInfo->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::ThisTransaction; 75 | $payerAccountInfo->PaymentMethodAdded = $now; 76 | $payerAccountInfo->PaymentMethodIndicator = PaymentMethodIndicator::ThisTransaction; 77 | $payerAccountInfo->ProvisionAttempts = 1; 78 | $payerAccountInfo->TransactionalActivityPerDay = 1; 79 | $payerAccountInfo->TransactionalActivityPerYear = 100; 80 | $payerAccountInfo->SuspiciousActivityIndicator = SuspiciousActivityIndicator::NoSuspiciousActivityObserved; 81 | ``` 82 | 83 | Similarly, all known information about the purchase itself shall be supplied in the **PurchaseInformationModel**: 84 | 85 | ```php 86 | $purchaseInfo = new PurchaseInformationModel(); 87 | $purchaseInfo->DeliveryTimeframe = DeliveryTimeFrameType::OvernightShipping; 88 | $purchaseInfo->DeliveryEmailAddress = "user@example.com"; 89 | $purchaseInfo->PreOrderDate = "2019-08-01"; 90 | $purchaseInfo->AvailabilityIndicator = AvailabilityIndicator::MerchandiseAvailable; 91 | $purchaseInfo->ReOrderIndicator = ReOrderIndicator::FirstTimeOrdered; 92 | $purchaseInfo->RecurringExpiry = "2099-12-31 23:59:59"; 93 | $purchaseInfo->RecurringFrequency = "0"; 94 | $purchaseInfo->ShippingAddressIndicator = ShippingAddressIndicator::ShipToCardholdersBillingAddress; 95 | $purchaseInfo->GiftCardPurchase = null; 96 | $purchaseInfo->PurchaseType = PurchaseType::GoodsAndServicePurchase; 97 | ``` 98 | 99 | Lastly, the final **PreparePaymentRequestModel** can be constructed using the transactions and the extra parameters above, among with known phone numbers and credit card holder name of the customer. 100 | 101 | ```php 102 | $psr = new PreparePaymentRequestModel(); 103 | $psr->GuestCheckout = true; 104 | $psr->PaymentType = PaymentType::Immediate; 105 | $psr->FundingSources = array(FundingSourceType::All); 106 | $psr->PaymentRequestId = "TESTPAY-01"; 107 | $psr->PayerHint = "user@example.com"; 108 | $psr->Locale = UILocale::EN; 109 | $psr->Currency = Currency::EUR; 110 | $psr->OrderNumber = "ORDER-0001"; 111 | $psr->AddTransaction($trans); 112 | 113 | $psr->ShippingAddress = $shippingAddress; 114 | $psr->BillingAddress = $billingAddress; 115 | $psr->CardHolderNameHint = "John Doe"; 116 | $psr->PayerPhoneNumber = "36301122334"; 117 | $psr->PayerWorkPhoneNumber = "36301122334"; 118 | $psr->PayerHomePhoneNumber = "36301122334"; 119 | $psr->PayerAccountInformation = $payerAccountInfo; 120 | $psr->PurchaseInformation = $purchaseInfo; 121 | ``` 122 | 123 | The complete payment request object looks like this: 124 | 125 | ``` 126 | PreparePaymentRequestModel Object 127 | ( 128 | [PaymentType] => Immediate 129 | [ReservationPeriod] => 130 | [DelayedCapturePeriod] => 131 | [PaymentWindow] => 00:30:00 132 | [GuestCheckout] => 1 133 | [FundingSources] => Array 134 | ( 135 | [0] => All 136 | ) 137 | 138 | [PaymentRequestId] => TESTPAY-01 139 | [PayerHint] => user@example.com 140 | [Transactions] => Array 141 | ( 142 | [0] => PaymentTransactionModel Object 143 | ( 144 | [POSTransactionId] => TRANS-01 145 | [Payee] => barionaccount@demo-merchant.shop 146 | [Total] => 75 147 | [Comment] => Test Transaction 148 | [Items] => Array 149 | ( 150 | [0] => ItemModel Object 151 | ( 152 | [Name] => TestItem 153 | [Description] => A test item for payment 154 | [Quantity] => 1 155 | [Unit] => pc 156 | [UnitPrice] => 75 157 | [ItemTotal] => 75 158 | [SKU] => ITEM-01 159 | ) 160 | 161 | ) 162 | 163 | [PayeeTransactions] => Array 164 | ( 165 | ) 166 | 167 | ) 168 | 169 | ) 170 | 171 | [Locale] => en-US 172 | [OrderNumber] => ORDER-0001 173 | [ShippingAddress] => ShippingAddressModel Object 174 | ( 175 | [Country] => DE 176 | [Region] => 177 | [City] => Berlin 178 | [Zip] => 10243 179 | [Street] => Karl-Marx-Allee 93A 180 | [Street2] => 1. ebene 181 | [Street3] => 182 | [FullName] => Thomas Testing 183 | ) 184 | 185 | [BillingAddress] => BillingAddressModel Object 186 | ( 187 | [Country] => DE 188 | [Region] => 189 | [City] => Berlin 190 | [Zip] => 10243 191 | [Street] => Karl-Marx-Allee 93A 192 | [Street2] => 1. ebene 193 | [Street3] => 194 | ) 195 | 196 | [InitiateRecurrence] => 197 | [RecurrenceId] => 198 | [RedirectUrl] => 199 | [CallbackUrl] => 200 | [Currency] => EUR 201 | [CardHolderNameHint] => John Doe 202 | [PayerPhoneNumber] => 36301122334 203 | [PayerWorkPhoneNumber] => 36301122334 204 | [PayerHomePhoneNumber] => 36301122334 205 | [PayerAccountInformation] => PayerAccountInformationModel Object 206 | ( 207 | [AccountId] => 4690011905085639 208 | [AccountCreated] => 209 | [AccountCreationIndicator] => CreatedDuringThisTransaction 210 | [AccountLastChanged] => 211 | [AccountChangeIndicator] => ChangedDuringThisTransaction 212 | [PasswordLastChanged] => 213 | [PasswordChangeIndicator] => NoChange 214 | [PurchasesInTheLastSixMonths] => 6 215 | [ShippingAddressAdded] => 216 | [ShippingAddressUsageIndicator] => ThisTransaction 217 | [PaymentMethodAdded] => 218 | [PaymentMethodIndicator] => ThisTransaction 219 | [ProvisionAttempts] => 1 220 | [TransactionalActivityPerDay] => 1 221 | [TransactionalActivityPerYear] => 100 222 | [SuspiciousActivityIndicator] => NoSuspiciousActivityObserved 223 | ) 224 | 225 | [PurchaseInformation] => PurchaseInformationModel Object 226 | ( 227 | [DeliveryTimeframe] => OvernightShipping 228 | [DeliveryEmailAddress] => 229 | [PreOrderDate] => 230 | [AvailabilityIndicator] => MerchandiseAvailable 231 | [ReOrderIndicator] => FirstTimeOrdered 232 | [RecurringExpiry] => 2099-12-31 23:59:59 233 | [RecurringFrequency] => 0 234 | [ShippingAddressIndicator] => ShipToCardholdersBillingAddress 235 | [GiftCardPurchase] => 236 | [PurchaseType] => GoodsAndServicePurchase 237 | ) 238 | 239 | [POSKey] => 240 | ) 241 | ``` 242 | 243 | Nothing left than to call the API with the payment request: 244 | 245 | ```php 246 | $myPayment = $BC->PreparePayment($psr); 247 | ``` 248 | 249 | From here the process is identical to any other payment scenario. The additional 3D Secure related data is used by the Barion server in payment card related communication. Detailed information about the 3D secure authentication result is not disclosed to the webshop. 250 | 251 | ## Detailed documentation 252 | 253 | We strongly suggest that you read this article about parameters related to 3D Secure authentication in the official Barion API documentation: 254 | https://docs.barion.com/Payment-Start-v2 255 | -------------------------------------------------------------------------------- /examples/example_capture_amount.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 39 | $item->Description = "A test item for delayed capture payment"; // no more than 500 characters 40 | $item->Quantity = 1; 41 | $item->Unit = "piece"; // no more than 50 characters 42 | $item->UnitPrice = 1000; 43 | $item->ItemTotal = 1000; 44 | $item->SKU = "ITEM-01"; // no more than 100 characters 45 | 46 | // create the transaction model 47 | $trans = new TransactionToCaptureModel(); 48 | $trans->TransactionId = "33333333-3333-3333-3333-333333333333"; // <-- Replace this with the original transaction ID! 49 | $trans->Total = 1000; 50 | $trans->Comment = "Transaction completed"; // no more than 640 characters 51 | $trans->AddItem($item); 52 | 53 | // create the request object 54 | $crm = new CaptureRequestModel($paymentId); 55 | $crm->AddTransaction($trans); // add the transaction to the request 56 | 57 | // send the request 58 | $captureResult = $BC->Capture($crm); 59 | 60 | if ($captureResult->RequestSuccessful) { 61 | // TODO: process the information contained in $finishReservationResult 62 | } -------------------------------------------------------------------------------- /examples/example_complete_3ds_authenticated_payment.php: -------------------------------------------------------------------------------- 1 | Complete3DSPayment($completeRequest); 37 | 38 | if ($completeResult->RequestSuccessful) { 39 | // TODO: process the information contained in $completeResult 40 | } -------------------------------------------------------------------------------- /examples/example_finish_reservation.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 34 | $item1->Description = "A test item for payment"; // no more than 500 characters 35 | $item1->Quantity = 1; 36 | $item1->Unit = "piece"; // no more than 50 characters 37 | $item1->UnitPrice = 1000; 38 | $item1->ItemTotal = 1000; 39 | $item1->SKU = "ITEM-01"; // no more than 100 characters 40 | 41 | $item2 = new ItemModel(); 42 | $item2->Name = "AnotherTestItem"; // no more than 250 characters 43 | $item2->Description = "Another test item for payment"; // no more than 500 characters 44 | $item2->Quantity = 2; 45 | $item2->Unit = "piece"; // no more than 50 characters 46 | $item2->UnitPrice = 250; 47 | $item2->ItemTotal = 250; 48 | $item2->SKU = "ITEM-02"; // no more than 100 characters 49 | 50 | // create the transaction model 51 | $trans = new TransactionToFinishModel(); 52 | $trans->TransactionId = "33333333-3333-3333-3333-333333333333"; // <-- Replace this with the original transaction ID! 53 | $trans->Total = 1500; 54 | $trans->Comment = "Reservation complete"; // no more than 640 characters 55 | $trans->AddItem($item1); // add the items to the transaction 56 | $trans->AddItem($item2); 57 | 58 | // create the request object 59 | $frrm = new FinishReservationRequestModel($paymentId); 60 | $frrm->AddTransaction($trans); // add the transaction to the request 61 | 62 | // send the request 63 | $finishReservationResult = $BC->FinishReservation($frrm); 64 | 65 | if ($finishReservationResult->RequestSuccessful) { 66 | // TODO: process the information contained in $finishReservationResult 67 | } -------------------------------------------------------------------------------- /examples/example_get_payment_details.php: -------------------------------------------------------------------------------- 1 | PaymentState($paymentId); 31 | 32 | // TODO: process the information contained in $paymentDetails -------------------------------------------------------------------------------- /examples/example_payee_transactions.php: -------------------------------------------------------------------------------- 1 | Name = "ExpensiveTestItem"; // no more than 250 characters 47 | $item->Description = "An expensive test item for payment"; // no more than 500 characters 48 | $item->Quantity = 1; 49 | $item->Unit = "piece"; // no more than 50 characters 50 | $item->UnitPrice = 50000; 51 | $item->ItemTotal = 50000; 52 | $item->SKU = "ITEM-03"; // no more than 100 characters 53 | 54 | // create the payee transactions 55 | $ptrans1 = new PayeeTransactionModel(); 56 | $ptrans1->POSTransactionId = "PTRANS-01"; // no more than 100 characters 57 | $ptrans1->Payee = "user1@example.com"; // no more than 256 characters 58 | $ptrans1->Total = 1000; 59 | $ptrans1->Comment = "Royalties"; // no more than 640 characters 60 | 61 | $ptrans2 = new PayeeTransactionModel(); 62 | $ptrans2->POSTransactionId = "PTRANS-02"; // no more than 100 characters 63 | $ptrans2->Payee = "user2@example.com"; // no more than 256 characters 64 | $ptrans2->Total = 3000; 65 | $ptrans2->Comment = "Royalties"; // no more than 640 characters 66 | 67 | // create the transaction 68 | $trans = new PaymentTransactionModel(); 69 | $trans->POSTransactionId = "TRANS-03"; 70 | $trans->Payee = $myEmailAddress; // no more than 256 characters 71 | $trans->Total = 50000; 72 | $trans->Comment = "Test Transaction"; // no more than 640 characters 73 | $trans->AddItem($item); // add the item to the transaction 74 | $trans->AddPayeeTransaction($ptrans1); // add the payee transactions to the transaction 75 | $trans->AddPayeeTransaction($ptrans2); 76 | 77 | // create the shipping address 78 | $shippingAddress = new ShippingAddressModel(); 79 | $shippingAddress->Country = "HU"; 80 | $shippingAddress->Region = null; 81 | $shippingAddress->City = "Budapest"; 82 | $shippingAddress->Zip = "1111"; 83 | $shippingAddress->Street = "Teszt utca 1."; 84 | $shippingAddress->Street2 = "1. emelet 1. ajto"; 85 | $shippingAddress->Street3 = ""; 86 | $shippingAddress->FullName = "Teszt Tibor"; 87 | 88 | // create the request model 89 | $psr = new PreparePaymentRequestModel(); 90 | $psr->GuestCheckout = true; // we allow guest checkout 91 | $psr->PaymentType = PaymentType::Immediate; // we want an immediate payment 92 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 93 | $psr->PaymentRequestId = "TESTPAY-03"; // no more than 100 characters 94 | $psr->PayerHint = "user@example.com"; // no more than 256 characters 95 | $psr->Locale = UILocale::EN; // the UI language will be English 96 | $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters 97 | $psr->ShippingAddress = $shippingAddress; 98 | $psr->Currency = Currency::HUF; 99 | $psr->AddTransaction($trans); // add the transaction to the payment 100 | 101 | // send the request 102 | $myPayment = $BC->PreparePayment($psr); 103 | 104 | if ($myPayment->RequestSuccessful === true) { 105 | // redirect the user to the Barion Smart Gateway 106 | header("Location: " . $BC::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); 107 | } -------------------------------------------------------------------------------- /examples/example_recurring_payment_with_3dsecure.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 64 | $item->Description = "A test item for payment"; // no more than 500 characters 65 | $item->Quantity = 1; 66 | $item->Unit = "pc"; // no more than 50 characters 67 | $item->UnitPrice = 19.95; 68 | $item->ItemTotal = 19.95; 69 | $item->SKU = "ITEM-01"; // no more than 100 characters 70 | 71 | // create the transaction 72 | $trans = new PaymentTransactionModel(); 73 | $trans->POSTransactionId = "TRANS-01"; 74 | $trans->Payee = $myEmailAddress; // no more than 256 characters 75 | $trans->Total = 19.95; 76 | $trans->Comment = "Test Transaction"; // no more than 640 characters 77 | $trans->AddItem($item); // add the item to the transaction 78 | 79 | // create the addresses 80 | $shippingAddress = new ShippingAddressModel(); 81 | $shippingAddress->Country = "DE"; 82 | $shippingAddress->Region = null; 83 | $shippingAddress->City = "Berlin"; 84 | $shippingAddress->Zip = "10243"; 85 | $shippingAddress->Street = "Karl-Marx-Allee 93A"; 86 | $shippingAddress->Street2 = "1. ebene"; 87 | $shippingAddress->Street3 = ""; 88 | $shippingAddress->FullName = "Thomas Testing"; 89 | 90 | $billingAddress = new BillingAddressModel(); 91 | $billingAddress->Country = "DE"; 92 | $billingAddress->Region = null; 93 | $billingAddress->City = "Berlin"; 94 | $billingAddress->Zip = "10243"; 95 | $billingAddress->Street = "Karl-Marx-Allee 93A"; 96 | $billingAddress->Street2 = "1. ebene"; 97 | $billingAddress->Street3 = ""; 98 | 99 | // 3DS information about the payer 100 | $payerAccountInfo = new PayerAccountInformationModel(); 101 | $payerAccountInfo->AccountId = "4690011905085639"; 102 | $payerAccountInfo->AccountCreated = $now; 103 | $payerAccountInfo->AccountCreationIndicator = AccountCreationIndicator::CreatedDuringThisTransaction; 104 | $payerAccountInfo->AccountLastChanged = $now; 105 | $payerAccountInfo->AccountChangeIndicator = AccountChangeIndicator::ChangedDuringThisTransaction; 106 | $payerAccountInfo->PasswordLastChanged = $now; 107 | $payerAccountInfo->PasswordChangeIndicator = PasswordChangeIndicator::NoChange; 108 | $payerAccountInfo->PurchasesInTheLastSixMonths = 6; 109 | $payerAccountInfo->ShippingAddressAdded = $now; 110 | $payerAccountInfo->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::ThisTransaction; 111 | $payerAccountInfo->PaymentMethodAdded = $now; 112 | $payerAccountInfo->PaymentMethodIndicator = PaymentMethodIndicator::ThisTransaction; 113 | $payerAccountInfo->ProvisionAttempts = 1; 114 | $payerAccountInfo->TransactionalActivityPerDay = 1; 115 | $payerAccountInfo->TransactionalActivityPerYear = 100; 116 | $payerAccountInfo->SuspiciousActivityIndicator = SuspiciousActivityIndicator::NoSuspiciousActivityObserved; 117 | 118 | // 3DS information about the purchase 119 | $purchaseInfo = new PurchaseInformationModel(); 120 | $purchaseInfo->DeliveryTimeframe = DeliveryTimeFrameType::OvernightShipping; 121 | $purchaseInfo->DeliveryEmailAddress = $payerEmail; 122 | $purchaseInfo->PreOrderDate = $now; 123 | $purchaseInfo->AvailabilityIndicator = AvailabilityIndicator::MerchandiseAvailable; 124 | $purchaseInfo->ReOrderIndicator = ReOrderIndicator::FirstTimeOrdered; 125 | $purchaseInfo->RecurringExpiry = "2099-12-31 23:59:59"; 126 | $purchaseInfo->RecurringFrequency = "0"; 127 | $purchaseInfo->ShippingAddressIndicator = ShippingAddressIndicator::ShipToCardholdersBillingAddress; 128 | $purchaseInfo->GiftCardPurchase = null; 129 | $purchaseInfo->PurchaseType = PurchaseType::GoodsAndServicePurchase; 130 | 131 | // create the request model 132 | $psr = new PreparePaymentRequestModel(); 133 | $psr->GuestCheckout = true; // we allow guest checkout 134 | $psr->PaymentType = PaymentType::Immediate; // we want an immediate payment 135 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 136 | $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters 137 | $psr->PayerHint = $payerEmail; // no more than 256 characters 138 | $psr->Locale = UILocale::EN; // the UI language will be English 139 | $psr->Currency = Currency::EUR; 140 | $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters 141 | $psr->AddTransaction($trans); // add the transaction to the payment 142 | 143 | // adding the 3d secure compliant parameters to the request 144 | $psr->ShippingAddress = $shippingAddress; 145 | $psr->BillingAddress = $billingAddress; 146 | $psr->CardHolderNameHint = "John Doe"; 147 | $psr->PayerPhoneNumber = "36301122334"; 148 | $psr->PayerWorkPhoneNumber = "36301122334"; 149 | $psr->PayerHomePhoneNumber = "36301122334"; 150 | $psr->PayerAccountInformation = $payerAccountInfo; 151 | $psr->PurchaseInformation = $purchaseInfo; 152 | $psr->ChallengePreference = ChallengePreference::NoPreference; 153 | 154 | // setting the properties related to token/recurring payment 155 | $psr->InitiateRecurrence = false; // InitiateRecurrence is false, because the webshop already has a token initialized 156 | $psr->RecurrenceId = "XXXXXXXX"; // replace this with the previously initialized token for this recurrence 157 | $psr->RecurrenceType = "RecurringPayment"; // RecurrenceType indicates that this is a recurring payment charge (for merchant-initiated, or simple token payments, use 'MerchantInitiatedPayment' instead) 158 | $psr->TraceId = "XXXXXXXX"; // replace this with the corresponding TraceId received when initializing the token payment! 159 | 160 | // send the request 161 | $paymentResponse = $BC->PreparePayment($psr); 162 | 163 | if ($paymentResponse->RequestSuccessful === true) { 164 | // NOTE: since this is a recurring payment execution, no redirect is taking place - the charge happens immediately 165 | // TODO: process the response found in $paymentResponse 166 | } -------------------------------------------------------------------------------- /examples/example_refund_payment.php: -------------------------------------------------------------------------------- 1 | AddTransaction($trans); 49 | 50 | $refundResult = $BC->RefundPayment($rr); 51 | 52 | if ($refundResult->RequestSuccessful) { 53 | // TODO: process the information contained in $refundResult 54 | } -------------------------------------------------------------------------------- /examples/example_start_delayedcapture_payment.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 46 | $item->Description = "A test item for delayed capture payment"; // no more than 500 characters 47 | $item->Quantity = 1; 48 | $item->Unit = "piece"; // no more than 50 characters 49 | $item->UnitPrice = 1000; 50 | $item->ItemTotal = 1000; 51 | $item->SKU = "ITEM-01"; // no more than 100 characters 52 | 53 | // create the transaction 54 | $trans = new PaymentTransactionModel(); 55 | $trans->POSTransactionId = "TRANS-01"; 56 | $trans->Payee = $myEmailAddress; // no more than 256 characters 57 | $trans->Total = 1000; 58 | $trans->Comment = "Test Transaction"; // no more than 640 characters 59 | $trans->AddItem($item); // add the item to the transaction 60 | 61 | // create the shipping address 62 | $shippingAddress = new ShippingAddressModel(); 63 | $shippingAddress->Country = "HU"; 64 | $shippingAddress->Region = null; 65 | $shippingAddress->City = "Budapest"; 66 | $shippingAddress->Zip = "1111"; 67 | $shippingAddress->Street = "Teszt utca 1."; 68 | $shippingAddress->Street2 = "1. emelet 1. ajto"; 69 | $shippingAddress->Street3 = ""; 70 | $shippingAddress->FullName = "Teszt Tibor"; 71 | 72 | // create the request model 73 | $psr = new PreparePaymentRequestModel(); 74 | $psr->GuestCheckout = true; // we allow guest checkout 75 | $psr->PaymentType = PaymentType::DelayedCapture; // we want a delayed capture payment 76 | $psr->DelayedCapturePeriod = "3:00:00:00"; // capture is delayed for 3 days 77 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 78 | $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters 79 | $psr->PayerHint = "user@example.com"; // no more than 256 characters 80 | $psr->Locale = UILocale::EN; // the UI language will be English 81 | $psr->Currency = Currency::HUF; 82 | $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters 83 | $psr->ShippingAddress = $shippingAddress; 84 | $psr->AddTransaction($trans); // add the transaction to the payment 85 | 86 | // send the request 87 | $myPayment = $BC->PreparePayment($psr); 88 | 89 | if ($myPayment->RequestSuccessful === true) { 90 | // redirect the user to the Barion Smart Gateway 91 | header("Location: " . $BC::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); 92 | } -------------------------------------------------------------------------------- /examples/example_start_immediate_payment.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 46 | $item->Description = "A test item for payment"; // no more than 500 characters 47 | $item->Quantity = 1; 48 | $item->Unit = "piece"; // no more than 50 characters 49 | $item->UnitPrice = 1000; 50 | $item->ItemTotal = 1000; 51 | $item->SKU = "ITEM-01"; // no more than 100 characters 52 | 53 | // create the transaction 54 | $trans = new PaymentTransactionModel(); 55 | $trans->POSTransactionId = "TRANS-01"; 56 | $trans->Payee = $myEmailAddress; // no more than 256 characters 57 | $trans->Total = 1000; 58 | $trans->Comment = "Test Transaction"; // no more than 640 characters 59 | $trans->AddItem($item); // add the item to the transaction 60 | 61 | // create the shipping address 62 | $shippingAddress = new ShippingAddressModel(); 63 | $shippingAddress->Country = "HU"; 64 | $shippingAddress->Region = null; 65 | $shippingAddress->City = "Budapest"; 66 | $shippingAddress->Zip = "1111"; 67 | $shippingAddress->Street = "Teszt utca 1."; 68 | $shippingAddress->Street2 = "1. emelet 1. ajto"; 69 | $shippingAddress->Street3 = ""; 70 | $shippingAddress->FullName = "Teszt Tibor"; 71 | 72 | // create the request model 73 | $psr = new PreparePaymentRequestModel(); 74 | $psr->GuestCheckout = true; // we allow guest checkout 75 | $psr->PaymentType = PaymentType::Immediate; // we want an immediate payment 76 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 77 | $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters 78 | $psr->PayerHint = "user@example.com"; // no more than 256 characters 79 | $psr->Locale = UILocale::EN; // the UI language will be English 80 | $psr->Currency = Currency::HUF; 81 | $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters 82 | $psr->ShippingAddress = $shippingAddress; 83 | $psr->AddTransaction($trans); // add the transaction to the payment 84 | 85 | // send the request 86 | $myPayment = $BC->PreparePayment($psr); 87 | 88 | if ($myPayment->RequestSuccessful === true) { 89 | // redirect the user to the Barion Smart Gateway 90 | header("Location: " . $BC::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); 91 | } -------------------------------------------------------------------------------- /examples/example_start_payment_with_3dsecure_parameters.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 69 | $item->Description = "A test item for payment"; // no more than 500 characters 70 | $item->Quantity = 1; 71 | $item->Unit = "pc"; // no more than 50 characters 72 | $item->UnitPrice = 75; 73 | $item->ItemTotal = 75; 74 | $item->SKU = "ITEM-01"; // no more than 100 characters 75 | 76 | // create the transaction 77 | $trans = new PaymentTransactionModel(); 78 | $trans->POSTransactionId = "TRANS-01"; 79 | $trans->Payee = $myEmailAddress; // no more than 256 characters 80 | $trans->Total = 75; 81 | $trans->Comment = "Test Transaction"; // no more than 640 characters 82 | $trans->AddItem($item); // add the item to the transaction 83 | 84 | // create the addresses 85 | $shippingAddress = new ShippingAddressModel(); 86 | $shippingAddress->Country = "DE"; 87 | $shippingAddress->Region = null; 88 | $shippingAddress->City = "Berlin"; 89 | $shippingAddress->Zip = "10243"; 90 | $shippingAddress->Street = "Karl-Marx-Allee 93A"; 91 | $shippingAddress->Street2 = "1. ebene"; 92 | $shippingAddress->Street3 = ""; 93 | $shippingAddress->FullName = "Thomas Testing"; 94 | 95 | $billingAddress = new BillingAddressModel(); 96 | $billingAddress->Country = "DE"; 97 | $billingAddress->Region = null; 98 | $billingAddress->City = "Berlin"; 99 | $billingAddress->Zip = "10243"; 100 | $billingAddress->Street = "Karl-Marx-Allee 93A"; 101 | $billingAddress->Street2 = "1. ebene"; 102 | $billingAddress->Street3 = ""; 103 | 104 | // 3DS information about the payer 105 | $payerAccountInfo = new PayerAccountInformationModel(); 106 | $payerAccountInfo->AccountId = "4690011905085639"; 107 | $payerAccountInfo->AccountCreated = $now; 108 | $payerAccountInfo->AccountCreationIndicator = AccountCreationIndicator::CreatedDuringThisTransaction; 109 | $payerAccountInfo->AccountLastChanged = $now; 110 | $payerAccountInfo->AccountChangeIndicator = AccountChangeIndicator::ChangedDuringThisTransaction; 111 | $payerAccountInfo->PasswordLastChanged = $now; 112 | $payerAccountInfo->PasswordChangeIndicator = PasswordChangeIndicator::NoChange; 113 | $payerAccountInfo->PurchasesInTheLastSixMonths = 6; 114 | $payerAccountInfo->ShippingAddressAdded = $now; 115 | $payerAccountInfo->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::ThisTransaction; 116 | $payerAccountInfo->PaymentMethodAdded = $now; 117 | $payerAccountInfo->PaymentMethodIndicator = PaymentMethodIndicator::ThisTransaction; 118 | $payerAccountInfo->ProvisionAttempts = 1; 119 | $payerAccountInfo->TransactionalActivityPerDay = 1; 120 | $payerAccountInfo->TransactionalActivityPerYear = 100; 121 | $payerAccountInfo->SuspiciousActivityIndicator = SuspiciousActivityIndicator::NoSuspiciousActivityObserved; 122 | 123 | // 3DS information about the purchase 124 | $purchaseInfo = new PurchaseInformationModel(); 125 | $purchaseInfo->DeliveryTimeframe = DeliveryTimeFrameType::OvernightShipping; 126 | $purchaseInfo->DeliveryEmailAddress = $payerEmail; 127 | $purchaseInfo->PreOrderDate = $now; 128 | $purchaseInfo->AvailabilityIndicator = AvailabilityIndicator::MerchandiseAvailable; 129 | $purchaseInfo->ReOrderIndicator = ReOrderIndicator::FirstTimeOrdered; 130 | $purchaseInfo->RecurringExpiry = "2099-12-31 23:59:59"; 131 | $purchaseInfo->RecurringFrequency = "0"; 132 | $purchaseInfo->ShippingAddressIndicator = ShippingAddressIndicator::ShipToCardholdersBillingAddress; 133 | $purchaseInfo->GiftCardPurchase = null; 134 | $purchaseInfo->PurchaseType = PurchaseType::GoodsAndServicePurchase; 135 | $purchaseInfo->PurchaseDate = "2021-05-01 10:00:00"; 136 | 137 | // create the request model 138 | $psr = new PreparePaymentRequestModel(); 139 | $psr->GuestCheckout = true; // we allow guest checkout 140 | $psr->PaymentType = PaymentType::Immediate; // we want an immediate payment 141 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 142 | $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters 143 | $psr->PayerHint = $payerEmail; // no more than 256 characters 144 | $psr->Locale = UILocale::EN; // the UI language will be English 145 | $psr->Currency = Currency::EUR; 146 | $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters 147 | $psr->AddTransaction($trans); // add the transaction to the payment 148 | 149 | // adding the 3d secure compliant parameters to the request 150 | $psr->ShippingAddress = $shippingAddress; 151 | $psr->BillingAddress = $billingAddress; 152 | $psr->CardHolderNameHint = "John Doe"; 153 | $psr->PayerPhoneNumber = "36301122334"; 154 | $psr->PayerWorkPhoneNumber = "36301122334"; 155 | $psr->PayerHomePhoneNumber = "36301122334"; 156 | $psr->PayerAccountInformation = $payerAccountInfo; 157 | $psr->PurchaseInformation = $purchaseInfo; 158 | $psr->ChallengePreference = ChallengePreference::NoPreference; 159 | 160 | // send the request 161 | $myPayment = $BC->PreparePayment($psr); 162 | 163 | if ($myPayment->RequestSuccessful === true) { 164 | // redirect the user to the Barion Smart Gateway 165 | header("Location: " . $BC::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); 166 | } -------------------------------------------------------------------------------- /examples/example_start_reservation_payment.php: -------------------------------------------------------------------------------- 1 | Name = "TestItem"; // no more than 250 characters 46 | $item1->Description = "A test item for payment"; // no more than 500 characters 47 | $item1->Quantity = 1; 48 | $item1->Unit = "piece"; // no more than 50 characters 49 | $item1->UnitPrice = 1000; 50 | $item1->ItemTotal = 1000; 51 | $item1->SKU = "ITEM-01"; // no more than 100 characters 52 | 53 | $item2 = new ItemModel(); 54 | $item2->Name = "AnotherTestItem"; // no more than 250 characters 55 | $item2->Description = "Another test item for payment"; // no more than 500 characters 56 | $item2->Quantity = 2; 57 | $item2->Unit = "piece"; // no more than 50 characters 58 | $item2->UnitPrice = 250; 59 | $item2->ItemTotal = 250; 60 | $item2->SKU = "ITEM-02"; // no more than 100 characters 61 | 62 | // create the transaction 63 | $trans = new PaymentTransactionModel(); 64 | $trans->POSTransactionId = "TRANS-02"; 65 | $trans->Payee = $myEmailAddress; // no more than 256 characters 66 | $trans->Total = 1500; 67 | $trans->Comment = "Test Transaction"; // no more than 640 characters 68 | $trans->AddItem($item1); // add the items to the transaction 69 | $trans->AddItem($item2); 70 | 71 | // create the shipping address 72 | $shippingAddress = new ShippingAddressModel(); 73 | $shippingAddress->Country = "HU"; 74 | $shippingAddress->Region = null; 75 | $shippingAddress->City = "Budapest"; 76 | $shippingAddress->Zip = "1111"; 77 | $shippingAddress->Street = "Teszt utca 1."; 78 | $shippingAddress->Street2 = "1. emelet 1. ajto"; 79 | $shippingAddress->Street3 = ""; 80 | $shippingAddress->FullName = "Teszt Tibor"; 81 | 82 | // create the request model 83 | $psr = new PreparePaymentRequestModel(); 84 | $psr->GuestCheckout = true; // we allow guest checkout 85 | $psr->PaymentType = PaymentType::Reservation; // we want an immediate payment 86 | $psr->ReservationPeriod = "1:00:00:00"; // money is reserved for one day 87 | $psr->PaymentWindow = "00:20:00"; // the payment must be completed in 20 minutes 88 | $psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted 89 | $psr->PaymentRequestId = "TESTPAY-02"; // no more than 100 characters 90 | $psr->PayerHint = "user@example.com"; // no more than 256 characters 91 | $psr->Locale = UILocale::EN; // the UI language will be English 92 | $psr->Currency = Currency::HUF; 93 | $psr->OrderNumber = "ORDER-0002"; // no more than 100 characters 94 | $psr->ShippingAddress = $shippingAddress; 95 | $psr->AddTransaction($trans); // add the transaction to the payment 96 | 97 | // send the request 98 | $myPayment = $BC->PreparePayment($psr); 99 | 100 | if ($myPayment->RequestSuccessful === true) { 101 | // redirect the user to the Barion Smart Gateway 102 | header("Location: " . $BC::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); 103 | } -------------------------------------------------------------------------------- /library/Enumerations/BarionEnvironment.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum BarionEnvironment : string 22 | { 23 | case Test = "test"; 24 | case Prod = "prod"; 25 | } -------------------------------------------------------------------------------- /library/Enumerations/CardType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum CardType : string 22 | { 23 | case Unknown = "Unknown"; 24 | case Mastercard = "Mastercard"; 25 | case Maestro = "Maestro"; 26 | case Visa = "Visa"; 27 | case Electron = "Electron"; 28 | case AmericanExpress = "AmericanExpress"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/Currency.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum Currency : string 22 | { 23 | case Unspecified = "Unspecified"; 24 | case HUF = "HUF"; 25 | case EUR = "EUR"; 26 | case USD = "USD"; 27 | case CZK = "CZK"; 28 | } -------------------------------------------------------------------------------- /library/Enumerations/FundingSourceType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum FundingSourceType : string 22 | { 23 | case All = "All"; 24 | case Balance = "Balance"; 25 | case Bankcard = "Bankcard"; 26 | case BankTransfer = "BankTransfer"; 27 | case ApplePay = "ApplePay"; 28 | case GooglePay = "GooglePay"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/PaymentStatus.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum PaymentStatus : string 22 | { 23 | case Prepared = "Prepared"; 24 | case Started = "Started"; 25 | case InProgress = "InProgress"; 26 | case Waiting = "Waiting"; 27 | case Reserved = "Reserved"; 28 | case Authorized = "Authorized"; 29 | case Canceled = "Canceled"; 30 | case Succeeded = "Succeeded"; 31 | case Failed = "Failed"; 32 | case PartiallySucceeded = "PartiallySucceeded"; 33 | case Expired = "Expired"; 34 | } -------------------------------------------------------------------------------- /library/Enumerations/PaymentType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum PaymentType : string 22 | { 23 | case Immediate = "Immediate"; 24 | case Reservation = "Reservation"; 25 | case DelayedCapture = "DelayedCapture"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/QRCodeSize.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum QRCodeSize : string 22 | { 23 | case Small = "Small"; 24 | case Normal = "Normal"; 25 | case Large = "Large"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/RecurrenceResult.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum RecurrenceResult : string 22 | { 23 | case None = "None"; 24 | case Successful = "Successful"; 25 | case Failed = "Failed"; 26 | case NotFound = "NotFound"; 27 | case ThreeDSAuthenticationRequired = "ThreeDSAuthenticationRequired"; 28 | } 29 | -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/AccountChangeIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum AccountChangeIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; 25 | case LessThan30Days = "LessThan30Days"; 26 | case Between30And60Days = "Between30And60Days"; 27 | case MoreThan60Days = "MoreThan60Days"; 28 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/AccountCreationIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum AccountCreationIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case NoAccount = "NoAccount"; 25 | case CreatedDuringThisTransaction = "CreatedDuringThisTransaction"; 26 | case LessThan30Days = "LessThan30Days"; 27 | case Between30And60Days = "Between30And60Days"; 28 | case MoreThan60Days = "MoreThan60Days"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/AvailabilityIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum AvailabilityIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case MerchandiseAvailable = "MerchandiseAvailable"; 25 | case FutureAvailability = "FutureAvailability"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/ChallengePreference.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum ChallengePreference : string 22 | { 23 | case Unspecified = ""; 24 | case NoPreference = "NoPreference"; 25 | case ChallengeRequired = "ChallengeRequired"; 26 | case NoChallengeNeeded = "NoChallengeNeeded"; 27 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/DeliveryTimeframeType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum DeliveryTimeframeType : string 22 | { 23 | case Unspecified = ""; 24 | case ElectronicDelivery = "ElectronicDelivery"; 25 | case SameDayShipping = "SameDayShipping"; 26 | case OvernightShipping = "OvernightShipping"; 27 | case TwoDayOrMoreShipping = "TwoDayOrMoreShipping"; 28 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/PasswordChangeIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum PasswordChangeIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case NoChange = "NoChange"; 25 | case ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; 26 | case LessThan30Days = "LessThan30Days"; 27 | case Between30And60Days = "Between30And60Days"; 28 | case MoreThan60Days = "MoreThan60Days"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/PaymentMethodIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum PaymentMethodIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case NoAccount = "NoAccount"; 25 | case ThisTransaction = "ThisTransaction"; 26 | case LessThan30Days = "LessThan30Days"; 27 | case Between30And60Days = "Between30And60Days"; 28 | case MoreThan60Days = "MoreThan60Days"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/PurchaseType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum PurchaseType : string 22 | { 23 | case Unspecified = ""; 24 | case GoodsAndServicePurchase = "GoodsAndServicePurchase"; 25 | case CheckAcceptance = "CheckAcceptance"; 26 | case AccountFunding = "AccountFunding"; 27 | case QuasiCashTransaction = "QuasiCashTransaction"; 28 | case PrePaidVacationAndLoan = "PrePaidVacationAndLoan"; 29 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/ReOrderIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum ReOrderIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case FirstTimeOrdered = "FirstTimeOrdered"; 25 | case ReOrdered = "ReOrdered"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/RecurrenceType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum RecurrenceType : string 22 | { 23 | case MerchantInitiatedPayment = "MerchantInitiatedPayment"; 24 | case OneClickPayment = "OneClickPayment"; 25 | case RecurringPayment = "RecurringPayment"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/ShippingAddressIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum ShippingAddressIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case ShipToCardholdersBillingAddress = "ShipToCardholdersBillingAddress"; 25 | case ShipToAnotherVerifiedAddress = "ShipToAnotherVerifiedAddress"; 26 | case ShipToDifferentAddress = "ShipToDifferentAddress"; 27 | case ShipToStore = "ShipToStore"; 28 | case DigitalGoods = "DigitalGoods"; 29 | case TravelAndEventTickets = "TravelAndEventTickets"; 30 | case Other = "Other"; 31 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/ShippingAddressUsageIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum ShippingAddressUsageIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case ThisTransaction = "ThisTransaction"; 25 | case LessThan30Days = "LessThan30Days"; 26 | case Between30And60Days = "Between30And60Days"; 27 | case MoreThan60Days = "MoreThan60Days"; 28 | } -------------------------------------------------------------------------------- /library/Enumerations/ThreeDSecure/SuspiciousActivityIndicator.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations\ThreeDSecure; 20 | 21 | enum SuspiciousActivityIndicator : string 22 | { 23 | case Unspecified = ""; 24 | case NoSuspiciousActivityObserved = "NoSuspiciousActivityObserved"; 25 | case SuspiciousActivityObserved = "SuspiciousActivityObserved"; 26 | } -------------------------------------------------------------------------------- /library/Enumerations/TransactionStatus.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum TransactionStatus : string 22 | { 23 | case Prepared = "Prepared"; 24 | case Started = "Started"; 25 | case Succeeded = "Succeeded"; 26 | case Timeout = "Timeout"; 27 | case ShopIsDeleted = "ShopIsDeleted"; 28 | case ShopIsClosed = "ShopIsClosed"; 29 | case Rejected = "Rejected"; 30 | case RejectedByShop = "RejectedByShop"; 31 | case Storno = "Storno"; 32 | case Reserved = "Reserved"; 33 | case Deleted = "Deleted"; 34 | case Expired = "Expired"; 35 | case Authorized = "Authorized"; 36 | case Reversed = "Reversed"; 37 | case InvalidPaymentRecord = "InvalidPaymentRecord"; 38 | case PaymentTimeOut = "PaymentTimeOut"; 39 | case InvalidPaymentStatus = "InvalidPaymentStatus"; 40 | case PaymentSenderOrRecipientIsInvalid = "PaymentSenderOrRecipientIsInvalid"; 41 | case Unknown = "Unknown"; 42 | } -------------------------------------------------------------------------------- /library/Enumerations/TransactionType.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum TransactionType : string 22 | { 23 | case Commission = "Commission"; 24 | case Shop = "Shop"; 25 | case TransferToExistingUser = "TransferToExistingUser"; 26 | case TransferToTechnicalAccount = "TransferToTechnicalAccount"; 27 | case TransferFromTechnicalAccount = "TransferFromTechnicalAccount"; 28 | case Storno = "Storno"; 29 | case WithdrawFee = "WithdrawFee"; 30 | case ClosureFee = "ClosureFee"; 31 | case StornoBankTransferFee = "StornoBankTransferFee"; 32 | case CashDepositFee = "CashDepositFee"; 33 | case ForeignDepositFee = "ForeignDepositFee"; 34 | case ForeignWithdrawFee = "ForeignWithdrawFee"; 35 | case ForeignClosureFee = "ForeignClosureFee"; 36 | case BankTransferWithdrawFeeStorno = "BankTransferWithdrawFeeStorno"; 37 | case Reserve = "Reserve"; 38 | case StornoReserve = "StornoReserve"; 39 | case CardTopUpFee = "CardTopUpFee"; 40 | case CardProcessingFee = "CardProcessingFee"; 41 | case GatewayFee = "GatewayFee"; 42 | case CardProcessingFeeStorno = "CardProcessingFeeStorno"; 43 | case Unspecified = "Unspecified"; 44 | case In = "In"; 45 | case Withdraw = "Withdraw"; 46 | case CashDeposit = "CashDeposit"; 47 | case ForeignDeposit = "ForeignDeposit"; 48 | case ForeignBankTransferFee = "ForeignBankTransferFee"; 49 | case CashBankTransferFee = "CashBankTransferFee"; 50 | case CustodyFee = "CustodyFee"; 51 | case ForeignWithdraw = "ForeignWithdraw"; 52 | case TransferBack = "TransferBack"; 53 | case CardTopUp = "CardTopUp"; 54 | case CardTopUpBankFee = "CardTopUpBankFee"; 55 | case EmoneySubstractionRestore = "EmoneySubstractionRestore"; 56 | case CardPayment = "CardPayment"; 57 | case Refund = "Refund"; 58 | case RefundToBankCard = "RefundToBankCard"; 59 | case StornoUnSuccessfulRefundToBankCard = "StornoUnSuccessfulRefundToBankCard"; 60 | case UnderReview = "UnderReview"; 61 | case ReleaseReview = "ReleaseReview"; 62 | case BankTransferPayment = "BankTransferPayment"; 63 | case RefundToBankAccount = "RefundToBankAccount"; 64 | case StornoUnSuccessfulRefundToBankAccount = "StornoUnSuccessfulRefundToBankAccount"; 65 | case BankTransferPaymentFee = "BankTransferPaymentFee"; 66 | case BarionBalanceProcessingFee = "BarionBalanceProcessingFee"; 67 | } -------------------------------------------------------------------------------- /library/Enumerations/UILocale.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Enumerations; 20 | 21 | enum UILocale : string 22 | { 23 | case HU = "hu-HU"; 24 | case EN = "en-US"; 25 | case DE = "de-DE"; 26 | case SL = "sl-SI"; 27 | case SK = "sk-SK"; 28 | case FR = "fr-FR"; 29 | case CZ = "cs-CZ"; 30 | case GR = "el-GR"; 31 | case ES = "es-ES"; 32 | } -------------------------------------------------------------------------------- /library/Exceptions/BarionException.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Exceptions; 20 | 21 | use Exception; 22 | 23 | class BarionException extends Exception 24 | { 25 | /** 26 | * BarionException constructor. 27 | * 28 | * @param string $message 29 | * @param int $errorCode 30 | */ 31 | public function __construct(string $message = "", int $errorCode = 0) { 32 | parent::__construct($message, $errorCode); 33 | } 34 | } -------------------------------------------------------------------------------- /library/Helpers/JSON.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Helpers; 20 | 21 | class JSON { 22 | 23 | /** 24 | * Gets the value of the specified property from the JSON as a string. 25 | * 26 | * @param mixed $json The JSON 27 | * @param string $propertyName 28 | * @return ?string The value of the property as string 29 | */ 30 | public static function getString(mixed $json, string $propertyName): ?string 31 | { 32 | if (!isset($json[$propertyName])) { 33 | return null; 34 | } 35 | 36 | $value = $json[$propertyName]; 37 | 38 | if (is_array($value) || is_object($value)) { 39 | return null; 40 | } 41 | 42 | return strval($value); 43 | } 44 | 45 | /** 46 | * Gets the value of the specified property from the JSON as an integer number. 47 | * 48 | * @param mixed $json The JSON 49 | * @param string $propertyName 50 | * @return ?int The value of the property as int 51 | */ 52 | public static function getInt(mixed $json, string $propertyName): ?int 53 | { 54 | if (!isset($json[$propertyName])) { 55 | return null; 56 | } 57 | 58 | $value = $json[$propertyName]; 59 | 60 | if (is_array($value) || is_object($value)) { 61 | return null; 62 | } 63 | 64 | return intval($value); 65 | } 66 | 67 | 68 | /** 69 | * Gets the value of the specified property from the JSON as a floating point number. 70 | * 71 | * @param mixed $json The JSON 72 | * @param string $propertyName 73 | * @return ?float The value of the property as float 74 | */ 75 | public static function getFloat(mixed $json, string $propertyName): ?float 76 | { 77 | if (!isset($json[$propertyName])) { 78 | return null; 79 | } 80 | 81 | $value = $json[$propertyName]; 82 | 83 | if (is_array($value) || is_object($value)) { 84 | return null; 85 | } 86 | 87 | return floatval($value); 88 | } 89 | 90 | /** 91 | * Gets the value of the specified property from the JSON as a boolean. 92 | * 93 | * @param mixed $json The JSON 94 | * @param string $propertyName 95 | * @return ?bool The value of the property as bool 96 | */ 97 | public static function getBool(mixed $json, string $propertyName): ?bool 98 | { 99 | if (!isset($json[$propertyName])) { 100 | return null; 101 | } 102 | 103 | $value = $json[$propertyName]; 104 | 105 | if (is_array($value) || is_object($value)) { 106 | return null; 107 | } 108 | 109 | return (bool)$value; 110 | } 111 | 112 | /** 113 | * Gets the value of the specified property from the JSON as an associative array. 114 | * 115 | * @param mixed $json The JSON 116 | * @param string $propertyName 117 | * @return ?array The value of the property as an array 118 | */ 119 | public static function getArray(mixed $json, string $propertyName): ?array 120 | { 121 | if (!isset($json[$propertyName])) { 122 | return null; 123 | } 124 | 125 | $value = $json[$propertyName]; 126 | 127 | if (is_array($value)) { 128 | return $value; 129 | } 130 | 131 | return null; 132 | } 133 | 134 | /** 135 | * Gets the value of the specified property from the JSON as a standard PHP object. 136 | * 137 | * @param mixed $json The JSON 138 | * @param string $propertyName 139 | * @return ?object The value of the property as object 140 | */ 141 | public static function getObject(mixed $json, string $propertyName): ?object 142 | { 143 | if (!isset($json[$propertyName])) { 144 | return null; 145 | } 146 | 147 | $value = $json[$propertyName]; 148 | 149 | if (is_object($value)) { 150 | return $value; 151 | } 152 | 153 | return null; 154 | } 155 | 156 | } -------------------------------------------------------------------------------- /library/Helpers/StringExtension.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Helpers; 20 | 21 | class StringExtension { 22 | 23 | /** 24 | * Helper function to decide if a given string value is null or empty. 25 | * 26 | * @param ?string $string 27 | * @return bool 28 | */ 29 | public static function isNullOrEmpty(?string $string) : bool 30 | { 31 | return ($string === null || trim($string) === ''); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /library/Interfaces/IBarionModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Interfaces; 20 | 21 | /* 22 | * Base model interface. 23 | */ 24 | interface IBarionModel 25 | { 26 | /** 27 | * Assemble the model from an array representing standard JSON stucture. 28 | * 29 | * @param array $json Associative array returned by json_decode. 30 | * @return void 31 | */ 32 | public function fromJson(array $json) : void; 33 | } -------------------------------------------------------------------------------- /library/Interfaces/IItemContainer.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Interfaces; 20 | 21 | /** 22 | * Interface describing a model that can contain items. 23 | * 24 | * @method void AddItem(object $item) 25 | * @method void AddItems(array $items) 26 | */ 27 | interface IItemContainer 28 | { 29 | 30 | } -------------------------------------------------------------------------------- /library/Interfaces/IPayeeTransactionContainer.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Interfaces; 20 | 21 | /** 22 | * Interface describing a model that can contain payee transactions. 23 | * 24 | * @method void AddPayeeTransaction(object $transaction) 25 | * @method void AddPayeeTransactions(array $transactions) 26 | */ 27 | interface IPayeeTransactionContainer 28 | { 29 | 30 | } -------------------------------------------------------------------------------- /library/Interfaces/IPaymentTransactionContainer.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Interfaces; 20 | 21 | /** 22 | * Interface describing a class that can contain payment transactions. 23 | * 24 | * @method void AddTransaction(object $transaction) 25 | * @method void AddTransactions(array $transactions) 26 | */ 27 | interface IPaymentTransactionContainer 28 | { 29 | 30 | } -------------------------------------------------------------------------------- /library/Models/BaseRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models; 20 | 21 | /** 22 | * Base model of all requests sent towards the Barion API. 23 | */ 24 | class BaseRequestModel 25 | { 26 | /** 27 | * The secret key of the shop that is calling the Barion API, used for authentication. 28 | * 29 | * @var string 30 | */ 31 | public string $POSKey; 32 | } -------------------------------------------------------------------------------- /library/Models/BaseResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models; 20 | 21 | use Barion\Helpers\JSON; 22 | use Barion\Models\Error\ApiErrorModel; 23 | 24 | class BaseResponseModel 25 | { 26 | /** 27 | * Array of API error models. 28 | * 29 | * @var array 30 | */ 31 | public array $Errors; 32 | 33 | /** 34 | * Flag indicating that the request itself was successful. 35 | * IMPORTANT: This only means that the Barion API communication took place without errors. It does not inform the caller about the result of an intended action. * 36 | * 37 | * @var bool 38 | */ 39 | public bool $RequestSuccessful; 40 | 41 | function __construct() 42 | { 43 | $this->Errors = array(); 44 | $this->RequestSuccessful = false; 45 | } 46 | 47 | /** 48 | * Build model from a JSON array. 49 | * 50 | * @param array $json 51 | * @return void 52 | */ 53 | public function fromJson(array $json) : void 54 | { 55 | if (!empty($json)) { 56 | $this->RequestSuccessful = true; 57 | if (!array_key_exists('Errors', $json) || !empty(JSON::getArray($json, 'Errors'))) { 58 | $this->RequestSuccessful = false; 59 | } 60 | 61 | if (array_key_exists('Errors', $json)) { 62 | $errors = JSON::getArray($json, 'Errors'); 63 | if (is_array($errors) && !empty($errors)) { 64 | foreach ($errors as $key => $error) { 65 | $apiError = new ApiErrorModel(); 66 | $apiError->fromJson($error); 67 | $this->Errors[] = $apiError; 68 | } 69 | } 70 | } else { 71 | $internalError = new ApiErrorModel(); 72 | $internalError->ErrorCode = "500"; 73 | if (array_key_exists('ExceptionMessage', $json)) { 74 | $internalError->Title = JSON::getString($json, 'ExceptionMessage'); 75 | $internalError->Description = JSON::getString($json, 'ExceptionType'); 76 | } else { 77 | $internalError->Title = "Internal Server Error"; 78 | } 79 | 80 | $this->Errors[] = $internalError; 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /library/Models/Common/BankCardModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Common; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model representing a bank card that was used to complete a payment on the Barion Smart Gateway. 26 | */ 27 | class BankCardModel implements IBarionModel 28 | { 29 | /** 30 | * The last 4 digits of the bank card number. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $MaskedPan; 35 | 36 | /** 37 | * The type of the card, containing the name of the issuer network. 38 | * Example: Visa, Mastercard, etc. 39 | * 40 | * @var ?string 41 | */ 42 | public ?string $BankCardType; 43 | 44 | /** 45 | * The expiration year of the card in a 2-digit representation. 46 | * 47 | * @var ?string 48 | */ 49 | public ?string $ValidThruYear; 50 | 51 | /** 52 | * The expiration month of the card in a 2-digit representation. 53 | * 54 | * @var ?string 55 | */ 56 | public ?string $ValidThruMonth; 57 | 58 | function __construct() 59 | { 60 | $this->MaskedPan = ""; 61 | $this->BankCardType = ""; 62 | $this->ValidThruYear = ""; 63 | $this->ValidThruMonth = ""; 64 | } 65 | 66 | /** 67 | * Build model from a JSON array. 68 | * 69 | * @param array $json 70 | * @return void 71 | */ 72 | public function fromJson(array $json) : void 73 | { 74 | if (!empty($json)) { 75 | $this->MaskedPan = JSON::getString($json, 'MaskedPan'); 76 | $this->BankCardType = JSON::getString($json, 'BankCardType'); 77 | $this->ValidThruYear = JSON::getString($json, 'ValidThruYear'); 78 | $this->ValidThruMonth = JSON::getString($json, 'ValidThruMonth'); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /library/Models/Common/FundingInformationModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Common; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model containing information about the funding source that was used to attempt to complete a payment on the Barion Smart Gateway. 26 | */ 27 | class FundingInformationModel implements IBarionModel 28 | { 29 | /** 30 | * The object containing bank card details. 31 | * 32 | * @var object 33 | */ 34 | public object $BankCard; 35 | 36 | /** 37 | * The authorization code received from the bank system during the card payment. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $AuthorizationCode; 42 | 43 | /** 44 | * The process result received from the bank system during the card payment. 45 | * 46 | * @var ?string 47 | */ 48 | public ?string $ProcessResult; 49 | 50 | function __construct() 51 | { 52 | $this->BankCard = new BankCardModel(); 53 | $this->AuthorizationCode = null; 54 | $this->ProcessResult = null; 55 | } 56 | 57 | /** 58 | * Build model from a JSON array. 59 | * 60 | * @param array $json 61 | * @return void 62 | */ 63 | public function fromJson(array $json) : void 64 | { 65 | if (!empty($json)) { 66 | $this->BankCard = new BankCardModel(); 67 | $this->BankCard->fromJson(JSON::getArray($json, 'BankCard') ?? array()); 68 | $this->AuthorizationCode = JSON::getString($json, 'AuthorizationCode'); 69 | $this->ProcessResult = JSON::getString($json, 'ProcessResult'); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /library/Models/Common/ItemModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Common; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model representing an item included in a payment transaction. 26 | */ 27 | class ItemModel implements IBarionModel 28 | { 29 | /** 30 | * The name of the item. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $Name; 35 | 36 | /** 37 | * The decription of the item. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $Description; 42 | 43 | /** 44 | * The quantity purchased during the transaction. 45 | * 46 | * @var ?float 47 | */ 48 | public ?float $Quantity; 49 | 50 | /** 51 | * The unit name, if applicable. 52 | * Example: piece, month, kilograms, etc. 53 | * 54 | * @var ?string 55 | */ 56 | public ?string $Unit; 57 | 58 | /** 59 | * Price of one unit of the item. 60 | * 61 | * @var ?float 62 | */ 63 | public ?float $UnitPrice; 64 | 65 | /** 66 | * The total amount paid for the item. 67 | * 68 | * @var ?float 69 | */ 70 | public ?float $ItemTotal; 71 | 72 | /** 73 | * Storage Keeping Unit, an internal identifier specified by the shop. 74 | * 75 | * @var ?string 76 | */ 77 | public ?string $SKU; 78 | 79 | function __construct() 80 | { 81 | $this->Name = null; 82 | $this->Description = null; 83 | $this->Quantity = null; 84 | $this->Unit = null; 85 | $this->UnitPrice = null; 86 | $this->ItemTotal = null; 87 | $this->SKU = null; 88 | } 89 | 90 | public function fromJson(array $json) : void 91 | { 92 | if (!empty($json)) { 93 | $this->Name = JSON::getString($json, 'Name'); 94 | $this->Description = JSON::getString($json, 'Description'); 95 | $this->Quantity = JSON::getFloat($json, 'Quantity'); 96 | $this->Unit = JSON::getString($json, 'Unit'); 97 | $this->UnitPrice = JSON::getFloat($json, 'UnitPrice'); 98 | $this->ItemTotal = JSON::getFloat($json, 'ItemTotal'); 99 | $this->SKU = JSON::getString($json, 'SKU'); 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /library/Models/Common/UserModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Common; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model containing information about a user partaking in a Barion Smart Gateway payment. 26 | */ 27 | class UserModel implements IBarionModel 28 | { 29 | /** 30 | * The name of the user. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $Name; 35 | 36 | /** 37 | * The e-mail address of the user. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $Email; 42 | 43 | function __construct() 44 | { 45 | $this->Name = null; 46 | $this->Email = null; 47 | } 48 | 49 | /** 50 | * Build model from a JSON array. 51 | * 52 | * @param array $json 53 | * @return void 54 | */ 55 | public function fromJson(array $json) : void 56 | { 57 | if (!empty($json)) { 58 | $this->Email = JSON::getString($json, 'Email'); 59 | $userNameData = JSON::getArray($json, 'Name'); 60 | if ($userNameData !== null) { 61 | $name = new UserNameModel(); 62 | $name->fromJson($userNameData); 63 | $this->Name = $name->getName(); 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /library/Models/Common/UserNameModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Common; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Helpers\StringExtension; 24 | 25 | /** 26 | * Model containing information about the name of a user partaking in a Barion Smart Gateway payment. 27 | */ 28 | class UserNameModel implements IBarionModel 29 | { 30 | /** 31 | * The Barion login name of the user. 32 | * 33 | * @var ?string 34 | */ 35 | public ?string $LoginName; 36 | 37 | /** 38 | * The first name of the user. Applicable only for individuals. 39 | * 40 | * @var ?string 41 | */ 42 | public ?string $FirstName; 43 | 44 | /** 45 | * The last name of the user. Applicable only for individuals. 46 | * 47 | * @var ?string 48 | */ 49 | public ?string $LastName; 50 | 51 | /** 52 | * The full organization name of the user. Applicable only for organizations. 53 | * 54 | * @var ?string 55 | */ 56 | public ?string $OrganizationName; 57 | 58 | function __construct() 59 | { 60 | $this->LoginName = null; 61 | $this->FirstName = null; 62 | $this->LastName = null; 63 | $this->OrganizationName = null; 64 | } 65 | 66 | /** 67 | * Build model from a JSON array. 68 | * 69 | * @param array $json 70 | * @return void 71 | */ 72 | public function fromJson(array $json) : void 73 | { 74 | if (!empty($json)) { 75 | $this->LoginName = JSON::getString($json, 'LoginName'); 76 | $this->FirstName = JSON::getString($json, 'FirstName'); 77 | $this->LastName = JSON::getString($json, 'LastName'); 78 | $this->OrganizationName = JSON::getString($json, 'OrganizationName'); 79 | } 80 | } 81 | 82 | /** 83 | * Gets the final formatted name of the user based on available values. 84 | * 85 | * @return string 86 | */ 87 | public function getName() : string 88 | { 89 | if (!StringExtension::isNullOrEmpty($this->OrganizationName)) { 90 | return strval($this->OrganizationName); 91 | } 92 | 93 | if (!StringExtension::isNullOrEmpty($this->FirstName) || !StringExtension::isNullOrEmpty($this->LastName)) { 94 | return trim($this->FirstName . " " . $this->LastName); 95 | } 96 | 97 | if (!StringExtension::isNullOrEmpty($this->LoginName)) { 98 | return strval($this->LoginName); 99 | } 100 | 101 | return ""; 102 | } 103 | } -------------------------------------------------------------------------------- /library/Models/Error/ApiErrorModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Error; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model containing error response data received from the Barion API. 26 | */ 27 | class ApiErrorModel implements IBarionModel 28 | { 29 | /** 30 | * The title of the error message. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $Title; 35 | 36 | /** 37 | * An alphanumeric code of the error. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $ErrorCode; 42 | 43 | /** 44 | * The detailed description of the error, if applicable. 45 | * 46 | * @var ?string 47 | */ 48 | public ?string $Description; 49 | 50 | /** 51 | * The timestamp when the error occured. 52 | * 53 | * @var ?string 54 | */ 55 | public ?string $HappenedAt; 56 | 57 | /** 58 | * Details about the authentication data available during the request where the error occured. 59 | * 60 | * @var ?string 61 | */ 62 | public ?string $AuthData; 63 | 64 | /** 65 | * The API endpoint on which the error occured. 66 | * 67 | * @var ?string 68 | */ 69 | public ?string $EndPoint; 70 | 71 | /** 72 | * The Barion payment identifier related to the error, if applicable. 73 | * 74 | * @var ?string 75 | */ 76 | public ?string $PaymentId; 77 | 78 | function __construct() 79 | { 80 | $this->Title = null; 81 | $this->ErrorCode = null; 82 | $this->Description = null; 83 | $this->HappenedAt = null; 84 | $this->AuthData = null; 85 | $this->EndPoint = null; 86 | $this->PaymentId = null; 87 | } 88 | 89 | /** 90 | * Build model from a JSON array. 91 | * 92 | * @param array $json 93 | * @return void 94 | */ 95 | public function fromJson(array $json) : void 96 | { 97 | if (!empty($json)) { 98 | $this->ErrorCode = JSON::getString($json, 'ErrorCode'); 99 | $this->Title = JSON::getString($json, 'Title'); 100 | $this->Description = JSON::getString($json, 'Description'); 101 | $this->HappenedAt = JSON::getString($json, 'HappenedAt'); 102 | $this->AuthData = JSON::getString($json, 'AuthData'); 103 | $this->EndPoint = JSON::getString($json, 'EndPoint'); 104 | 105 | if (array_key_exists('PaymentId', $json)) { 106 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 107 | } 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /library/Models/Payment/CancelAuthorizationRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | 23 | /** 24 | * Model used to request the cancellation of a previously authorized payment in a delayed capture scenario. 25 | */ 26 | class CancelAuthorizationRequestModel extends BaseRequestModel 27 | { 28 | /** 29 | * The Barion identifier of the payment. 30 | * 31 | * @var string 32 | */ 33 | public string $PaymentId; 34 | 35 | function __construct(string $paymentId) 36 | { 37 | $this->PaymentId = $paymentId; 38 | } 39 | } -------------------------------------------------------------------------------- /library/Models/Payment/CancelAuthorizationResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | use Barion\Enumerations\{ 25 | PaymentStatus 26 | }; 27 | 28 | /** 29 | * Model containing the response data after requesting the cancellation of a previously authorized payment in a delayed capture scenario. 30 | */ 31 | class CancelAuthorizationResponseModel extends BaseResponseModel implements IBarionModel 32 | { 33 | /** 34 | * Flag indicating that the cancellation was successful. 35 | * 36 | * @var ?bool 37 | */ 38 | public ?bool $IsSuccessful; 39 | 40 | /** 41 | * The Barion identifier of the payment. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $PaymentId; 46 | 47 | /** 48 | * The internal identifier of the payment, specified by the shop. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $PaymentRequestId; 53 | 54 | /** 55 | * The status of the payment 56 | * 57 | * @var PaymentStatus 58 | */ 59 | public PaymentStatus $Status; 60 | 61 | /** 62 | * Array of payment transactions that were cancelled. 63 | * 64 | * @var array 65 | */ 66 | public array $Transactions; 67 | 68 | function __construct() 69 | { 70 | parent::__construct(); 71 | $this->IsSuccessful = false; 72 | $this->PaymentId = null; 73 | $this->PaymentRequestId = null; 74 | $this->Transactions = array(); 75 | } 76 | 77 | public function fromJson(array $json) : void 78 | { 79 | if (!empty($json)) { 80 | parent::fromJson($json); 81 | 82 | $this->IsSuccessful = JSON::getBool($json, 'IsSuccessful'); 83 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 84 | $this->PaymentRequestId = JSON::getString($json, 'PaymentRequestId'); 85 | 86 | if (array_key_exists('Status', $json)) { 87 | $this->Status = PaymentStatus::from(JSON::getString($json, 'Status') ?? 'Prepared'); 88 | } 89 | 90 | $this->Transactions = array(); 91 | 92 | $transactions = JSON::getArray($json, 'Transactions'); 93 | 94 | if (!empty($transactions)) { 95 | foreach ($transactions as $key => $transaction) { 96 | $tr = new TransactionResponseModel(); 97 | $tr->fromJson($transaction); 98 | $this->Transactions[] = $tr; 99 | } 100 | } 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /library/Models/Payment/CaptureRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | use Barion\Interfaces\IPaymentTransactionContainer; 23 | 24 | /** 25 | * Model used to request to capture the amount of a previously authorized payment in a delayed capture scenario. 26 | */ 27 | class CaptureRequestModel extends BaseRequestModel implements IPaymentTransactionContainer 28 | { 29 | /** 30 | * The Barion identifier of the payment. 31 | * 32 | * @var string 33 | */ 34 | public string $PaymentId; 35 | 36 | /** 37 | * Array of previously authorized payment transactions that are to be captured. 38 | * 39 | * @var array 40 | */ 41 | public array $Transactions; 42 | 43 | function __construct(string $paymentId) 44 | { 45 | $this->PaymentId = $paymentId; 46 | $this->Transactions = array(); 47 | } 48 | 49 | /** 50 | * Add a single transaction to the capture request. 51 | * 52 | * @param TransactionToCaptureModel $transaction Model describing the transaction to be captured. 53 | * @return void 54 | */ 55 | public function AddTransaction(TransactionToCaptureModel $transaction) : void 56 | { 57 | if ($this->Transactions == null) { 58 | $this->Transactions = array(); 59 | } 60 | $this->Transactions[] = $transaction; 61 | } 62 | 63 | /** 64 | * Add multiple transactions to the capture request. 65 | * 66 | * @param array $transactions 67 | * @return void 68 | */ 69 | public function AddTransactions(array $transactions) : void 70 | { 71 | if (!empty($transactions)) { 72 | foreach ($transactions as $transaction) { 73 | if ($transaction instanceof TransactionToCaptureModel) { 74 | $this->AddTransaction($transaction); 75 | } 76 | } 77 | } 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /library/Models/Payment/CaptureResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | use Barion\Enumerations\{ 25 | PaymentStatus 26 | }; 27 | 28 | /** 29 | * Model containing the response data after requesting the capture of a previously authorized payment in a delayed capture scenario. 30 | */ 31 | class CaptureResponseModel extends BaseResponseModel implements IBarionModel 32 | { 33 | /** 34 | * Flag indicating that the capture was successful. 35 | * 36 | * @var ?bool 37 | */ 38 | public ?bool $IsSuccessful; 39 | 40 | /** 41 | * The Barion identifier of the payment. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $PaymentId; 46 | 47 | /** 48 | * The internal identifier of the payment, specified by the shop. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $PaymentRequestId; 53 | 54 | /** 55 | * The status of the payment 56 | * 57 | * @var PaymentStatus 58 | */ 59 | public PaymentStatus $Status; 60 | 61 | /** 62 | * Array of payment transactions that were captured. 63 | * 64 | * @var array 65 | */ 66 | public array $Transactions; 67 | 68 | function __construct() 69 | { 70 | parent::__construct(); 71 | $this->IsSuccessful = false; 72 | $this->PaymentId = ""; 73 | $this->PaymentRequestId = ""; 74 | $this->Transactions = array(); 75 | } 76 | 77 | public function fromJson(array $json) : void 78 | { 79 | if (!empty($json)) { 80 | parent::fromJson($json); 81 | 82 | $this->IsSuccessful = JSON::getBool($json, 'IsSuccessful'); 83 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 84 | $this->PaymentRequestId = JSON::getString($json, 'PaymentRequestId'); 85 | 86 | if (array_key_exists('Status', $json)) { 87 | $this->Status = PaymentStatus::from(JSON::getString($json, 'Status') ?? 'Prepared'); 88 | } 89 | 90 | $this->Transactions = array(); 91 | 92 | $transactions = JSON::getArray($json, 'Transactions'); 93 | 94 | if (!empty($transactions)) { 95 | foreach ($transactions as $key => $transaction) { 96 | $tr = new TransactionResponseModel(); 97 | $tr->fromJson($transaction); 98 | $this->Transactions[] = $tr; 99 | } 100 | } 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /library/Models/Payment/Complete3DSPaymentRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | 23 | /** 24 | * Model used to complete a previously off-site authenticated 3D-Secure card payment. 25 | */ 26 | class Complete3DSPaymentRequestModel extends BaseRequestModel 27 | { 28 | /** 29 | * The Barion identifier of the payment. 30 | * 31 | * @var string 32 | */ 33 | public string $PaymentId; 34 | 35 | function __construct(string $paymentId) 36 | { 37 | $this->PaymentId = $paymentId; 38 | } 39 | } -------------------------------------------------------------------------------- /library/Models/Payment/Complete3DSPaymentResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | use Barion\Enumerations\{ 25 | PaymentStatus 26 | }; 27 | 28 | /** 29 | * Model containing the response data after completing a previously off-site authenticated 3D-Secure card payment. 30 | */ 31 | class Complete3DSPaymentResponseModel extends BaseResponseModel implements IBarionModel 32 | { 33 | /** 34 | * Flag indicating that the cancellation was successful. 35 | * 36 | * @var ?bool 37 | */ 38 | public ?bool $IsSuccessful; 39 | 40 | /** 41 | * The Barion identifier of the payment. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $PaymentId; 46 | 47 | /** 48 | * The internal identifier of the payment, specified by the shop. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $PaymentRequestId; 53 | 54 | /** 55 | * The status of the payment 56 | * 57 | * @var PaymentStatus 58 | */ 59 | public PaymentStatus $Status; 60 | 61 | /** 62 | * The trace id of the 3D-Secure payment flow. 63 | * 64 | * @var ?string 65 | */ 66 | public ?string $TraceId; 67 | 68 | function __construct() 69 | { 70 | parent::__construct(); 71 | $this->PaymentId = null; 72 | $this->PaymentRequestId = null; 73 | $this->IsSuccessful = false; 74 | $this->TraceId = null; 75 | } 76 | 77 | public function fromJson(array $json) : void 78 | { 79 | if (!empty($json)) { 80 | parent::fromJson($json); 81 | 82 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 83 | $this->PaymentRequestId = JSON::getString($json, 'PaymentRequestId'); 84 | 85 | if (array_key_exists('PaymentStatus', $json)) { 86 | $this->Status = PaymentStatus::from(JSON::getString($json, 'PaymentStatus') ?? 'Prepared'); 87 | } 88 | 89 | $this->IsSuccessful = JSON::getBool($json, 'IsSuccessful'); 90 | $this->TraceId = JSON::getString($json, 'TraceId'); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /library/Models/Payment/FinishReservationRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | use Barion\Interfaces\IPaymentTransactionContainer; 23 | 24 | /** 25 | * Model used to request the finish of a previously started reservation payment on the Barion Smart Gateway. 26 | */ 27 | class FinishReservationRequestModel extends BaseRequestModel implements IPaymentTransactionContainer 28 | { 29 | /** 30 | * The Barion identifier of the payment. 31 | * 32 | * @var string 33 | */ 34 | public string $PaymentId; 35 | 36 | /** 37 | * Array of started reservation payment transactions that are to be finished. 38 | * 39 | * @var array 40 | */ 41 | public array $Transactions; 42 | 43 | function __construct(string $paymentId) 44 | { 45 | $this->PaymentId = $paymentId; 46 | $this->Transactions = array(); 47 | } 48 | 49 | /** 50 | * Add a single transaction to the finish reservation request. 51 | * 52 | * @param TransactionToFinishModel $transaction Model describing the transaction to be finished. 53 | * @return void 54 | */ 55 | public function AddTransaction(TransactionToFinishModel $transaction) : void 56 | { 57 | if ($this->Transactions == null) { 58 | $this->Transactions = array(); 59 | } 60 | $this->Transactions[] = $transaction; 61 | } 62 | 63 | /** 64 | * Add multiple transactions to the finish reservation request. 65 | * 66 | * @param array $transactions 67 | * @return void 68 | */ 69 | public function AddTransactions(array $transactions) : void 70 | { 71 | if (!empty($transactions)) { 72 | foreach ($transactions as $transaction) { 73 | if ($transaction instanceof TransactionToFinishModel) { 74 | $this->AddTransaction($transaction); 75 | } 76 | } 77 | } 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /library/Models/Payment/FinishReservationResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | use Barion\Enumerations\{ 25 | PaymentStatus 26 | }; 27 | 28 | /** 29 | * Model containing the response data after requesting the finishing of a previously started reservation payment on the Barion Smart Gateway. 30 | */ 31 | class FinishReservationResponseModel extends BaseResponseModel implements IBarionModel 32 | { 33 | /** 34 | * Flag indicating that the cancellation was successful. 35 | * 36 | * @var ?bool 37 | */ 38 | public ?bool $IsSuccessful; 39 | 40 | /** 41 | * The Barion identifier of the payment. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $PaymentId; 46 | 47 | /** 48 | * The internal identifier of the payment, specified by the shop. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $PaymentRequestId; 53 | 54 | /** 55 | * The status of the payment 56 | * 57 | * @var PaymentStatus 58 | */ 59 | public PaymentStatus $Status; 60 | 61 | /** 62 | * Array of reservation payment transactions that were finished. 63 | * 64 | * @var array 65 | */ 66 | public array $Transactions; 67 | 68 | function __construct() 69 | { 70 | parent::__construct(); 71 | $this->IsSuccessful = false; 72 | $this->PaymentId = ""; 73 | $this->PaymentRequestId = ""; 74 | $this->Transactions = array(); 75 | } 76 | 77 | public function fromJson(array $json) : void 78 | { 79 | if (!empty($json)) { 80 | parent::fromJson($json); 81 | 82 | $this->IsSuccessful = JSON::getBool($json, 'IsSuccessful'); 83 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 84 | $this->PaymentRequestId = JSON::getString($json, 'PaymentRequestId'); 85 | 86 | if (array_key_exists('Status', $json)) { 87 | $this->Status = PaymentStatus::from(JSON::getString($json, 'Status') ?? 'Prepared'); 88 | } 89 | 90 | $this->Transactions = array(); 91 | 92 | $transactions = JSON::getArray($json, 'Transactions'); 93 | 94 | if (!empty($transactions)) { 95 | foreach ($transactions as $key => $transaction) { 96 | $tr = new TransactionResponseModel(); 97 | $tr->fromJson($transaction); 98 | $this->Transactions[] = $tr; 99 | } 100 | } 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /library/Models/Payment/GetPaymentStateRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | 23 | /** 24 | * Model used to request detailed information about a payment on the Barion Smart Gateway. 25 | */ 26 | class GetPaymentStateRequestModel extends BaseRequestModel 27 | { 28 | /** 29 | * The Barion identifier of the payment. 30 | * 31 | * @var string 32 | */ 33 | public string $PaymentId; 34 | 35 | function __construct(string $paymentId) 36 | { 37 | $this->PaymentId = $paymentId; 38 | } 39 | } -------------------------------------------------------------------------------- /library/Models/Payment/PayeeTransactionModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | /** 22 | * Model describing a payee transaction attached to a payment transaction. 23 | */ 24 | class PayeeTransactionModel 25 | { 26 | /** 27 | * The internal identifier of the payee transaction. 28 | * 29 | * @var string 30 | */ 31 | public string $POSTransactionId; 32 | 33 | /** 34 | * The e-mail address of the Barion wallet of the payee. 35 | * 36 | * @var string 37 | */ 38 | public string $Payee; 39 | 40 | /** 41 | * The total amount of the payee transaction 42 | * 43 | * @var float 44 | */ 45 | public float $Total; 46 | 47 | /** 48 | * Optional comment for the payee transaction. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $Comment; 53 | 54 | function __construct() 55 | { 56 | $this->POSTransactionId = ""; 57 | $this->Payee = ""; 58 | $this->Total = 0.0; 59 | $this->Comment = null; 60 | } 61 | } -------------------------------------------------------------------------------- /library/Models/Payment/PayeeTransactionToCaptureModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | /** 22 | * Model describing a payee transaction that is being captured in a delayed capture scenario. 23 | */ 24 | class PayeeTransactionToCaptureModel 25 | { 26 | /** 27 | * The Barion identifier of the payee transaction. 28 | * 29 | * @var string 30 | */ 31 | public string $TransactionId; 32 | 33 | /** 34 | * The total finishing amount of the payee transaction. 35 | * 36 | * @var float 37 | */ 38 | public float $Total; 39 | 40 | /** 41 | * Optional comment for the finished payee transaction. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $Comment; 46 | 47 | function __construct() 48 | { 49 | $this->TransactionId = ""; 50 | $this->Total = 0.0; 51 | $this->Comment = null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/Models/Payment/PayeeTransactionToFinishModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | /** 22 | * Model describing a payee transaction attached to a reservation payment transaction that is being finished. 23 | */ 24 | class PayeeTransactionToFinishModel 25 | { 26 | /** 27 | * The Barion identifier of the payee transaction. 28 | * 29 | * @var string 30 | */ 31 | public string $TransactionId; 32 | 33 | /** 34 | * The total finishing amount of the payee transaction. 35 | * 36 | * @var float 37 | */ 38 | public float $Total; 39 | 40 | /** 41 | * Optional comment for the finished payee transaction. 42 | * 43 | * @var ?string 44 | */ 45 | public ?string $Comment; 46 | 47 | function __construct() 48 | { 49 | $this->TransactionId = ""; 50 | $this->Total = 0.0; 51 | $this->Comment = null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/Models/Payment/PaymentQRRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | use Barion\Enumerations\QRCodeSize; 23 | 24 | /** 25 | * @deprecated 26 | * Model used to request a QR code image for the Barion Smart Gateway URL of a payment. 27 | */ 28 | class PaymentQRRequestModel extends BaseRequestModel 29 | { 30 | /** 31 | * The Barion username (e-mail address) of the caller. 32 | * 33 | * @var string 34 | */ 35 | public string $UserName; 36 | 37 | /** 38 | * The Barion password of the caller. 39 | * 40 | * @var string 41 | */ 42 | public string $Password; 43 | 44 | /** 45 | * The Barion identifier of the payment. 46 | * 47 | * @var string 48 | */ 49 | public string $PaymentId; 50 | 51 | /** 52 | * Size of the requested QR code image. 53 | * 54 | * @var QRCodeSize 55 | */ 56 | public QRCodeSize $Size; 57 | 58 | function __construct(string $userName, string $password, string $paymentId, QRCodeSize $size = QRCodeSize::Normal) 59 | { 60 | $this->UserName = $userName; 61 | $this->Password = $password; 62 | $this->PaymentId = $paymentId; 63 | $this->Size = $size; 64 | } 65 | } -------------------------------------------------------------------------------- /library/Models/Payment/PaymentStateRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | 23 | /** 24 | * Model used to request detailed information about a payment on the Barion Smart Gateway. 25 | */ 26 | class PaymentStateRequestModel extends BaseRequestModel 27 | { 28 | /** 29 | * The Barion identifier of the payment. 30 | * 31 | * @var string 32 | */ 33 | public string $PaymentId; 34 | 35 | function __construct(string $paymentId) 36 | { 37 | $this->PaymentId = $paymentId; 38 | } 39 | } -------------------------------------------------------------------------------- /library/Models/Payment/PaymentTransactionModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IItemContainer; 22 | use Barion\Interfaces\IPayeeTransactionContainer; 23 | use Barion\Models\Common\{ 24 | ItemModel 25 | }; 26 | 27 | /** 28 | * Model containing details about a payment transaction attached to a Barion Smart Gateway payment. 29 | */ 30 | class PaymentTransactionModel implements IItemContainer, IPayeeTransactionContainer 31 | { 32 | /** 33 | * The internal identifier of the transaction, specified by the shop. 34 | * 35 | * @var string 36 | */ 37 | public string $POSTransactionId; 38 | 39 | /** 40 | * The e-mail address of the recipient of the payment amount. 41 | * 42 | * @var string 43 | */ 44 | public string $Payee; 45 | 46 | /** 47 | * The total amount of the payment. 48 | * 49 | * @var float 50 | */ 51 | public float $Total; 52 | 53 | /** 54 | * Optional comment of the payment transaction. 55 | * 56 | * @var ?string 57 | */ 58 | public ?string $Comment; 59 | 60 | /** 61 | * Array of items included in the transaction. 62 | * 63 | * @var array 64 | */ 65 | public array $Items; 66 | 67 | /** 68 | * Array of payee transactions attached to the transaction. 69 | * 70 | * @var array 71 | */ 72 | public array $PayeeTransactions; 73 | 74 | function __construct() 75 | { 76 | $this->POSTransactionId = ""; 77 | $this->Payee = ""; 78 | $this->Total = 0.0; 79 | $this->Comment = null; 80 | $this->Items = array(); 81 | $this->PayeeTransactions = array(); 82 | } 83 | 84 | /** 85 | * Add a single item to the payment transaction. 86 | * 87 | * @param ItemModel $item 88 | * @return void 89 | */ 90 | public function AddItem(ItemModel $item) : void 91 | { 92 | $this->Items[] = $item; 93 | } 94 | 95 | /** 96 | * Add multiple items to the payment transaction. 97 | * 98 | * @param array $items 99 | * @return void 100 | */ 101 | public function AddItems(array $items) : void 102 | { 103 | foreach ($items as $item) { 104 | if ($item instanceof ItemModel) { 105 | $this->AddItem($item); 106 | } 107 | } 108 | } 109 | 110 | /** 111 | * Attach a single payee transaction to the payment transaction. 112 | * 113 | * @param PayeeTransactionModel $transaction 114 | * @return void 115 | */ 116 | public function AddPayeeTransaction(PayeeTransactionModel $transaction) : void 117 | { 118 | $this->PayeeTransactions[] = $transaction; 119 | } 120 | 121 | /** 122 | * Attach multiple payee transactions to the payment transaction. 123 | * 124 | * @param array $transactions 125 | * @return void 126 | */ 127 | public function AddPayeeTransactions(array $transactions) : void 128 | { 129 | foreach ($transactions as $transaction) { 130 | if ($transaction instanceof PayeeTransactionModel) { 131 | $this->AddPayeeTransaction($transaction); 132 | } 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /library/Models/Payment/PreparePaymentRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | use Barion\Interfaces\IPaymentTransactionContainer; 23 | use Barion\Enumerations\{ 24 | PaymentType, 25 | FundingSourceType, 26 | Currency, 27 | UILocale 28 | }; 29 | use Barion\Enumerations\ThreeDSecure\{ 30 | RecurrenceType, 31 | ChallengePreference 32 | }; 33 | 34 | /** 35 | * Model used to start a new payment on the Barion Smart Gateway. 36 | */ 37 | class PreparePaymentRequestModel extends BaseRequestModel implements IPaymentTransactionContainer 38 | { 39 | /** 40 | * The type of the payment. 41 | * 42 | * @var PaymentType 43 | */ 44 | public PaymentType $PaymentType; 45 | 46 | /** 47 | * Timespan of the period the payment should be reserved for. 48 | * Applicable if PaymentType = Reservation 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $ReservationPeriod; 53 | 54 | /** 55 | * Timespan of the period the payment should be available for capturing after authorization. 56 | * Applicable if PaymentType = DelayedCapture 57 | * 58 | * @var ?string 59 | */ 60 | public ?string $DelayedCapturePeriod; 61 | 62 | /** 63 | * Timespan of the period the payment can be completed on the Barion Smart Gateway. 64 | * 65 | * @var string 66 | */ 67 | public string $PaymentWindow; 68 | 69 | /** 70 | * Flag indicating if guest checkout is available for the payment. 71 | * 72 | * @var bool 73 | */ 74 | public bool $GuestCheckout; 75 | 76 | /** 77 | * Array of funding source types allowed to complete the payment. 78 | * 79 | * @var array 80 | */ 81 | public array $FundingSources; 82 | 83 | /** 84 | * Internal identifier of the payment, specified by the shop. 85 | * 86 | * @var string 87 | */ 88 | public string $PaymentRequestId; 89 | 90 | /** 91 | * Hint of a payer e-mail address the Barion Smart Gateway should pre-fill for the user. 92 | * 93 | * @var ?string 94 | */ 95 | public ?string $PayerHint; 96 | 97 | /** 98 | * Array of payment transactions included in the payment. 99 | * 100 | * @var array 101 | */ 102 | public array $Transactions; 103 | 104 | /** 105 | * Locale of the Barion Smart Gateway for the payment. 106 | * 107 | * @var UILocale 108 | */ 109 | public UILocale $Locale; 110 | 111 | /** 112 | * The order number of the payment, specified by the shop. 113 | * 114 | * @var ?string 115 | */ 116 | public ?string $OrderNumber; 117 | 118 | /** 119 | * Shipping address data connected to a 3D-Secure card payment. 120 | * 121 | * @var ?object 122 | */ 123 | public ?object $ShippingAddress; 124 | 125 | /** 126 | * Billing address data connected to a 3D-Secure card payment. 127 | * 128 | * @var ?object 129 | */ 130 | public ?object $BillingAddress; 131 | 132 | /** 133 | * Flag indicating if this payment is the starting point of a recurring/token payment flow. 134 | * 135 | * @var bool 136 | */ 137 | public bool $InitiateRecurrence; 138 | 139 | /** 140 | * The recurrence identifier (token) of the recurring payment, if applicable. 141 | * 142 | * @var ?string 143 | */ 144 | public ?string $RecurrenceId; 145 | 146 | /** 147 | * The URL where the customer is redirected after completing or rejecting the payment. 148 | * 149 | * @var ?string 150 | */ 151 | public ?string $RedirectUrl; 152 | 153 | /** 154 | * The URL where the Barion system will send a callback request whenever the payment state is changed. 155 | * 156 | * @var ?string 157 | */ 158 | public ?string $CallbackUrl; 159 | 160 | /** 161 | * The currency of the payment. 162 | * 163 | * @var Currency 164 | */ 165 | public Currency $Currency; 166 | 167 | /** 168 | * Information about the cardholder name in case of a 3D-Secure card payment process. 169 | * 170 | * @var ?string 171 | */ 172 | public ?string $CardHolderNameHint; 173 | 174 | /** 175 | * Information about the payer phone number in case of a 3D-Secure card payment process. 176 | * 177 | * @var ?string 178 | */ 179 | public ?string $PayerPhoneNumber; 180 | 181 | /** 182 | * Payer work phone number in case of a 3D-Secure card payment process. 183 | * 184 | * @var ?string 185 | */ 186 | public ?string $PayerWorkPhoneNumber; 187 | 188 | /** 189 | * Payer home phone number in case of a 3D-Secure card payment process. 190 | * 191 | * @var ?string 192 | */ 193 | public ?string $PayerHomePhoneNumber; 194 | 195 | /** 196 | * Payer account information applicable in case of a 3D-Secure card payment process. 197 | * 198 | * @var ?object 199 | */ 200 | public ?object $PayerAccountInformation; 201 | 202 | /** 203 | * Purchase information applicable in case of a 3D-Secure card payment process. 204 | * 205 | * @var ?object 206 | */ 207 | public ?object $PurchaseInformation; 208 | 209 | /** 210 | * Type of recurrence in case of a recurring/token payment scenario. 211 | * 212 | * @var RecurrenceType 213 | */ 214 | public RecurrenceType $RecurrenceType; 215 | 216 | /** 217 | * Challenge preference indicator for a 3D-Secure card payment process. 218 | * 219 | * @var ChallengePreference 220 | */ 221 | public ChallengePreference $ChallengePreference; 222 | 223 | /** 224 | * The trace id of the 3D-Secure payment flow. 225 | * 226 | * @var ?string 227 | */ 228 | public ?string $TraceId; 229 | 230 | /** 231 | * Create a new request for starting a payment. 232 | * 233 | * @param string $requestId 234 | * @param PaymentType $paymentType 235 | * @param bool $guestCheckoutAllowed 236 | * @param array $allowedFundingSources 237 | * @param string $paymentWindow 238 | * @param UILocale $locale 239 | * @param bool $initiateRecurrence 240 | * @param string|null $recurrenceId 241 | * @param string|null $redirectUrl 242 | * @param string|null $callbackUrl 243 | * @param Currency $currency 244 | * @param string|null $traceId 245 | */ 246 | function __construct(string $requestId = "", PaymentType $paymentType = PaymentType::Immediate, bool $guestCheckoutAllowed = true, 247 | array $allowedFundingSources = array(FundingSourceType::All), string $paymentWindow = "00:30:00", UILocale $locale = UILocale::HU, 248 | bool $initiateRecurrence = false, string $recurrenceId = null, string $redirectUrl = null, 249 | string $callbackUrl = null, Currency $currency = Currency::HUF, string $traceId = null) 250 | { 251 | $this->PaymentRequestId = $requestId; 252 | $this->PaymentType = $paymentType; 253 | $this->PaymentWindow = $paymentWindow; 254 | $this->GuestCheckout = $guestCheckoutAllowed; 255 | $this->FundingSources = $allowedFundingSources; 256 | $this->Locale = $locale; 257 | $this->InitiateRecurrence = $initiateRecurrence; 258 | $this->RecurrenceId = $recurrenceId; 259 | $this->RedirectUrl = $redirectUrl; 260 | $this->CallbackUrl = $callbackUrl; 261 | $this->Currency = $currency; 262 | $this->Transactions = array(); 263 | $this->TraceId = $traceId; 264 | } 265 | 266 | /** 267 | * Add a single payment transaction to the payment. 268 | * 269 | * @param PaymentTransactionModel $transaction 270 | * @return void 271 | */ 272 | public function AddTransaction(PaymentTransactionModel $transaction) : void 273 | { 274 | $this->Transactions[] = $transaction; 275 | } 276 | 277 | /** 278 | * Add multiple payment transactions to the payment. 279 | * 280 | * @param array $transactions 281 | * @return void 282 | */ 283 | public function AddTransactions(array $transactions) : void 284 | { 285 | foreach ($transactions as $transaction) { 286 | if ($transaction instanceof PaymentTransactionModel) { 287 | $this->AddTransaction($transaction); 288 | } 289 | } 290 | } 291 | } -------------------------------------------------------------------------------- /library/Models/Payment/PreparePaymentResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | use Barion\Enumerations\{ 25 | PaymentStatus, 26 | RecurrenceResult 27 | }; 28 | 29 | /** 30 | * Model containing the response data after starting a new payment on the Barion Smart Gateway. 31 | */ 32 | class PreparePaymentResponseModel extends BaseResponseModel implements IBarionModel 33 | { 34 | /** 35 | * The Barion identifier of the payment. 36 | * 37 | * @var ?string 38 | */ 39 | public ?string $PaymentId; 40 | 41 | /** 42 | * The internal identifier of the payment, specified by the shop. 43 | * 44 | * @var ?string 45 | */ 46 | public ?string $PaymentRequestId; 47 | 48 | /** 49 | * The status of the payment. 50 | * 51 | * @var PaymentStatus 52 | */ 53 | public PaymentStatus $Status; 54 | 55 | /** 56 | * Array of payment transactions included in the payment. 57 | * 58 | * @var array 59 | */ 60 | public array $Transactions; 61 | 62 | /** 63 | * URL for a QR code image containing the Barion Smart Gateway address for the payment. 64 | * 65 | * @var ?string 66 | */ 67 | public ?string $QRUrl; 68 | 69 | /** 70 | * The result of a recurring payment action, if applicable. 71 | * 72 | * @var RecurrenceResult 73 | */ 74 | public RecurrenceResult $RecurrenceResult; 75 | 76 | /** 77 | * The Barion Smart Gateway URL the customer should be redirected to, so they can complete the payment. 78 | * 79 | * @var ?string 80 | */ 81 | public ?string $PaymentRedirectUrl; 82 | 83 | /** 84 | * 3D-Secure authentication data, applicable if off-site authentication is required. 85 | * 86 | * @var ?string 87 | */ 88 | public ?string $ThreeDSAuthClientData; 89 | 90 | /** 91 | * The trace id of the 3D-Secure payment flow. 92 | * 93 | * @var ?string 94 | */ 95 | public ?string $TraceId; 96 | 97 | function __construct() 98 | { 99 | parent::__construct(); 100 | $this->PaymentId = null; 101 | $this->PaymentRequestId = null; 102 | $this->QRUrl = null; 103 | $this->RecurrenceResult = RecurrenceResult::None; 104 | $this->PaymentRedirectUrl = null; 105 | $this->ThreeDSAuthClientData = null; 106 | $this->TraceId = null; 107 | $this->Transactions = array(); 108 | } 109 | 110 | public function fromJson(array $json) : void 111 | { 112 | if (!empty($json)) { 113 | parent::fromJson($json); 114 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 115 | $this->PaymentRequestId = JSON::getString($json, 'PaymentRequestId'); 116 | $this->QRUrl = JSON::getString($json, 'QRUrl'); 117 | $this->RecurrenceResult = RecurrenceResult::from(JSON::getString($json, 'RecurrenceResult') ?? 'None'); 118 | $this->ThreeDSAuthClientData = JSON::getString($json, 'ThreeDSAuthClientData'); 119 | $this->TraceId = JSON::getString($json, 'TraceId'); 120 | $this->Transactions = array(); 121 | 122 | if (array_key_exists('Status', $json)) { 123 | $this->Status = PaymentStatus::from(JSON::getString($json, 'Status') ?? 'Prepared'); 124 | } 125 | 126 | $transactions = JSON::getArray($json, 'Transactions'); 127 | 128 | if (!empty($transactions)) { 129 | foreach ($transactions as $key => $transaction) { 130 | $tr = new TransactionResponseModel(); 131 | $tr->fromJson($transaction); 132 | $this->Transactions[] = $tr; 133 | } 134 | } 135 | 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /library/Models/Payment/TransactionDetailModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Models\Common\{ 24 | UserModel, 25 | ItemModel 26 | }; 27 | use Barion\Enumerations\{ 28 | Currency, 29 | TransactionType, 30 | TransactionStatus 31 | }; 32 | 33 | /** 34 | * Model containing detailed information about a payment transaction in a Barion API request. 35 | */ 36 | class TransactionDetailModel implements IBarionModel 37 | { 38 | /** 39 | * The Barion identifier of the transaction. 40 | * 41 | * @var ?string 42 | */ 43 | public ?string $TransactionId; 44 | 45 | /** 46 | * The internal identifier of the transaction, specified by the shop. 47 | * 48 | * @var ?string 49 | */ 50 | public ?string $POSTransactionId; 51 | 52 | /** 53 | * ISO-8601 format timestamp of the transaction. 54 | * 55 | * @var ?string 56 | */ 57 | public ?string $TransactionTime; 58 | 59 | /** 60 | * The total amount of the transaction. 61 | * 62 | * @var ?float 63 | */ 64 | public ?float $Total; 65 | 66 | /** 67 | * The currency of the transaction 68 | * 69 | * @var Currency 70 | */ 71 | public Currency $Currency; 72 | 73 | /** 74 | * Information about the payer of the transaction. 75 | * 76 | * @var object 77 | */ 78 | public object $Payer; 79 | 80 | /** 81 | * Information about the payee of the transaction. 82 | * 83 | * @var object 84 | */ 85 | public object $Payee; 86 | 87 | /** 88 | * Optional comment of the transaction. 89 | * 90 | * @var ?string 91 | */ 92 | public ?string $Comment; 93 | 94 | /** 95 | * Current status of the transaction. 96 | * 97 | * @var TransactionStatus 98 | */ 99 | public TransactionStatus $Status; 100 | 101 | /** 102 | * The type of the transaction. 103 | * 104 | * @var TransactionType 105 | */ 106 | public TransactionType $TransactionType; 107 | 108 | /** 109 | * Items included in the transaction. 110 | * 111 | * @var array 112 | */ 113 | public array $Items; 114 | 115 | /** 116 | * Barion identifier of a transaction this one is related to. 117 | * 118 | * @var ?string 119 | */ 120 | public ?string $RelatedId; 121 | 122 | /** 123 | * Barion identifier of the shop that started the transaction. 124 | * 125 | * @var ?string 126 | */ 127 | public ?string $POSId; 128 | 129 | /** 130 | * Barion identifier of the payment related to the transaction. 131 | * 132 | * @var ?string 133 | */ 134 | public ?string $PaymentId; 135 | 136 | function __construct() 137 | { 138 | $this->TransactionId = ""; 139 | $this->POSTransactionId = null; 140 | $this->TransactionTime = ""; 141 | $this->Total = 0.0; 142 | $this->Currency = Currency::HUF; 143 | $this->Payer = new UserModel(); 144 | $this->Payee = new UserModel(); 145 | $this->Comment = null; 146 | $this->Status = TransactionStatus::Unknown; 147 | $this->TransactionType = TransactionType::Unspecified; 148 | $this->Items = array(); 149 | $this->RelatedId = null; 150 | $this->POSId = null; 151 | $this->PaymentId = null; 152 | } 153 | 154 | public function fromJson(array $json) : void 155 | { 156 | if (!empty($json)) { 157 | $this->TransactionId = JSON::getString($json, 'TransactionId'); 158 | $this->POSTransactionId = JSON::getString($json, 'POSTransactionId'); 159 | $this->TransactionTime = JSON::getString($json, 'TransactionTime'); 160 | $this->Total = JSON::getFloat($json, 'Total'); 161 | $this->Currency = Currency::from(JSON::getString($json, 'Currency') ?? "Unspecified"); 162 | 163 | $this->Payer = new UserModel(); 164 | $this->Payer->fromJson(JSON::getArray($json, 'Payer') ?? array()); 165 | 166 | $this->Payee = new UserModel(); 167 | $this->Payee->fromJson(JSON::getArray($json, 'Payee') ?? array()); 168 | 169 | $this->Comment = JSON::getString($json, 'Comment'); 170 | $this->Status = TransactionStatus::from(JSON::getString($json, 'Status') ?? "Unknown"); 171 | $this->TransactionType = TransactionType::from(JSON::getString($json, 'TransactionType') ?? "Unspecified"); 172 | 173 | $this->Items = array(); 174 | 175 | $items = JSON::getArray($json, 'Items'); 176 | 177 | if (!empty($items)) { 178 | foreach ($items as $key => $i) { 179 | $item = new ItemModel(); 180 | $item->fromJson($i); 181 | $this->Items[] = $item; 182 | } 183 | } 184 | 185 | $this->RelatedId = JSON::getString($json, 'RelatedId'); 186 | $this->POSId = JSON::getString($json, 'POSId'); 187 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 188 | } 189 | } 190 | } -------------------------------------------------------------------------------- /library/Models/Payment/TransactionResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Enumerations\{ 24 | TransactionStatus 25 | }; 26 | 27 | /** 28 | * Model containing detailed information about a payment transaction in a Barion API response. 29 | */ 30 | class TransactionResponseModel implements IBarionModel 31 | { 32 | /** 33 | * The internal identifier of the transaction, specified by the shop. 34 | * 35 | * @var ?string 36 | */ 37 | public ?string $POSTransactionId; 38 | 39 | /** 40 | * The Barion identifier of the transaction. 41 | * 42 | * @var ?string 43 | */ 44 | public ?string $TransactionId; 45 | 46 | /** 47 | * Current status of the transaction. 48 | * 49 | * @var TransactionStatus 50 | */ 51 | public TransactionStatus $Status; 52 | 53 | /** 54 | * ISO-8601 format timestamp of the transaction. 55 | * 56 | * @var ?string 57 | */ 58 | public ?string $TransactionTime; 59 | 60 | /** 61 | * Barion identifier of a transaction this one is related to. 62 | * 63 | * @var ?string 64 | */ 65 | public ?string $RelatedId; 66 | 67 | function __construct() 68 | { 69 | $this->POSTransactionId = ""; 70 | $this->TransactionId = ""; 71 | $this->Status = TransactionStatus::Unknown; 72 | $this->TransactionTime = ""; 73 | $this->RelatedId = null; 74 | } 75 | 76 | public function fromJson(array $json) : void 77 | { 78 | if (!empty($json)) { 79 | $this->POSTransactionId = JSON::getString($json, 'POSTransactionId'); 80 | $this->Status = TransactionStatus::from(JSON::getString($json, 'Status') ?? "Unknown"); 81 | $this->TransactionId = JSON::getString($json, 'TransactionId'); 82 | $this->TransactionTime = JSON::getString($json, 'TransactionTime'); 83 | $this->RelatedId = JSON::getString($json, 'RelatedId'); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /library/Models/Payment/TransactionToCaptureModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IItemContainer; 22 | use Barion\Interfaces\IPayeeTransactionContainer; 23 | use Barion\Models\Common\{ 24 | ItemModel 25 | }; 26 | 27 | /** 28 | * Model describing a transaction that is being captured in a delayed capture scenario. 29 | */ 30 | class TransactionToCaptureModel implements IItemContainer, IPayeeTransactionContainer 31 | { 32 | /** 33 | * The Barion identifier of the transaction. 34 | * 35 | * @var string 36 | */ 37 | public string $TransactionId; 38 | 39 | /** 40 | * The total amount to capture in the transaction. 41 | * 42 | * @var float 43 | */ 44 | public float $Total; 45 | 46 | /** 47 | * Payee transactions attached to the transaction. 48 | * 49 | * @var array 50 | */ 51 | public array $PayeeTransactions; 52 | 53 | /** 54 | * Items included in the transaction. 55 | * 56 | * @var array 57 | */ 58 | public array $Items; 59 | 60 | /** 61 | * Optional comment of the transaction. 62 | * 63 | * @var ?string 64 | */ 65 | public ?string $Comment; 66 | 67 | function __construct() 68 | { 69 | $this->TransactionId = ""; 70 | $this->Total = 0.0; 71 | $this->PayeeTransactions = array(); 72 | $this->Comment = null; 73 | $this->Items = array(); 74 | } 75 | 76 | /** 77 | * Add a single item to the transaction. 78 | * 79 | * @param ItemModel $item 80 | * @return void 81 | */ 82 | public function AddItem(ItemModel $item) : void 83 | { 84 | $this->Items[] = $item; 85 | } 86 | 87 | /** 88 | * Add multiple items to the transaction. 89 | * 90 | * @param array $items 91 | * @return void 92 | */ 93 | public function AddItems(array $items) : void 94 | { 95 | foreach ($items as $item) { 96 | if ($item instanceof ItemModel) { 97 | $this->AddItem($item); 98 | } 99 | } 100 | } 101 | 102 | /** 103 | * Add a single payee transaction to the transaction. 104 | * 105 | * @param PayeeTransactionToCaptureModel $transaction Model describing the payee transaction to be captured. 106 | * @return void 107 | */ 108 | public function AddPayeeTransaction(PayeeTransactionToCaptureModel $transaction) : void 109 | { 110 | $this->PayeeTransactions[] = $transaction; 111 | } 112 | 113 | /** 114 | * Add multiple payee transactions to the transaction. 115 | * 116 | * @param array $transactions 117 | * @return void 118 | */ 119 | public function AddPayeeTransactions(array $transactions) : void 120 | { 121 | foreach ($transactions as $transaction) { 122 | if ($transaction instanceof PayeeTransactionToCaptureModel) { 123 | $this->AddPayeeTransaction($transaction); 124 | } 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /library/Models/Payment/TransactionToFinishModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | use Barion\Interfaces\IItemContainer; 22 | use Barion\Interfaces\IPayeeTransactionContainer; 23 | use Barion\Models\Common\{ 24 | ItemModel 25 | }; 26 | 27 | /** 28 | * Model describing a transaction that is being finished in a reservation payment scenario. 29 | */ 30 | class TransactionToFinishModel implements IItemContainer, IPayeeTransactionContainer 31 | { 32 | /** 33 | * The Barion identifier of the transaction. 34 | * 35 | * @var string 36 | */ 37 | public string $TransactionId; 38 | 39 | /** 40 | * The total finishing amount of the transaction. 41 | * 42 | * @var float 43 | */ 44 | public float $Total; 45 | 46 | /** 47 | * Payee transactions attached to the transaction. 48 | * 49 | * @var array 50 | */ 51 | public array $PayeeTransactions; 52 | 53 | /** 54 | * Items included in the transaction. 55 | * 56 | * @var array 57 | */ 58 | public array $Items; 59 | 60 | /** 61 | * Optional comment of the transaction. 62 | * 63 | * @var ?string 64 | */ 65 | public ?string $Comment; 66 | 67 | function __construct() 68 | { 69 | $this->TransactionId = ""; 70 | $this->Total = 0; 71 | $this->PayeeTransactions = array(); 72 | $this->Items = array(); 73 | $this->Comment = null; 74 | } 75 | 76 | /** 77 | * Add a single item to the transaction. 78 | * 79 | * @param ItemModel $item 80 | * @return void 81 | */ 82 | public function AddItem(ItemModel $item) : void 83 | { 84 | $this->Items[] = $item; 85 | } 86 | 87 | /** 88 | * Add multiple items to the transaction. 89 | * 90 | * @param array $items 91 | * @return void 92 | */ 93 | public function AddItems(array $items) : void 94 | { 95 | foreach ($items as $item) { 96 | if ($item instanceof ItemModel) { 97 | $this->AddItem($item); 98 | } 99 | } 100 | } 101 | 102 | /** 103 | * Add a single payee transaction to the transaction. 104 | * 105 | * @param PayeeTransactionToFinishModel $transaction Model describing the payee transaction to be finished. 106 | * @return void 107 | */ 108 | public function AddPayeeTransaction(PayeeTransactionToFinishModel $transaction) : void 109 | { 110 | $this->PayeeTransactions[] = $transaction; 111 | } 112 | 113 | 114 | /** 115 | * Add multiple payee transactions to the transaction. 116 | * 117 | * @param array $transactions 118 | * @return void 119 | */ 120 | public function AddPayeeTransactions(array $transactions) : void 121 | { 122 | foreach ($transactions as $transaction) { 123 | if ($transaction instanceof PayeeTransactionToFinishModel) { 124 | $this->AddPayeeTransaction($transaction); 125 | } 126 | } 127 | } 128 | } -------------------------------------------------------------------------------- /library/Models/Payment/TransactionToRefundModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Payment; 20 | 21 | /** 22 | * Model describing a transaction that is being refunded. 23 | */ 24 | class TransactionToRefundModel 25 | { 26 | /** 27 | * The Barion identifier of the transaction. 28 | * 29 | * @var string 30 | */ 31 | public string $TransactionId; 32 | 33 | /** 34 | * The internal identifier of the transaction, specified by the shop. 35 | * 36 | * @var string 37 | */ 38 | public string $POSTransactionId; 39 | 40 | /** 41 | * The amount to refund from the transaction. 42 | * 43 | * @var float 44 | */ 45 | public float $AmountToRefund; 46 | 47 | /** 48 | * Optional comment of the refund transaction. 49 | * 50 | * @var ?string 51 | */ 52 | public ?string $Comment; 53 | 54 | function __construct(string $transactionId, string $posTransactionId, float $amountToRefund, string $comment = null) 55 | { 56 | $this->TransactionId = $transactionId; 57 | $this->POSTransactionId = $posTransactionId; 58 | $this->AmountToRefund = $amountToRefund; 59 | $this->Comment = $comment; 60 | } 61 | } -------------------------------------------------------------------------------- /library/Models/Refund/RefundRequestModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Refund; 20 | 21 | use Barion\Models\BaseRequestModel; 22 | use Barion\Interfaces\IPaymentTransactionContainer; 23 | use Barion\Models\Payment\{ 24 | TransactionToRefundModel 25 | }; 26 | 27 | /** 28 | * Model used to request the refund of a previously completed payment transaction. 29 | */ 30 | class RefundRequestModel extends BaseRequestModel implements IPaymentTransactionContainer 31 | { 32 | /** 33 | * The Barion identifier of the payment. 34 | * 35 | * @var string 36 | */ 37 | public string $PaymentId; 38 | 39 | /** 40 | * Array of transactions in the payment that are to be refunded. 41 | * 42 | * @var array 43 | */ 44 | public array $TransactionsToRefund; 45 | 46 | function __construct(string $paymentId) 47 | { 48 | $this->PaymentId = $paymentId; 49 | $this->TransactionsToRefund = array(); 50 | } 51 | 52 | /** 53 | * Add a single transaction to the refund request. 54 | * 55 | * @param TransactionToRefundModel $transaction Model describing the transaction to be refunded. 56 | * @return void 57 | */ 58 | public function AddTransaction(TransactionToRefundModel $transaction) : void 59 | { 60 | $this->TransactionsToRefund[] = $transaction; 61 | } 62 | 63 | /** 64 | * Add multiple transactions to the refund request. 65 | * 66 | * @param array $transactions 67 | * @return void 68 | */ 69 | public function AddTransactions(array $transactions) : void 70 | { 71 | if (!empty($transactions)) { 72 | foreach ($transactions as $transaction) { 73 | if ($transaction instanceof TransactionToRefundModel) { 74 | $this->AddTransaction($transaction); 75 | } 76 | } 77 | } 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /library/Models/Refund/RefundResponseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Refund; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Models\BaseResponseModel; 23 | use Barion\Helpers\JSON; 24 | 25 | /** 26 | * Model containing the response data after a refund request sent to the Barion API. 27 | */ 28 | class RefundResponseModel extends BaseResponseModel implements IBarionModel 29 | { 30 | /** 31 | * The Barion identifier of the payment. 32 | * 33 | * @var ?string 34 | */ 35 | public ?string $PaymentId; 36 | 37 | /** 38 | * Array of transactions that were refunded during the request. 39 | * 40 | * @var array 41 | */ 42 | public array $RefundedTransactions; 43 | 44 | function __construct() 45 | { 46 | parent::__construct(); 47 | $this->PaymentId = null; 48 | $this->RefundedTransactions = array(); 49 | } 50 | 51 | public function fromJson(array $json) : void 52 | { 53 | if (!empty($json)) { 54 | parent::fromJson($json); 55 | 56 | $this->PaymentId = JSON::getString($json, 'PaymentId'); 57 | $this->RefundedTransactions = array(); 58 | 59 | $refundedTransactions = JSON::getArray($json, 'RefundedTransactions'); 60 | 61 | if (!empty($refundedTransactions)) { 62 | foreach ($refundedTransactions as $key => $refundedTransaction) { 63 | $tr = new RefundedTransactionModel(); 64 | $tr->fromJson($refundedTransaction); 65 | $this->RefundedTransactions[] = $tr; 66 | } 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /library/Models/Refund/RefundedTransactionModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\Refund; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Enumerations\{ 24 | TransactionStatus 25 | }; 26 | 27 | /** 28 | * Model containing information that was refunded via the Barion system. 29 | */ 30 | class RefundedTransactionModel implements IBarionModel 31 | { 32 | /** 33 | * The Barion identifier of the refunded transaction. 34 | * 35 | * @var ?string 36 | */ 37 | public ?string $TransactionId; 38 | 39 | /** 40 | * The total amount of the refunded transaction. 41 | * 42 | * @var ?float 43 | */ 44 | public ?float $Total; 45 | 46 | /** 47 | * The internal identifier of the refunded transaction, specified by the shop when starting the payment. 48 | * 49 | * @var ?string 50 | */ 51 | public ?string $POSTransactionId; 52 | 53 | /** 54 | * The comment for the refund. 55 | * 56 | * @var ?string 57 | */ 58 | public ?string $Comment; 59 | 60 | /** 61 | * The status of the refunded transaction. 62 | * 63 | * @var TransactionStatus 64 | */ 65 | public TransactionStatus $Status; 66 | 67 | function __construct() 68 | { 69 | $this->TransactionId = ""; 70 | $this->Total = 0.0; 71 | $this->POSTransactionId = null; 72 | $this->Comment = null; 73 | $this->Status = TransactionStatus::Unknown; 74 | } 75 | 76 | public function fromJson(array $json) : void 77 | { 78 | if (!empty($json)) { 79 | $this->TransactionId = JSON::getString($json, 'TransactionId'); 80 | $this->Total = JSON::getFloat($json, 'Total'); 81 | $this->POSTransactionId = JSON::getString($json, 'POSTransactionId'); 82 | $this->Comment = JSON::getString($json, 'Comment'); 83 | $this->Status = TransactionStatus::from(JSON::getString($json, 'Status') ?? 'Unknown'); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /library/Models/ThreeDSecure/BillingAddressModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\ThreeDSecure; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model representing a billing address used during a 3D-Secure card payment process. 26 | */ 27 | class BillingAddressModel implements IBarionModel 28 | { 29 | /** 30 | * The 2-character code (ISO-3166-2 format) of the country of the address. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $Country; 35 | 36 | /** 37 | * The 2-character code (ISO-3166-2 format) of the region of the address, if applicable. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $Region; 42 | 43 | /** 44 | * The city part of the address. 45 | * 46 | * @var ?string 47 | */ 48 | public ?string $City; 49 | 50 | /** 51 | * The zip/postal code of the address. 52 | * 53 | * @var ?string 54 | */ 55 | public ?string $Zip; 56 | 57 | /** 58 | * First line of the whole street address. 59 | * 60 | * @var ?string 61 | */ 62 | public ?string $Street; 63 | 64 | /** 65 | * Second line of the whole street address, if applicable. 66 | * 67 | * @var ?string 68 | */ 69 | public ?string $Street2; 70 | 71 | /** 72 | * Third line of the whole street address, if applicable. 73 | * 74 | * @var ?string 75 | */ 76 | public ?string $Street3; 77 | 78 | function __construct() 79 | { 80 | $this->Country = null; 81 | $this->Region = null; 82 | $this->City = null; 83 | $this->Zip = null; 84 | $this->Street = null; 85 | $this->Street2 = null; 86 | $this->Street3 = null; 87 | } 88 | 89 | public function fromJson(array $json) : void 90 | { 91 | if (!empty($json)) { 92 | $this->Country = JSON::getString($json, 'Country'); 93 | $this->Region = JSON::getString($json, 'Region'); 94 | $this->City = JSON::getString($json, 'City'); 95 | $this->Zip = JSON::getString($json, 'Zip'); 96 | $this->Street = JSON::getString($json, 'Street'); 97 | $this->Street2 = JSON::getString($json, 'Street2'); 98 | $this->Street3 = JSON::getString($json, 'Street3'); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /library/Models/ThreeDSecure/GiftCardPurchaseModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\ThreeDSecure; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model describing a gift card purchase during a 3D-Secure card payment process. 26 | */ 27 | class GiftCardPurchaseModel implements IBarionModel 28 | { 29 | /** 30 | * The total amount of all gift cards that are being purchased during the payment. 31 | * 32 | * @var ?float 33 | */ 34 | public ?float $Amount; 35 | 36 | /** 37 | * The number of gift cards being purchased during the payment. 38 | * 39 | * @var ?int 40 | */ 41 | public ?int $Count; 42 | 43 | function __construct() 44 | { 45 | $this->Amount = 0.0; 46 | $this->Count = 0; 47 | } 48 | 49 | public function fromJson(array $json) : void 50 | { 51 | if (!empty($json)) { 52 | $this->Amount = JSON::getFloat($json, 'Amount'); 53 | $this->Count = JSON::getInt($json, 'Count'); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /library/Models/ThreeDSecure/PayerAccountInformationModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\ThreeDSecure; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Enumerations\ThreeDSecure\{ 24 | AccountChangeIndicator, 25 | AccountCreationIndicator, 26 | PasswordChangeIndicator, 27 | PaymentMethodIndicator, 28 | ShippingAddressUsageIndicator, 29 | SuspiciousActivityIndicator 30 | }; 31 | 32 | /** 33 | * Model containing information about the payer during a 3D-Secure card payment process. 34 | */ 35 | class PayerAccountInformationModel implements IBarionModel 36 | { 37 | /** 38 | * The account number of the payer, if applicable. 39 | * 40 | * @var ?string 41 | */ 42 | public ?string $AccountId; 43 | 44 | /** 45 | * ISO-8601 format timestamp of the creation of the payer account. 46 | * 47 | * @var ?string 48 | */ 49 | public ?string $AccountCreated; 50 | 51 | /** 52 | * Indicator describing the time since the payer account has been created. 53 | * 54 | * @var AccountCreationIndicator 55 | */ 56 | public AccountCreationIndicator $AccountCreationIndicator; 57 | 58 | /** 59 | * ISO-8601 format timestamp of the last change of the payer account. 60 | * 61 | * @var ?string 62 | */ 63 | public ?string $AccountLastChanged; 64 | 65 | /** 66 | * Indicator describing the time since the payer account has been changed. 67 | * 68 | * @var AccountChangeIndicator 69 | */ 70 | public AccountChangeIndicator $AccountChangeIndicator; 71 | 72 | /** 73 | * ISO-8601 format timestamp of the last password change of the payer account. 74 | * 75 | * @var ?string 76 | */ 77 | public ?string $PasswordLastChanged; 78 | 79 | /** 80 | * Indicator describing the time since the last password change regarding the payer account. 81 | * 82 | * @var PasswordChangeIndicator 83 | */ 84 | public PasswordChangeIndicator $PasswordChangeIndicator; 85 | 86 | /** 87 | * Number of successful purchases during the last six months made by the payer account. 88 | * 89 | * @var ?int 90 | */ 91 | public ?int $PurchasesInTheLastSixMonths; 92 | 93 | /** 94 | * ISO-8601 format timestamp when a shipping address was last added to the payer account. 95 | * 96 | * @var ?string 97 | */ 98 | public ?string $ShippingAddressAdded; 99 | 100 | /** 101 | * Indicator describing how long ago was the shipping address added to the payer account. 102 | * 103 | * @var ShippingAddressUsageIndicator 104 | */ 105 | public ShippingAddressUsageIndicator $ShippingAddressUsageIndicator; 106 | 107 | /** 108 | * ISO-8601 format timestamp when a payment method was last added to the payer account. 109 | * 110 | * @var ?string 111 | */ 112 | public ?string $PaymentMethodAdded; 113 | 114 | /** 115 | * Indicator describing how long ago was the payment method added to the payer account. 116 | * 117 | * @var PaymentMethodIndicator 118 | */ 119 | public PaymentMethodIndicator $PaymentMethodIndicator; 120 | 121 | /** 122 | * Number of successfully added payment methods (e.g. bank cards) the payer account during the last 24 hours. 123 | * 124 | * @var ?int 125 | */ 126 | public ?int $ProvisionAttempts; 127 | 128 | /** 129 | * Number of successful transactions made by the payer account in the last 24 hours. 130 | * 131 | * @var ?int 132 | */ 133 | public ?int $TransactionalActivityPerDay; 134 | 135 | /** 136 | * Number of successful transactions made by the payer account in the last 365 days. 137 | * 138 | * @var ?int 139 | */ 140 | public ?int $TransactionalActivityPerYear; 141 | 142 | /** 143 | * Indicator about any suspicious activity regarding the payer account. 144 | * 145 | * @var SuspiciousActivityIndicator 146 | */ 147 | public SuspiciousActivityIndicator $SuspiciousActivityIndicator; 148 | 149 | function __construct() 150 | { 151 | $this->AccountId = null; 152 | $this->AccountCreated = null; 153 | $this->AccountCreationIndicator = AccountCreationIndicator::Unspecified; 154 | $this->AccountLastChanged = null; 155 | $this->AccountChangeIndicator = AccountChangeIndicator::Unspecified; 156 | $this->PasswordLastChanged = null; 157 | $this->PasswordChangeIndicator = PasswordChangeIndicator::Unspecified; 158 | $this->PurchasesInTheLastSixMonths = null; 159 | $this->ShippingAddressAdded = null; 160 | $this->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::Unspecified; 161 | $this->PaymentMethodAdded = null; 162 | $this->PaymentMethodIndicator = PaymentMethodIndicator::Unspecified; 163 | $this->ProvisionAttempts = null; 164 | $this->TransactionalActivityPerDay = null; 165 | $this->TransactionalActivityPerYear = null; 166 | $this->SuspiciousActivityIndicator = SuspiciousActivityIndicator::Unspecified; 167 | } 168 | 169 | public function fromJson(array $json) : void 170 | { 171 | if (!empty($json)) { 172 | $this->AccountId = JSON::getString($json, 'AccountId'); 173 | $this->AccountCreated = JSON::getString($json, 'AccountCreated'); 174 | $this->AccountCreationIndicator = AccountCreationIndicator::from(JSON::getString($json, 'AccountCreationIndicator') ?? ''); 175 | $this->AccountLastChanged = JSON::getString($json, 'AccountLastChanged'); 176 | $this->AccountChangeIndicator = AccountChangeIndicator::from(JSON::getString($json, 'AccountChangeIndicator') ?? ''); 177 | $this->PasswordLastChanged = JSON::getString($json, 'PasswordLastChanged'); 178 | $this->PasswordChangeIndicator = PasswordChangeIndicator::from(JSON::getString($json, 'PasswordChangeIndicator') ?? ''); 179 | $this->PurchasesInTheLastSixMonths = JSON::getInt($json, 'PurchasesInTheLastSixMonths'); 180 | $this->ShippingAddressAdded = JSON::getString($json, 'ShippingAddressAdded'); 181 | $this->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::from(JSON::getString($json, 'ShippingAddressUsageIndicator') ?? ''); 182 | $this->PaymentMethodAdded = JSON::getString($json, 'PaymentMethodAdded'); 183 | $this->PaymentMethodIndicator = PaymentMethodIndicator::from(JSON::getString($json, 'PaymentMethodIndicator') ?? ''); 184 | $this->ProvisionAttempts = JSON::getInt($json, 'ProvisionAttempts'); 185 | $this->TransactionalActivityPerDay = JSON::getInt($json, 'TransactionalActivityPerDay'); 186 | $this->TransactionalActivityPerYear = JSON::getInt($json, 'TransactionalActivityPerYear'); 187 | $this->SuspiciousActivityIndicator = SuspiciousActivityIndicator::from(JSON::getString($json, 'SuspiciousActivityIndicator') ?? ''); 188 | } 189 | } 190 | } -------------------------------------------------------------------------------- /library/Models/ThreeDSecure/PurchaseInformationModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\ThreeDSecure; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | use Barion\Enumerations\ThreeDSecure\{ 24 | AvailabilityIndicator, 25 | DeliveryTimeframeType, 26 | PurchaseType, 27 | ReOrderIndicator, 28 | ShippingAddressIndicator 29 | }; 30 | 31 | /** 32 | * Model containing information about the purchase during a 3D-Secure card payment process. 33 | */ 34 | class PurchaseInformationModel implements IBarionModel 35 | { 36 | /** 37 | * Indicator about the delivery speed of the purchase. 38 | * 39 | * @var DeliveryTimeframeType 40 | */ 41 | public DeliveryTimeframeType $DeliveryTimeframe; 42 | 43 | /** 44 | * The e-mail address attached to the delivery, if applicable. 45 | * 46 | * @var ?string 47 | */ 48 | public ?string $DeliveryEmailAddress; 49 | 50 | /** 51 | * ISO-8601 format timestamp when pre-ordered goods will be available, if applicable. 52 | * 53 | * @var ?string 54 | */ 55 | public ?string $PreOrderDate; 56 | 57 | /** 58 | * Indicator about the availability of a pre-ordered product, if applicable. 59 | * 60 | * @var AvailabilityIndicator 61 | */ 62 | public AvailabilityIndicator $AvailabilityIndicator; 63 | 64 | /** 65 | * Indicator describing if this purchase is a re-order of a previous purchase. 66 | * 67 | * @var ReOrderIndicator 68 | */ 69 | public ReOrderIndicator $ReOrderIndicator; 70 | 71 | /** 72 | * ISO-8601 format timestamp of the last moment when this purchase can be used a source for a recurring/token payment. 73 | * 74 | * @var ?string 75 | */ 76 | public ?string $RecurringExpiry; 77 | 78 | /** 79 | * The minimum number of days between subsequent payments. Only applicable if this is a "recurring payment" scenario. 80 | * 81 | * @var ?int 82 | */ 83 | public ?int $RecurringFrequency; 84 | 85 | /** 86 | * Indicator describing the method of shipping. 87 | * 88 | * @var ShippingAddressIndicator 89 | */ 90 | public ShippingAddressIndicator $ShippingAddressIndicator; 91 | 92 | /** 93 | * Model describing the details of a gift card purchase, if applicable. 94 | * 95 | * @var ?object 96 | */ 97 | public ?object $GiftCardPurchase; 98 | 99 | /** 100 | * Indicator describing the type of purchase regarding the nature of goods or services being sold. 101 | * 102 | * @var PurchaseType 103 | */ 104 | public PurchaseType $PurchaseType; 105 | 106 | /** 107 | * ISO-8601 format timestamp of the purchase. 108 | * 109 | * @var ?string 110 | */ 111 | public ?string $PurchaseDate; 112 | 113 | function __construct() 114 | { 115 | $this->DeliveryTimeframe = DeliveryTimeframeType::Unspecified; 116 | $this->DeliveryEmailAddress = null; 117 | $this->PreOrderDate = null; 118 | $this->AvailabilityIndicator = AvailabilityIndicator::Unspecified; 119 | $this->ReOrderIndicator = ReOrderIndicator::Unspecified; 120 | $this->RecurringExpiry = null; 121 | $this->RecurringFrequency = null; 122 | $this->ShippingAddressIndicator = ShippingAddressIndicator::Unspecified; 123 | $this->GiftCardPurchase = null; 124 | $this->PurchaseType = PurchaseType::Unspecified; 125 | $this->PurchaseDate = null; 126 | } 127 | 128 | public function fromJson(array $json) : void 129 | { 130 | if (!empty($json)) { 131 | $this->DeliveryTimeframe = DeliveryTimeframeType::from(JSON::getString($json, 'DeliveryTimeframe') ?? ''); 132 | $this->DeliveryEmailAddress = JSON::getString($json, 'DeliveryEmailAddress'); 133 | $this->PreOrderDate = JSON::getString($json, 'PreOrderDate'); 134 | $this->AvailabilityIndicator = AvailabilityIndicator::from(JSON::getString($json, 'AvailabilityIndicator') ?? ''); 135 | $this->ReOrderIndicator = ReOrderIndicator::from(JSON::getString($json, 'ReOrderIndicator') ?? ''); 136 | $this->RecurringExpiry = JSON::getString($json, 'RecurringExpiry'); 137 | $this->RecurringFrequency = JSON::getInt($json, 'RecurringFrequency'); 138 | $this->ShippingAddressIndicator = ShippingAddressIndicator::from(JSON::getString($json, 'ShippingAddressIndicator') ?? ''); 139 | $this->GiftCardPurchase = JSON::getObject($json, 'GiftCardPurchase'); 140 | $this->PurchaseType = PurchaseType::from(JSON::getString($json, 'PurchaseType') ?? ''); 141 | $this->PurchaseDate = JSON::getString($json, 'PurchaseDate'); 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /library/Models/ThreeDSecure/ShippingAddressModel.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion\Models\ThreeDSecure; 20 | 21 | use Barion\Interfaces\IBarionModel; 22 | use Barion\Helpers\JSON; 23 | 24 | /** 25 | * Model representing a shipping address used during a 3D-Secure card payment process. 26 | */ 27 | class ShippingAddressModel implements IBarionModel 28 | { 29 | /** 30 | * The 2-character code (ISO-3166-2 format) of the country of the address. 31 | * 32 | * @var ?string 33 | */ 34 | public ?string $Country; 35 | 36 | /** 37 | * The 2-character code (ISO-3166-2 format) of the region of the address, if applicable. 38 | * 39 | * @var ?string 40 | */ 41 | public ?string $Region; 42 | 43 | /** 44 | * The city part of the address. 45 | * 46 | * @var ?string 47 | */ 48 | public ?string $City; 49 | 50 | /** 51 | * The zip/postal code of the address. 52 | * 53 | * @var ?string 54 | */ 55 | public ?string $Zip; 56 | 57 | /** 58 | * First line of the whole street address. 59 | * 60 | * @var ?string 61 | */ 62 | public ?string $Street; 63 | 64 | /** 65 | * Second line of the whole street address, if applicable. 66 | * 67 | * @var ?string 68 | */ 69 | public ?string $Street2; 70 | 71 | /** 72 | * Third line of the whole street address, if applicable. 73 | * 74 | * @var ?string 75 | */ 76 | public ?string $Street3; 77 | 78 | /** 79 | * The full name of the recipient of the shipping. 80 | * 81 | * @var ?string 82 | */ 83 | public ?string $FullName; 84 | 85 | function __construct() 86 | { 87 | $this->Country = null; 88 | $this->Region = null; 89 | $this->City = null; 90 | $this->Zip = null; 91 | $this->Street = null; 92 | $this->Street2 = null; 93 | $this->Street3 = null; 94 | $this->FullName = null; 95 | } 96 | 97 | public function fromJson(array $json) : void 98 | { 99 | if (!empty($json)) { 100 | $this->Country = JSON::getString($json, 'Country'); 101 | $this->Region = JSON::getString($json, 'Region'); 102 | $this->City = JSON::getString($json, 'City'); 103 | $this->Zip = JSON::getString($json, 'Zip'); 104 | $this->Street = JSON::getString($json, 'Street'); 105 | $this->Street2 = JSON::getString($json, 'Street2'); 106 | $this->Street3 = JSON::getString($json, 'Street3'); 107 | $this->FullName = JSON::getString($json, 'FullName'); 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /library/SSL/gd_bundle-g2.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIE0DCCA7igAwIBAgIBBzANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx 3 | EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT 4 | EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp 5 | ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTExMDUwMzA3MDAwMFoXDTMxMDUwMzA3 6 | MDAwMFowgbQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH 7 | EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjEtMCsGA1UE 8 | CxMkaHR0cDovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkvMTMwMQYDVQQD 9 | EypHbyBEYWRkeSBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IC0gRzIwggEi 10 | MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC54MsQ1K92vdSTYuswZLiBCGzD 11 | BNliF44v/z5lz4/OYuY8UhzaFkVLVat4a2ODYpDOD2lsmcgaFItMzEUz6ojcnqOv 12 | K/6AYZ15V8TPLvQ/MDxdR/yaFrzDN5ZBUY4RS1T4KL7QjL7wMDge87Am+GZHY23e 13 | cSZHjzhHU9FGHbTj3ADqRay9vHHZqm8A29vNMDp5T19MR/gd71vCxJ1gO7GyQ5HY 14 | pDNO6rPWJ0+tJYqlxvTV0KaudAVkV4i1RFXULSo6Pvi4vekyCgKUZMQWOlDxSq7n 15 | eTOvDCAHf+jfBDnCaQJsY1L6d8EbyHSHyLmTGFBUNUtpTrw700kuH9zB0lL7AgMB 16 | AAGjggEaMIIBFjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV 17 | HQ4EFgQUQMK9J47MNIMwojPX+2yz8LQsgM4wHwYDVR0jBBgwFoAUOpqFBxBnKLbv 18 | 9r0FQW4gwZTaD94wNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8v 19 | b2NzcC5nb2RhZGR5LmNvbS8wNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL2NybC5n 20 | b2RhZGR5LmNvbS9nZHJvb3QtZzIuY3JsMEYGA1UdIAQ/MD0wOwYEVR0gADAzMDEG 21 | CCsGAQUFBwIBFiVodHRwczovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkv 22 | MA0GCSqGSIb3DQEBCwUAA4IBAQAIfmyTEMg4uJapkEv/oV9PBO9sPpyIBslQj6Zz 23 | 91cxG7685C/b+LrTW+C05+Z5Yg4MotdqY3MxtfWoSKQ7CC2iXZDXtHwlTxFWMMS2 24 | RJ17LJ3lXubvDGGqv+QqG+6EnriDfcFDzkSnE3ANkR/0yBOtg2DZ2HKocyQetawi 25 | DsoXiWJYRBuriSUBAA/NxBti21G00w9RKpv0vHP8ds42pM3Z2Czqrpv1KrKQ0U11 26 | GIo/ikGQI31bS/6kA1ibRrLDYGCD+H1QQc7CoZDDu+8CL9IVVO5EFdkKrqeKM+2x 27 | LXY2JtwE65/3YR8V3Idv7kaWKK2hJn0KCacuBKONvPi8BDAB 28 | -----END CERTIFICATE----- 29 | -----BEGIN CERTIFICATE----- 30 | MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx 31 | EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT 32 | EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp 33 | ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz 34 | NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH 35 | EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE 36 | AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw 37 | DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD 38 | E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH 39 | /PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy 40 | DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh 41 | GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR 42 | tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA 43 | AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE 44 | FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX 45 | WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu 46 | 9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr 47 | gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo 48 | 2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO 49 | LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI 50 | 4uJEvlz36hz1 51 | -----END CERTIFICATE----- 52 | -------------------------------------------------------------------------------- /library/autoload.php: -------------------------------------------------------------------------------- 1 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | *

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Barion; 20 | 21 | /* 22 | * Autoloader for the Barion library. 23 | */ 24 | 25 | use DirectoryIterator; 26 | 27 | $include_dirs = Array( 28 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Interfaces"))), 29 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Exceptions"))), 30 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Enumerations"))), 31 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Enumerations/ThreeDSecure"))), 32 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Helpers"))), 33 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models"))), 34 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models/Common"))), 35 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models/Error"))), 36 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models/ThreeDSecure"))), 37 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models/Payment"))), 38 | realpath(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "Models/Refund"))) 39 | ); 40 | 41 | foreach ($include_dirs as $directoryKey => $directoryName) { 42 | $files = new DirectoryIterator(strval($directoryName)); 43 | foreach ($files as $fileInfo) { 44 | if (!$fileInfo->isDot() && !$fileInfo->isDir()) { 45 | $filePath = $directoryName . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); 46 | require_once $filePath; 47 | } 48 | } 49 | } --------------------------------------------------------------------------------