diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9df1f6e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_STORE + +/vendor/ diff --git a/changelog.md b/changelog.md index d63889d..07021e1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # Changelog +### v1.4.3 2020-04-14 +- Added composer support and published the fork on packagist. + ### [v1.4.2](https://github.com/barion/barion-web-php/releases/tag/v1.4.2) 2019-08-15 - ADD: added RecurrenceType and ChallengePreference 3DS properties diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c0cb2c9 --- /dev/null +++ b/composer.json @@ -0,0 +1,28 @@ +{ + "name": "barion/barion-web-php", + "description": "Barion PHP library", + "keywords": [ + "barion", + "payment processing", + "api" + ], + "homepage": "https://www.barion.com", + "authors": [ + { + "name": "Barion and contributors", + "homepage": "https://github.com/barion/barion-web-php" + } + ], + "type": "library", + "require": { + "ext-curl": "*", + "php": ">=5.6" + }, + "license": "Apache-2.0", + "minimum-stability": "dev", + "autoload": { + "psr-4": { + "Barion\\": "library/" + } + } +} diff --git a/docs/delayed_capture.md b/docs/delayed_capture.md index c07c94c..ebaab73 100644 --- a/docs/delayed_capture.md +++ b/docs/delayed_capture.md @@ -6,10 +6,10 @@ In this example we are going to start a delayed capture payment, where the amoun To start an online payment, you have to create one or more **Payment Transaction** objects, add transaction **Items** to them, then group these transactions together in a **Payment** object. -First, create an **ItemModel** instance: +First, create an **Barion\Models\Common\ItemModel** instance: ```php -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "J.K. Rowling - Harry Potter and the chamber of secrets"; $item->Description = "Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts."; $item->Quantity = 1; @@ -19,31 +19,31 @@ $item->ItemTotal = 9.99; $item->SKU = "HPbk2"; ``` -Then create a **PaymentTransactionModel** and add the two **ItemModel** instances mentioned above to it: +Then create a **Barion\Models\Payment\PaymentTransactionModel** and add the two **Barion\Models\Common\ItemModel** instances mentioned above to it: ```php -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = "barionaccount@demo-merchant.shop"; $trans->Total = 9.99; -$trans->Currency = Currency::EUR; +$trans->Currency = Barion\Common\Currency::EUR; $trans->Comment = "Test transaction containing the product"; $trans->AddItem($item); ``` -Finally, create a **PreparePaymentRequestModel** and add the **PaymentTransactionModel** mentioned above to it: +Finally, create a **Barion\Models\Payment\PreparePaymentRequestModel** and add the **Barion\Models\Payment\PaymentTransactionModel** mentioned above to it: ```php -$ppr = new PreparePaymentRequestModel(); +$ppr = new Barion\Models\Payment\PreparePaymentRequestModel(); $ppr->GuestCheckout = true; -$ppr->PaymentType = PaymentType::DelayedCapture; +$ppr->PaymentType = Barion\Common\PaymentType::DelayedCapture; $ppr->DelayedCapturePeriod = "1.00:00:00"; -$ppr->FundingSources = array(FundingSourceType::All); +$ppr->FundingSources = array(Barion\Common\FundingSourceType::All); $ppr->PaymentRequestId = "PAYMENT-01"; $ppr->PayerHint = "user@example.com"; -$ppr->Locale = UILocale::EN; +$ppr->Locale = Barion\Common\UILocale::EN; $ppr->OrderNumber = "ORDER-0001"; -$ppr->Currency = Currency::EUR; +$ppr->Currency = Barion\Common\Currency::EUR; $ppr->RedirectUrl = "http://webshop.example.com/afterpayment"; $ppr->CallbackUrl = "http://webshop.example.com/processpayment"; $ppr->AddTransaction($trans); @@ -52,7 +52,7 @@ $ppr->AddTransaction($trans); At this point, the complete request object looks like this: ``` -PreparePaymentRequestModel Object +\Barion\Models\Payment\PreparePaymentRequestModel Object ( [PaymentType] => DelayedCapture [ReservationPeriod] => @@ -68,7 +68,7 @@ PreparePaymentRequestModel Object [PayerHint] => user@example.com [Transactions] => Array ( - [0] => PaymentTransactionModel Object + [0] => \Barion\Models\Payment\PaymentTransactionModel Object ( [POSTransactionId] => TRANS-01 [Payee] => barionaccount@demo-merchant.shop @@ -76,7 +76,7 @@ PreparePaymentRequestModel Object [Comment] => Test transaction containing the product [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -129,17 +129,17 @@ $myPayment = $BC->PreparePayment($ppr); The Barion API now prepares a payment entity that can be paid by anyone. -The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **PreparePaymentResponseModel** object. It should look something like this: +The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PreparePaymentResponseModel** object. It should look something like this: ``` -PreparePaymentResponseModel Object +\Barion\Models\Payment\PreparePaymentResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 [Status] => Prepared [Transactions] => Array ( - [0] => TransactionResponseModel Object + [0] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => TRANS-01 [TransactionId] => 277edf17c7ce468a83f538102b4109be @@ -197,10 +197,10 @@ To request payment details, we call the **GetPaymentState** method of the Barion $paymentDetails = $BC->GetPaymentState("64157032-d3dc-4296-aeda-fd4b0994c64e"); ``` -The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **PaymentStateResponseModel** object. It should look something like this: +The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PaymentStateResponseModel** object. It should look something like this: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 @@ -211,9 +211,9 @@ PaymentStateResponseModel Object [Status] => Prepared [PaymentType] => DelayedCapture [FundingSource] => - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => [BankCardType] => @@ -238,20 +238,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:07:57.755Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -262,7 +262,7 @@ PaymentStateResponseModel Object [TransactionType] => Unspecified [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -293,12 +293,12 @@ PaymentStateResponseModel Object [RequestSuccessful] => 1 ) -FinishReservationRequestModel Object +\Barion\Models\Payment\FinishReservationRequestModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [Transactions] => Array ( - [0] => TransactionToFinishModel Object + [0] => \Barion\Models\Payment\TransactionToFinishModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [Total] => 499.95 @@ -308,7 +308,7 @@ FinishReservationRequestModel Object [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -319,7 +319,7 @@ FinishReservationRequestModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => [PRODUCT UNAVAILABLE] BestPresso XL Coffee Machine [Description] => [PRODUCT UNAVAILABLE] BPC4000 XL professional coffee machine, 3-year warranty @@ -345,7 +345,7 @@ The payment is in **Prepared** status, which means it is still waiting to be pai If we wait until the user completes the payment, and send the request again, we should get a slightly different result with more information: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 @@ -356,9 +356,9 @@ PaymentStateResponseModel Object [Status] => Authorized [PaymentType] => DelayedCapture [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -383,20 +383,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:07:57.755Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -407,7 +407,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -443,10 +443,10 @@ PaymentStateResponseModel Object As you can see, the payment status is now **Authorized**, which means the customer has paid the amount and it is blocked on the bank card. At this point, the webshop has one day to capture the amount, as it was previously indicated in the **DelayedCapturePeriod** parameter when the payment was started. -The shop can capture the amount by constructing the appropriate **CaptureRequestModel** instance: +The shop can capture the amount by constructing the appropriate **Barion\Models\Payment\CaptureRequestModel** instance: ```php -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "J.K. Rowling - Harry Potter and the chamber of secrets"; $item->Description = "Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts."; $item->Quantity = 1; @@ -455,25 +455,25 @@ $item->UnitPrice = 9.99; $item->ItemTotal = 9.99; $item->SKU = "HPbk2"; -$trans = new TransactionToCaptureModel(); +$trans = new Barion\Models\Payment\TransactionToCaptureModel(); $trans->TransactionId = $paymentDetails->Transactions[0]->TransactionId; $trans->Total = 9.99; $trans->Comment = "Test transaction containing the product"; $trans->AddItem($item); -$crm = new CaptureRequestModel($paymentDetails->PaymentId); +$crm = new Barion\Models\Payment\CaptureRequestModel($paymentDetails->PaymentId); $crm->AddTransaction($trans); ``` The full request for capturing the amount looks like this: ``` -CaptureRequestModel Object +\Barion\Models\Payment\CaptureRequestModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [Transactions] => Array ( - [0] => TransactionToCaptureModel Object + [0] => \Barion\Models\Payment\TransactionToCaptureModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [Total] => 9.99 @@ -483,7 +483,7 @@ CaptureRequestModel Object [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -513,7 +513,7 @@ $captureResult = $BC->Capture($crm); When sending the request, the following response arrives: ``` -CaptureResponseModel Object +\Barion\Models\Payment\CaptureResponseModel Object ( [IsSuccessful] => 1 [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 @@ -521,7 +521,7 @@ CaptureResponseModel Object [Status] => Succeeded [Transactions] => Array ( - [0] => TransactionResponseModel Object + [0] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => TRANS-01 [TransactionId] => 277edf17c7ce468a83f538102b4109be @@ -530,7 +530,7 @@ CaptureResponseModel Object [RelatedId] => ) - [1] => TransactionResponseModel Object + [1] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => 0d5645a581654b8b940ddcefff41ce73 @@ -554,7 +554,7 @@ This shows that everything went okay, the request was successful. The amount has If the webshop requests the payment details once more, you can see the completed state: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 @@ -565,9 +565,9 @@ PaymentStateResponseModel Object [Status] => Succeeded [PaymentType] => DelayedCapture [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -592,20 +592,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:07:57.755Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -616,7 +616,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -634,20 +634,20 @@ PaymentStateResponseModel Object [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 0d5645a581654b8b940ddcefff41ce73 [POSTransactionId] => [TransactionTime] => 2019-08-12T05:17:55.565Z [Total] => 0.1 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => diff --git a/docs/immediate_payment.md b/docs/immediate_payment.md index 20a925f..5a9aef1 100644 --- a/docs/immediate_payment.md +++ b/docs/immediate_payment.md @@ -6,10 +6,10 @@ Let's see a basic example of using the Barion library. We are going to start an To start an online payment, you have to create one or more **Payment Transaction** objects, add transaction **Items** to them, then group these transactions together in a **Payment** object. -First, create an **ItemModel**: +First, create an **Barion\Models\Common\ItemModel**: ```php -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; $item->Description = "A test product"; $item->Quantity = 1; @@ -19,30 +19,30 @@ $item->ItemTotal = 1000; $item->SKU = "ITEM-01"; ``` -Then create a **PaymentTransactionModel** and add the **Item** mentioned above to it: +Then create a **Barion\Models\Payment\PaymentTransactionModel** and add the **Item** mentioned above to it: ```php -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = "webshop@example.com"; $trans->Total = 1000; -$trans->Currency = Currency::HUF; +$trans->Currency = Barion\Common\Currency::HUF; $trans->Comment = "Test transaction containing the product"; $trans->AddItem($item); ``` -Finally, create a **PreparePaymentRequestModel** and add the **PaymentTransactionModel** mentioned above to it: +Finally, create a **Barion\Models\Payment\PreparePaymentRequestModel** and add the **Barion\Models\Payment\PaymentTransactionModel** mentioned above to it: ```php -$ppr = new PreparePaymentRequestModel(); +$ppr = new Barion\Models\Payment\PreparePaymentRequestModel(); $ppr->GuestCheckout = true; -$ppr->PaymentType = PaymentType::Immediate; -$ppr->FundingSources = array(FundingSourceType::All); +$ppr->PaymentType = Barion\Common\PaymentType::Immediate; +$ppr->FundingSources = array(Barion\Common\FundingSourceType::All); $ppr->PaymentRequestId = "PAYMENT-01"; $ppr->PayerHint = "user@example.com"; -$ppr->Locale = UILocale::EN; +$ppr->Locale = Barion\Common\UILocale::EN; $ppr->OrderNumber = "ORDER-0001"; -$ppr->Currency = Currency::HUF; +$ppr->Currency = Barion\Common\Currency::HUF; $ppr->RedirectUrl = "http://webshop.example.com/afterpayment"; $ppr->CallbackUrl = "http://webshop.example.com/processpayment"; $ppr->AddTransaction($trans); @@ -51,7 +51,7 @@ $ppr->AddTransaction($trans); At this point, the complete request object looks like this: ``` -PreparePaymentRequestModel Object +\Barion\Models\Payment\PreparePaymentRequestModel Object ( [PaymentType] => Immediate [ReservationPeriod] => @@ -66,7 +66,7 @@ PreparePaymentRequestModel Object [PayerHint] => user@example.com [Transactions] => Array ( - [0] => PaymentTransactionModel Object + [0] => \Barion\Models\Payment\PaymentTransactionModel Object ( [POSTransactionId] => TRANS-01 [Payee] => webshop@example.com @@ -75,7 +75,7 @@ PreparePaymentRequestModel Object [Comment] => Test transaction containing the product [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => TestItem [Description] => A test product @@ -112,17 +112,17 @@ $myPayment = $BC->PreparePayment($ppr); The Barion API now prepares a payment entity that can be paid by anyone. -The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **PreparePaymentResponseModel** object. It should look something like this: +The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PreparePaymentResponseModel** object. It should look something like this: ``` -PreparePaymentResponseModel Object +\Barion\Models\Payment\PreparePaymentResponseModel Object ( [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e [PaymentRequestId] => PAYMENT-01 [Status] => Prepared [Transactions] => Array ( - [0] => TransactionResponseModel Object + [0] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => TRANS-01 [TransactionId] => fb06f46e-7a55-4da5-9a62-992089b3dd23 @@ -130,7 +130,7 @@ PreparePaymentResponseModel Object [TransactionTime] => 2015-11-12T09:24:14.074 [RelatedId] => ) - [1] => TransactionResponseModel Object + [1] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => 49a9c395-833a-445f-82dd-b1d12784b3ef @@ -138,7 +138,7 @@ PreparePaymentResponseModel Object [TransactionTime] => 2015-11-12T09:24:14.262 [RelatedId] => ) - [2] => TransactionResponseModel Object + [2] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => c91a0006-4b6b-41ed-bdbd-5cfb3d67528b @@ -193,10 +193,10 @@ To request payment details, we call the **GetPaymentState** method of the Barion $paymentDetails = $BC->GetPaymentState("64157032-d3dc-4296-aeda-fd4b0994c64e"); ``` -The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **PaymentStateResponseModel** object. It should look something like this: +The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PaymentStateResponseModel** object. It should look something like this: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e [PaymentRequestId] => PAYMENT-01 @@ -218,19 +218,19 @@ PaymentStateResponseModel Object [Currency] => HUF [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => fb06f46e-7a55-4da5-9a62-992089b3dd23 [POSTransactionId] => TRANS-01 [TransactionTime] => 2015-11-12T09:47:12.189 [Total] => 1000 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com @@ -240,7 +240,7 @@ PaymentStateResponseModel Object [TransactionType] => Unspecified [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => TestItem [Description] => A test product @@ -255,19 +255,19 @@ PaymentStateResponseModel Object [POSId] => 04ed8c89-c9bd-4c17-92f6-a0964587bbff [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 49a9c395-833a-445f-82dd-b1d12784b3ef [POSTransactionId] => [TransactionTime] => 2015-11-12T09:47:12.205 [Total] => 50 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -282,19 +282,19 @@ PaymentStateResponseModel Object [POSId] => 04ed8c89-c9bd-4c17-92f6-a0964587bbff [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e ) - [2] => TransactionDetailModel Object + [2] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => c91a0006-4b6b-41ed-bdbd-5cfb3d67528b [POSTransactionId] => [TransactionTime] => 2015-11-12T09:47:12.205 [Total] => 10 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -322,7 +322,7 @@ The payment is in **Prepared** status, which means it is still waiting to be pai If we wait until the user completes the payment, and send the request again, we should get a slightly different result with more information: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e [PaymentRequestId] => PAYMENT-01 @@ -331,9 +331,9 @@ PaymentStateResponseModel Object [Status] => Succeeded [PaymentType] => Immediate [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\\BankCardModel Object ( [MaskedPan] => 1234 [BankCardType] => MasterCard @@ -356,19 +356,19 @@ PaymentStateResponseModel Object [Currency] => HUF [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => fb06f46e-7a55-4da5-9a62-992089b3dd23 [POSTransactionId] => TRANS-01 [TransactionTime] => 2015-11-12T09:47:12.189 [Total] => 1000 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => John Doe [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com @@ -378,7 +378,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => TestItem [Description] => A test product @@ -393,19 +393,19 @@ PaymentStateResponseModel Object [POSId] => 04ed8c89-c9bd-4c17-92f6-a0964587bbff [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 49a9c395-833a-445f-82dd-b1d12784b3ef [POSTransactionId] => [TransactionTime] => 2015-11-12T09:47:12.205 [Total] => 50 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -420,19 +420,19 @@ PaymentStateResponseModel Object [POSId] => 04ed8c89-c9bd-4c17-92f6-a0964587bbff [PaymentId] => 64157032-d3dc-4296-aeda-fd4b0994c64e ) - [2] => TransactionDetailModel Object + [2] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => c91a0006-4b6b-41ed-bdbd-5cfb3d67528b [POSTransactionId] => [TransactionTime] => 2015-11-12T09:47:12.205 [Total] => 10 [Currency] => HUF - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => Example Webshop Technologies Ltd. [Email] => webshop@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => diff --git a/docs/payment_with_3dsecure_parameters.md b/docs/payment_with_3dsecure_parameters.md index 2d07635..ea04c05 100644 --- a/docs/payment_with_3dsecure_parameters.md +++ b/docs/payment_with_3dsecure_parameters.md @@ -9,10 +9,10 @@ The purpose of these parameters is to help the Barion API and the webshop cooper The process is identical to any other simple payment scenario, only the parameter count changed. -There is one or more **ItemModel** describing the product, as usual: +There is one or more **Barion\Models\Common\ItemModel** describing the product, as usual: ```php -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; $item->Description = "A test item for payment"; $item->Quantity = 1; @@ -25,7 +25,7 @@ $item->SKU = "ITEM-01"; These items are then added to a transaction: ```php -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = $myEmailAddress; $trans->Total = 75; @@ -36,7 +36,7 @@ $trans->AddItem($item); And here come the additional parameters. First, the shipping and billing addresses: ```php -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "DE"; $shippingAddress->Region = null; $shippingAddress->City = "Berlin"; @@ -46,7 +46,7 @@ $shippingAddress->Street2 = "1. ebene"; $shippingAddress->Street3 = ""; $shippingAddress->FullName = "Thomas Testing"; -$billingAddress = new BillingAddressModel(); +$billingAddress = new Barion\Models\Secure3d\BillingAddressModel(); $billingAddress->Country = "DE"; $billingAddress->Region = null; $billingAddress->City = "Berlin"; @@ -58,55 +58,55 @@ $billingAddress->Street3 = ""; **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. -The webshop should supply as much information about the account of the customer as it can. This is done in the **PayerAccountInformationModel**. +The webshop should supply as much information about the account of the customer as it can. This is done in the **Barion\Models\Secure3d\PayerAccountInformationModel**. ```php -$payerAccountInfo = new PayerAccountInformationModel(); +$payerAccountInfo = new Barion\Models\Secure3d\PayerAccountInformationModel(); $payerAccountInfo->AccountId = "4444888888885559"; $payerAccountInfo->AccountCreated = $now; -$payerAccountInfo->AccountCreationIndicator = AccountCreationIndicator::CreatedDuringThisTransaction; +$payerAccountInfo->AccountCreationIndicator = Barion\Common\Secure3d\AccountCreationIndicator::CreatedDuringThisTransaction; $payerAccountInfo->AccountLastChanged = $now; -$payerAccountInfo->AccountChangeIndicator = AccountChangeIndicator::ChangedDuringThisTransaction; +$payerAccountInfo->AccountChangeIndicator = Barion\Common\Secure3d\AccountChangeIndicator::ChangedDuringThisTransaction; $payerAccountInfo->PasswordLastChanged = $now; -$payerAccountInfo->PasswordChangeIndicator = PasswordChangeIndicator::NoChange; +$payerAccountInfo->PasswordChangeIndicator = Barion\Common\Secure3d\PasswordChangeIndicator::NoChange; $payerAccountInfo->PurchasesInTheLastSixMonths = 6; $payerAccountInfo->ShippingAddressAdded = $now; -$payerAccountInfo->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::ThisTransaction; +$payerAccountInfo->ShippingAddressUsageIndicator = Barion\Common\Secure3d\ShippingAddressUsageIndicator::ThisTransaction; $payerAccountInfo->PaymentMethodAdded = $now; -$payerAccountInfo->PaymentMethodIndicator = PaymentMethodIndicator::ThisTransaction; +$payerAccountInfo->PaymentMethodIndicator = Barion\Common\Secure3d\PaymentMethodIndicator::ThisTransaction; $payerAccountInfo->ProvisionAttempts = 1; $payerAccountInfo->TransactionalActivityPerDay = 1; $payerAccountInfo->TransactionalActivityPerYear = 100; -$payerAccountInfo->SuspiciousActivityIndicator = SuspiciousActivityIndicator::NoSuspiciousActivityObserved; +$payerAccountInfo->SuspiciousActivityIndicator = Barion\Common\Secure3d\SuspiciousActivityIndicator::NoSuspiciousActivityObserved; ``` Similarly, all known information about the purchase itself shall be supplied in the **PurchaseInformationModel**: ```php -$purchaseInfo = new PurchaseInformationModel(); -$purchaseInfo->DeliveryTimeframe = DeliveryTimeFrameType::OvernightShipping; +$purchaseInfo = new Barion\Models\Secure3d\PurchaseInformationModel(); +$purchaseInfo->DeliveryTimeframe = Barion\Common\Secure3d\DeliveryTimeFrameType::OvernightShipping; $purchaseInfo->DeliveryEmailAddress = "user@example.com"; $purchaseInfo->PreOrderDate = "2019-08-01"; -$purchaseInfo->AvailabilityIndicator = AvailabilityIndicator::MerchandiseAvailable; -$purchaseInfo->ReOrderIndicator = ReOrderIndicator::FirstTimeOrdered; +$purchaseInfo->AvailabilityIndicator = Barion\Common\Secure3d\AvailabilityIndicator::MerchandiseAvailable; +$purchaseInfo->ReOrderIndicator = Barion\Common\Secure3d\ReOrderIndicator::FirstTimeOrdered; $purchaseInfo->RecurringExpiry = "2099-12-31 23:59:59"; $purchaseInfo->RecurringFrequency = "0"; -$purchaseInfo->ShippingAddressIndicator = ShippingAddressIndicator::ShipToCardholdersBillingAddress; +$purchaseInfo->ShippingAddressIndicator = Barion\Common\Secure3d\ShippingAddressIndicator::ShipToCardholdersBillingAddress; $purchaseInfo->GiftCardPurchase = null; -$purchaseInfo->PurchaseType = PurchaseType::GoodsAndServicePurchase; +$purchaseInfo->PurchaseType = Barion\Common\Secure3d\PurchaseType::GoodsAndServicePurchase; ``` -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. +Lastly, the final **Barion\Models\Payment\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. ```php -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; -$psr->PaymentType = PaymentType::Immediate; -$psr->FundingSources = array(FundingSourceType::All); +$psr->PaymentType = Barion\Common\PaymentType::Immediate; +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); $psr->PaymentRequestId = "TESTPAY-01"; $psr->PayerHint = "user@example.com"; -$psr->Locale = UILocale::EN; -$psr->Currency = Currency::EUR; +$psr->Locale = Barion\Common\UILocale::EN; +$psr->Currency = Barion\Common\Currency::EUR; $psr->OrderNumber = "ORDER-0001"; $psr->AddTransaction($trans); @@ -123,7 +123,7 @@ $psr->PurchaseInformation = $purchaseInfo; The complete payment request object looks like this: ``` -PreparePaymentRequestModel Object +\Barion\Models\Payment\PreparePaymentRequestModel Object ( [PaymentType] => Immediate [ReservationPeriod] => @@ -139,7 +139,7 @@ PreparePaymentRequestModel Object [PayerHint] => user@example.com [Transactions] => Array ( - [0] => PaymentTransactionModel Object + [0] => \Barion\Models\Payment\PaymentTransactionModel Object ( [POSTransactionId] => TRANS-01 [Payee] => barionaccount@demo-merchant.shop @@ -147,7 +147,7 @@ PreparePaymentRequestModel Object [Comment] => Test Transaction [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => TestItem [Description] => A test item for payment @@ -170,7 +170,7 @@ PreparePaymentRequestModel Object [Locale] => en-US [OrderNumber] => ORDER-0001 - [ShippingAddress] => ShippingAddressModel Object + [ShippingAddress] => \Barion\Models\Secure3d\ShippingAddressModel Object ( [Country] => DE [Region] => @@ -182,7 +182,7 @@ PreparePaymentRequestModel Object [FullName] => Thomas Testing ) - [BillingAddress] => BillingAddressModel Object + [BillingAddress] => \Barion\Models\Secure3d\BillingAddressModel Object ( [Country] => DE [Region] => @@ -202,7 +202,7 @@ PreparePaymentRequestModel Object [PayerPhoneNumber] => 36301122334 [PayerWorkPhoneNumber] => 36301122334 [PayerHomePhoneNumber] => 36301122334 - [PayerAccountInformation] => PayerAccountInformationModel Object + [PayerAccountInformation] => \Barion\Models\Secure3d\PayerAccountInformationModel Object ( [AccountId] => 4690011905085639 [AccountCreated] => @@ -222,7 +222,7 @@ PreparePaymentRequestModel Object [SuspiciousActivityIndicator] => NoSuspiciousActivityObserved ) - [PurchaseInformation] => PurchaseInformationModel Object + [PurchaseInformation] => \Barion\Models\Secure3d\PurchaseInformationModel Object ( [DeliveryTimeframe] => OvernightShipping [DeliveryEmailAddress] => diff --git a/docs/refund_payments.md b/docs/refund_payments.md index d5b838b..3949538 100644 --- a/docs/refund_payments.md +++ b/docs/refund_payments.md @@ -5,7 +5,7 @@ In this example a payment is refunded to the customer. Consider a previously completed, successful payment: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 @@ -16,9 +16,9 @@ PaymentStateResponseModel Object [Status] => Succeeded [PaymentType] => DelayedCapture [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -43,20 +43,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:07:57.755Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -67,7 +67,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -85,20 +85,20 @@ PaymentStateResponseModel Object [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 0d5645a581654b8b940ddcefff41ce73 [POSTransactionId] => [TransactionTime] => 2019-08-12T05:17:55.565Z [Total] => 0.1 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -137,32 +137,32 @@ The webshop can easily manage this with a simple API call. ### 1. Creating the request object -First, construct the **TransactionToRefundModel** accordingly: +First, construct the **Barion\Models\Payment\TransactionToRefundModel** accordingly: ```php -$trans = new TransactionToRefundModel(); +$trans = new Barion\Models\Payment\TransactionToRefundModel(); $trans->TransactionId = "277edf17c7ce468a83f538102b4109be"; $trans->POSTransactionId = "TRANS-01"; $trans->AmountToRefund = 9.99; $trans->Comment = "Refund of ORDER-0001 upon customer complaint"; ``` -Then, create a **RefundRequestModel** and add the transaction to it: +Then, create a **Barion\Models\Refund\RefundRequestModel** and add the transaction to it: ```php -$rr = new RefundRequestModel($paymentId); +$rr = new Barion\Models\Refund\RefundRequestModel($paymentId); $rr->AddTransaction($trans); ``` At this point, the complete refund request object looks like this: ``` -RefundRequestModel Object +\Barion\Models\Refund\RefundRequestModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [TransactionsToRefund] => Array ( - [0] => TransactionToRefundModel Object + [0] => \Barion\Models\Payment\TransactionToRefundModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 @@ -191,12 +191,12 @@ The Barion API now refunds the payment. The response in the **refundResult** variable should look something like this: ``` -RefundResponseModel Object +\Barion\Models\Refund\RefundResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [RefundedTransactions] => Array ( - [0] => RefundedTransactionModel Object + [0] => \Barion\Models\Refund\RefundedTransactionModel Object ( [TransactionId] => a173eb5e96fd4bb38488968b6ca264e2 [Total] => 9.99 @@ -220,7 +220,7 @@ As you can see, the **RefundedTransactions** array contains the refund transacti If we now request the payment details again, we can see that the structure changed slightly: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 [PaymentRequestId] => PAYMENT-01 @@ -231,9 +231,9 @@ PaymentStateResponseModel Object [Status] => Succeeded [PaymentType] => DelayedCapture [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -258,20 +258,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 277edf17c7ce468a83f538102b4109be [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:07:57.755Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -282,7 +282,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => J.K. Rowling - Harry Potter and the chamber of secrets [Description] => Second part of best-selling author J.K. Rowling's magnificient wizard tale about young Harry Potter's adventures at Hogwarts. @@ -300,20 +300,20 @@ PaymentStateResponseModel Object [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 0d5645a581654b8b940ddcefff41ce73 [POSTransactionId] => [TransactionTime] => 2019-08-12T05:17:55.565Z [Total] => 0.1 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -331,20 +331,20 @@ PaymentStateResponseModel Object [PaymentId] => 6faf16e245e44bc0b60aebad6aeb9ec2 ) - [2] => TransactionDetailModel Object + [2] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => a173eb5e96fd4bb38488968b6ca264e2 [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T05:32:44.568Z [Total] => 9.99 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com diff --git a/docs/reservation_payment.md b/docs/reservation_payment.md index a2f9f3a..efd7031 100644 --- a/docs/reservation_payment.md +++ b/docs/reservation_payment.md @@ -6,10 +6,10 @@ Here we are going to start a reservation payment, where the user pays for two pr To start an online payment, you have to create one or more **Payment Transaction** objects, add transaction **Items** to them, then group these transactions together in a **Payment** object. -First, create the two **ItemModel** instances: +First, create the two **Barion\Models\Common\ItemModel** instances: ```php -$item1 = new ItemModel(); +$item1 = new Barion\Models\Common\ItemModel(); $item1->Name = "BestPresso Coffee Machine"; $item1->Description = "BPC2303 coffee machine, 1-year warranty"; $item1->Quantity = 1; @@ -18,7 +18,7 @@ $item1->UnitPrice = 499.95; $item1->ItemTotal = 499.95; $item1->SKU = "BPC2303"; -$item2 = new ItemModel(); +$item2 = new Barion\Models\Common\ItemModel(); $item2->Name = "BestPresso XL Coffee Machine"; $item2->Description = "BPC4000 XL professional coffee machine, 3-year warranty"; $item2->Quantity = 1; @@ -28,32 +28,32 @@ $item2->ItemTotal = 1199.95; $item2->SKU = "BPC4000"; ``` -Then create a **PaymentTransactionModel** and add the two **ItemModel** instances mentioned above to it: +Then create a **Barion\Models\Payment\PaymentTransactionModel** and add the two **Barion\Models\Common\ItemModel** instances mentioned above to it: ```php -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = "barionaccount@demo-merchant.shop"; $trans->Total = 1699.9; -$trans->Currency = Currency::EUR; +$trans->Currency = Barion\Common\Currency::EUR; $trans->Comment = "Test transaction containing the products"; $trans->AddItem($item1); $trans->AddItem($item2); ``` -Finally, create a **PreparePaymentRequestModel** and add the **PaymentTransactionModel** mentioned above to it: +Finally, create a **Barion\Models\Payment\PreparePaymentRequestModel** and add the **Barion\Models\Payment\PaymentTransactionModel** mentioned above to it: ```php -$ppr = new PreparePaymentRequestModel(); +$ppr = new Barion\Models\Payment\PreparePaymentRequestModel(); $ppr->GuestCheckout = true; -$ppr->PaymentType = PaymentType::Reservation; +$ppr->PaymentType = Barion\Common\PaymentType::Reservation; $ppr->ReservationPeriod = "7.00:00:00"; -$ppr->FundingSources = array(FundingSourceType::All); +$ppr->FundingSources = array(Barion\Common\FundingSourceType::All); $ppr->PaymentRequestId = "PAYMENT-01"; $ppr->PayerHint = "user@example.com"; -$ppr->Locale = UILocale::EN; +$ppr->Locale = Barion\Common\UILocale::EN; $ppr->OrderNumber = "ORDER-0001"; -$ppr->Currency = Currency::EUR; +$ppr->Currency = Barion\Common\Currency::EUR; $ppr->RedirectUrl = "http://webshop.example.com/afterpayment"; $ppr->CallbackUrl = "http://webshop.example.com/processpayment"; $ppr->AddTransaction($trans); @@ -62,7 +62,7 @@ $ppr->AddTransaction($trans); At this point, the complete request object looks like this: ``` -PreparePaymentRequestModel Object +\Barion\Models\Payment\PreparePaymentRequestModel Object ( [PaymentType] => Reservation [ReservationPeriod] => 7.00:00:00 @@ -78,7 +78,7 @@ PreparePaymentRequestModel Object [PayerHint] => user@example.com [Transactions] => Array ( - [0] => PaymentTransactionModel Object + [0] => \Barion\Models\Payment\PaymentTransactionModel Object ( [POSTransactionId] => TRANS-01 [Payee] => barionaccount@demo-merchant.shop @@ -86,7 +86,7 @@ PreparePaymentRequestModel Object [Comment] => Test transaction containing the products [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -97,7 +97,7 @@ PreparePaymentRequestModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso XL Coffee Machine [Description] => BPC4000 XL professional coffee machine, 3-year warranty @@ -150,17 +150,17 @@ $myPayment = $BC->PreparePayment($ppr); The Barion API now prepares a payment entity that can be paid by anyone. -The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **PreparePaymentResponseModel** object. It should look something like this: +The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PreparePaymentResponseModel** object. It should look something like this: ``` -PreparePaymentResponseModel Object +\Barion\Models\Payment\PreparePaymentResponseModel Object ( [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 [PaymentRequestId] => PAYMENT-01 [Status] => Prepared [Transactions] => Array ( - [0] => TransactionResponseModel Object + [0] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => TRANS-01 [TransactionId] => 2831dcca202948e1954b91b90a24ca9c @@ -169,7 +169,7 @@ PreparePaymentResponseModel Object [RelatedId] => ) - [1] => TransactionResponseModel Object + [1] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => 811a6034dadf452db5233b8138b6dd58 @@ -227,10 +227,10 @@ To request payment details, we call the **GetPaymentState** method of the Barion $paymentDetails = $BC->GetPaymentState("64157032-d3dc-4296-aeda-fd4b0994c64e"); ``` -The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **PaymentStateResponseModel** object. It should look something like this: +The **$paymentDetails** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PaymentStateResponseModel** object. It should look something like this: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 [PaymentRequestId] => PAYMENT-01 @@ -241,9 +241,9 @@ PaymentStateResponseModel Object [Status] => Prepared [PaymentType] => Reservation [FundingSource] => - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => [BankCardType] => @@ -268,20 +268,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 2831dcca202948e1954b91b90a24ca9c [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T04:38:57.739Z [Total] => 1699.9 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -292,7 +292,7 @@ PaymentStateResponseModel Object [TransactionType] => Unspecified [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -303,7 +303,7 @@ PaymentStateResponseModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso XL Coffee Machine [Description] => BPC4000 XL professional coffee machine, 3-year warranty @@ -321,20 +321,20 @@ PaymentStateResponseModel Object [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 811a6034dadf452db5233b8138b6dd58 [POSTransactionId] => [TransactionTime] => 2019-08-12T04:38:57.759Z [Total] => 17 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -371,7 +371,7 @@ The payment is in **Prepared** status, which means it is still waiting to be pai If we wait until the user completes the payment, and send the request again, we should get a slightly different result with more information: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 [PaymentRequestId] => PAYMENT-01 @@ -382,9 +382,9 @@ PaymentStateResponseModel Object [Status] => Reserved [PaymentType] => Reservation [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -409,20 +409,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 2831dcca202948e1954b91b90a24ca9c [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T04:38:57.739Z [Total] => 1699.9 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -433,7 +433,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -444,7 +444,7 @@ PaymentStateResponseModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso XL Coffee Machine [Description] => BPC4000 XL professional coffee machine, 3-year warranty @@ -462,20 +462,20 @@ PaymentStateResponseModel Object [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 811a6034dadf452db5233b8138b6dd58 [POSTransactionId] => [TransactionTime] => 2019-08-12T04:38:57.759Z [Total] => 17 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -512,10 +512,10 @@ As you can see, the payment status is now **Reserved**, which means the customer At this point, the webshop has one week to finish the reservation, as it was previously indicated in the **ReservationPeriod** parameter when the payment was started. Unfortunately, one of the ordered products turn out to be out of stock and is no longer available. The customer settles with not cancelling the order, just paying only for the other one. -The shop can now finish the reservation by constructing the appropriate **FinishReservationRequestModel** instance: +The shop can now finish the reservation by constructing the appropriate **Barion\Models\Payment\FinishReservationRequestModel** instance: ```php -$item1 = new ItemModel(); +$item1 = new Barion\Models\Common\ItemModel(); $item1->Name = "BestPresso Coffee Machine"; $item1->Description = "BPC2303 coffee machine, 1-year warranty"; $item1->Quantity = 1; @@ -524,7 +524,7 @@ $item1->UnitPrice = 499.95; $item1->ItemTotal = 499.95; $item1->SKU = "BPC2303"; -$item2 = new ItemModel(); +$item2 = new Barion\Models\Common\ItemModel(); $item2->Name = "[PRODUCT UNAVAILABLE] BestPresso XL Coffee Machine"; $item2->Description = "[PRODUCT UNAVAILABLE] BPC4000 XL professional coffee machine, 3-year warranty"; $item2->Quantity = 0; @@ -533,26 +533,26 @@ $item2->UnitPrice = 0; $item2->ItemTotal = 0; $item2->SKU = "BPC4000"; -$trans = new TransactionToFinishModel(); +$trans = new Barion\Models\Payment\TransactionToFinishModel(); $trans->TransactionId = $paymentDetails->Transactions[0]->TransactionId; $trans->Total = 499.95; $trans->Comment = "Test transaction containing the products"; $trans->AddItem($item1); $trans->AddItem($item2); -$frrm = new FinishReservationRequestModel($paymentDetails->PaymentId); +$frrm = new Barion\Models\Payment\FinishReservationRequestModel($paymentDetails->PaymentId); $frrm->AddTransaction($trans); ``` The full request for finishing the reservation now looks like this: ``` -FinishReservationRequestModel Object +\Barion\Models\Payment\FinishReservationRequestModel Object ( [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 [Transactions] => Array ( - [0] => TransactionToFinishModel Object + [0] => \Barion\Models\Payment\TransactionToFinishModel Object ( [TransactionId] => 2831dcca202948e1954b91b90a24ca9c [Total] => 499.95 @@ -562,7 +562,7 @@ FinishReservationRequestModel Object [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -573,7 +573,7 @@ FinishReservationRequestModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => [PRODUCT UNAVAILABLE] BestPresso XL Coffee Machine [Description] => [PRODUCT UNAVAILABLE] BPC4000 XL professional coffee machine, 3-year warranty @@ -597,7 +597,7 @@ FinishReservationRequestModel Object Take note of the adjusted **Total** value for the payment, and the indicated unavailability for the second product. -Now the shop can send the request using the **BarionClient**: +Now the shop can send the request using the **Barion\BarionClient**: ```php $finishReservationResult = $BC->FinishReservation($frrm); @@ -606,7 +606,7 @@ $finishReservationResult = $BC->FinishReservation($frrm); When sending the request, the following response arrives: ``` -FinishReservationResponseModel Object +\Barion\Models\Payment\FinishReservationResponseModel Object ( [IsSuccessful] => 1 [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 @@ -614,7 +614,7 @@ FinishReservationResponseModel Object [Status] => Succeeded [Transactions] => Array ( - [0] => TransactionResponseModel Object + [0] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => TRANS-01 [TransactionId] => 2831dcca202948e1954b91b90a24ca9c @@ -623,7 +623,7 @@ FinishReservationResponseModel Object [RelatedId] => ) - [1] => TransactionResponseModel Object + [1] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => 811a6034dadf452db5233b8138b6dd58 @@ -632,7 +632,7 @@ FinishReservationResponseModel Object [RelatedId] => ) - [2] => TransactionResponseModel Object + [2] => \Barion\Models\Payment\TransactionResponseModel Object ( [POSTransactionId] => [TransactionId] => b949dc817f5a4f31bfd7d012de7dab8e @@ -656,7 +656,7 @@ This shows that everything went okay, the request was successful. The reservatio If the webshop requests the payment details once more, you can see the completed state: ``` -PaymentStateResponseModel Object +\Barion\Models\Payment\PaymentStateResponseModel Object ( [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 [PaymentRequestId] => PAYMENT-01 @@ -667,9 +667,9 @@ PaymentStateResponseModel Object [Status] => Succeeded [PaymentType] => Reservation [FundingSource] => BankCard - [FundingInformation] => FundingInformationModel Object + [FundingInformation] => \Barion\Models\Common\FundingInformationModel Object ( - [BankCard] => BankCardModel Object + [BankCard] => \Barion\Models\Common\BankCardModel Object ( [MaskedPan] => 5559 [BankCardType] => Visa @@ -694,20 +694,20 @@ PaymentStateResponseModel Object [Currency] => EUR [Transactions] => Array ( - [0] => TransactionDetailModel Object + [0] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 2831dcca202948e1954b91b90a24ca9c [POSTransactionId] => TRANS-01 [TransactionTime] => 2019-08-12T04:38:57.739Z [Total] => 1699.9 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop @@ -718,7 +718,7 @@ PaymentStateResponseModel Object [TransactionType] => CardPayment [Items] => Array ( - [0] => ItemModel Object + [0] => \Barion\Models\Common\ItemModel Object ( [Name] => BestPresso Coffee Machine [Description] => BPC2303 coffee machine, 1-year warranty @@ -729,7 +729,7 @@ PaymentStateResponseModel Object [SKU] => BPC2303 ) - [1] => ItemModel Object + [1] => \Barion\Models\Common\ItemModel Object ( [Name] => [PRODUCT UNAVAILABLE] BestPresso XL Coffee Machine [Description] => [PRODUCT UNAVAILABLE] BPC4000 XL professional coffee machine, 3-year warranty @@ -747,20 +747,20 @@ PaymentStateResponseModel Object [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 ) - [1] => TransactionDetailModel Object + [1] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => 811a6034dadf452db5233b8138b6dd58 [POSTransactionId] => [TransactionTime] => 2019-08-12T04:38:57.759Z [Total] => 17 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => @@ -778,20 +778,20 @@ PaymentStateResponseModel Object [PaymentId] => d1d1c3eebab04c56b3c3b30c70f2d278 ) - [2] => TransactionDetailModel Object + [2] => \Barion\Models\Payment\TransactionDetailModel Object ( [TransactionId] => b949dc817f5a4f31bfd7d012de7dab8e [POSTransactionId] => [TransactionTime] => 2019-08-12T04:53:25.596Z [Total] => 1199.95 [Currency] => EUR - [Payer] => UserModel Object + [Payer] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => barionaccount@demo-merchant.shop ) - [Payee] => UserModel Object + [Payee] => \Barion\Models\Common\UserModel Object ( [Name] => [Email] => user@example.com diff --git a/examples/example_capture_amount.php b/examples/example_capture_amount.php index 572f878..acc99aa 100644 --- a/examples/example_capture_amount.php +++ b/examples/example_capture_amount.php @@ -8,16 +8,14 @@ * � 2019 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $paymentId = "22222222-2222-2222-2222-222222222222"; // <-- Replace this with the ID of the payment! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item model -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; // no more than 250 characters $item->Description = "A test item for delayed capture payment"; // no more than 500 characters $item->Quantity = 1; @@ -27,14 +25,14 @@ $item->SKU = "ITEM-01"; // no more than 100 characters // create the transaction model -$trans = new TransactionToFinishModel(); +$trans = new Barion\Models\Payment\TransactionToFinishModel(); $trans->TransactionId = "33333333-3333-3333-3333-333333333333"; // <-- Replace this with the original transaction ID! $trans->Total = 1000; $trans->Comment = "Transaction completed"; // no more than 640 characters $trans->AddItem($item); // create the request object -$crm = new CaptureRequestModel($paymentId); +$crm = new Barion\Models\Payment\CaptureRequestModel($paymentId); $crm->AddTransaction($trans); // add the transaction to the request // send the request diff --git a/examples/example_finish_reservation.php b/examples/example_finish_reservation.php index 5a49676..9191d84 100755 --- a/examples/example_finish_reservation.php +++ b/examples/example_finish_reservation.php @@ -8,16 +8,14 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $paymentId = "22222222-2222-2222-2222-222222222222"; // <-- Replace this with the ID of the payment! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item models -$item1 = new ItemModel(); +$item1 = new Barion\Models\Common\ItemModel(); $item1->Name = "TestItem"; // no more than 250 characters $item1->Description = "A test item for payment"; // no more than 500 characters $item1->Quantity = 1; @@ -26,7 +24,7 @@ $item1->ItemTotal = 1000; $item1->SKU = "ITEM-01"; // no more than 100 characters -$item2 = new ItemModel(); +$item2 = new Barion\Models\Common\ItemModel(); $item2->Name = "AnotherTestItem"; // no more than 250 characters $item2->Description = "Another test item for payment"; // no more than 500 characters $item2->Quantity = 2; @@ -36,7 +34,7 @@ $item2->SKU = "ITEM-02"; // no more than 100 characters // create the transaction model -$trans = new TransactionToFinishModel(); +$trans = new Barion\Models\Payment\TransactionToFinishModel(); $trans->TransactionId = "33333333-3333-3333-3333-333333333333"; // <-- Replace this with the original transaction ID! $trans->Total = 1500; $trans->Comment = "Reservation complete"; // no more than 640 characters @@ -44,7 +42,7 @@ $trans->AddItem($item2); // create the request object -$frrm = new FinishReservationRequestModel($paymentId); +$frrm = new Barion\Models\Payment\FinishReservationRequestModel($paymentId); $frrm->AddTransaction($trans); // add the transaction to the request // send the request diff --git a/examples/example_get_payment_details.php b/examples/example_get_payment_details.php index 6ea1138..8dae7fc 100755 --- a/examples/example_get_payment_details.php +++ b/examples/example_get_payment_details.php @@ -8,13 +8,11 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $paymentId = "22222222-2222-2222-2222-222222222222"; // <-- Replace this with the ID of the payment! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // send the request $paymentDetails = $BC->GetPaymentState($paymentId); diff --git a/examples/example_payee_transactions.php b/examples/example_payee_transactions.php index 7086c73..6246059 100755 --- a/examples/example_payee_transactions.php +++ b/examples/example_payee_transactions.php @@ -8,16 +8,14 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $myEmailAddress = "mywebshop@example.com"; // <-- Replace this with your e-mail address in Barion! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item model -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "ExpensiveTestItem"; // no more than 250 characters $item->Description = "An expensive test item for payment"; // no more than 500 characters $item->Quantity = 1; @@ -27,20 +25,20 @@ $item->SKU = "ITEM-03"; // no more than 100 characters // create the payee transactions -$ptrans1 = new PayeeTransactionModel(); +$ptrans1 = new Barion\Models\Payment\PayeeTransactionModel(); $ptrans1->POSTransactionId = "PTRANS-01"; // no more than 100 characters $ptrans1->Payee = "user1@example.com"; // no more than 256 characters $ptrans1->Total = 1000; $ptrans1->Comment = "Royalties"; // no more than 640 characters -$ptrans2 = new PayeeTransactionModel(); +$ptrans2 = new Barion\Models\Payment\PayeeTransactionModel(); $ptrans2->POSTransactionId = "PTRANS-02"; // no more than 100 characters $ptrans2->Payee = "user2@example.com"; // no more than 256 characters $ptrans2->Total = 3000; $ptrans2->Comment = "Royalties"; // no more than 640 characters // create the transaction -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-03"; $trans->Payee = $myEmailAddress; // no more than 256 characters $trans->Total = 50000; @@ -50,7 +48,7 @@ $trans->AddPayeeTransaction($ptrans2); // create the shipping address -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "HU"; $shippingAddress->Region = null; $shippingAddress->City = "Budapest"; @@ -61,13 +59,13 @@ $shippingAddress->FullName = "Teszt Tibor"; // create the request model -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; // we allow guest checkout -$psr->PaymentType = PaymentType::Immediate; // we want an immediate payment -$psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted +$psr->PaymentType = Barion\Common\PaymentType::Immediate; // we want an immediate payment +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); // both Barion wallet and bank card accepted $psr->PaymentRequestId = "TESTPAY-03"; // no more than 100 characters $psr->PayerHint = "user@example.com"; // no more than 256 characters -$psr->Locale = UILocale::EN; // the UI language will be English +$psr->Locale = Barion\Common\UILocale::EN; // the UI language will be English $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters $psr->ShippingAddress = $shippingAddress; $psr->AddTransaction($trans); // add the transaction to the payment @@ -77,5 +75,5 @@ if ($myPayment->RequestSuccessful === true) { // redirect the user to the Barion Smart Gateway - header("Location: " . BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); + header("Location: " . Barion\Common\BarionConstants::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); } \ No newline at end of file diff --git a/examples/example_refund_payment.php b/examples/example_refund_payment.php index dd0f7ba..4913f77 100755 --- a/examples/example_refund_payment.php +++ b/examples/example_refund_payment.php @@ -8,22 +8,20 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $paymentId = "22222222-2222-2222-2222-222222222222"; // <-- Replace this with the ID of the payment! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the refund transaction model -$trans = new TransactionToRefundModel(); +$trans = new Barion\Models\Payment\TransactionToRefundModel(); $trans->TransactionId = "33333333-3333-3333-3333-333333333333"; // <-- Replace this with the original transaction ID! $trans->POSTransactionId = "TRANS-04"; // <-- Replace this with the original POS transaction ID! $trans->AmountToRefund = 100; $trans->Comment = "Refund because of complaint"; // no more than 640 characters -$rr = new RefundRequestModel($paymentId); +$rr = new Barion\Models\Refund\RefundRequestModel($paymentId); $rr->AddTransaction($trans); $refundResult = $BC->RefundPayment($rr); diff --git a/examples/example_start_delayedcapture_payment.php b/examples/example_start_delayedcapture_payment.php index 72630b7..66f0c34 100644 --- a/examples/example_start_delayedcapture_payment.php +++ b/examples/example_start_delayedcapture_payment.php @@ -12,10 +12,10 @@ $myEmailAddress = "mywebshop@example.com"; // <-- Replace this with your e-mail address in Barion! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item model -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; // no more than 250 characters $item->Description = "A test item for delayed capture payment"; // no more than 500 characters $item->Quantity = 1; @@ -25,7 +25,7 @@ $item->SKU = "ITEM-01"; // no more than 100 characters // create the transaction -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = $myEmailAddress; // no more than 256 characters $trans->Total = 1000; @@ -33,7 +33,7 @@ $trans->AddItem($item); // add the item to the transaction // create the shipping address -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "HU"; $shippingAddress->Region = null; $shippingAddress->City = "Budapest"; @@ -44,15 +44,15 @@ $shippingAddress->FullName = "Teszt Tibor"; // create the request model -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; // we allow guest checkout -$psr->PaymentType = PaymentType::DelayedCapture; // we want a delayed capture payment +$psr->PaymentType = Barion\Common\PaymentType::DelayedCapture; // we want a delayed capture payment $psr->DelayedCapturePeriod = "3:00:00:00"; // capture is delayed for 3 days -$psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); // both Barion wallet and bank card accepted $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters $psr->PayerHint = "user@example.com"; // no more than 256 characters -$psr->Locale = UILocale::EN; // the UI language will be English -$psr->Currency = Currency::HUF; +$psr->Locale = Barion\Common\UILocale::EN; // the UI language will be English +$psr->Currency = Barion\Common\Currency::HUF; $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters $psr->ShippingAddress = $shippingAddress; $psr->AddTransaction($trans); // add the transaction to the payment @@ -62,5 +62,5 @@ if ($myPayment->RequestSuccessful === true) { // redirect the user to the Barion Smart Gateway - header("Location: " . BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); + header("Location: " . Barion\Common\BarionConstants::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); } \ No newline at end of file diff --git a/examples/example_start_immediate_payment.php b/examples/example_start_immediate_payment.php index 18f7ffc..379d170 100755 --- a/examples/example_start_immediate_payment.php +++ b/examples/example_start_immediate_payment.php @@ -8,16 +8,14 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $myEmailAddress = "mywebshop@example.com"; // <-- Replace this with your e-mail address in Barion! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item model -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; // no more than 250 characters $item->Description = "A test item for payment"; // no more than 500 characters $item->Quantity = 1; @@ -27,7 +25,7 @@ $item->SKU = "ITEM-01"; // no more than 100 characters // create the transaction -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = $myEmailAddress; // no more than 256 characters $trans->Total = 1000; @@ -35,7 +33,7 @@ $trans->AddItem($item); // add the item to the transaction // create the shipping address -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "HU"; $shippingAddress->Region = null; $shippingAddress->City = "Budapest"; @@ -46,14 +44,14 @@ $shippingAddress->FullName = "Teszt Tibor"; // create the request model -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; // we allow guest checkout -$psr->PaymentType = PaymentType::Immediate; // we want an immediate payment -$psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted +$psr->PaymentType = Barion\Common\PaymentType::Immediate; // we want an immediate payment +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); // both Barion wallet and bank card accepted $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters $psr->PayerHint = "user@example.com"; // no more than 256 characters -$psr->Locale = UILocale::EN; // the UI language will be English -$psr->Currency = Currency::HUF; +$psr->Locale = Barion\Common\UILocale::EN; // the UI language will be English +$psr->Currency = Barion\Common\Currency::HUF; $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters $psr->ShippingAddress = $shippingAddress; $psr->AddTransaction($trans); // add the transaction to the payment @@ -63,5 +61,5 @@ if ($myPayment->RequestSuccessful === true) { // redirect the user to the Barion Smart Gateway - header("Location: " . BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); + header("Location: " . Barion\Common\BarionConstants::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); } \ No newline at end of file diff --git a/examples/example_start_payment_with_3dsecure_parameters.php b/examples/example_start_payment_with_3dsecure_parameters.php index 5133fb7..d3f8700 100644 --- a/examples/example_start_payment_with_3dsecure_parameters.php +++ b/examples/example_start_payment_with_3dsecure_parameters.php @@ -8,13 +8,11 @@ * � 2019 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $myEmailAddress = "mywebshop@example.com"; // <-- Replace this with your e-mail address in Barion! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // helper variable, containing the timestamp 10 minutes ago $now = date("Y-m-d H:i:s", (time() - 600)); @@ -23,7 +21,7 @@ $payerEmail = "john.doe@example.com"; // create the item model -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; // no more than 250 characters $item->Description = "A test item for payment"; // no more than 500 characters $item->Quantity = 1; @@ -33,7 +31,7 @@ $item->SKU = "ITEM-01"; // no more than 100 characters // create the transaction -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = $myEmailAddress; // no more than 256 characters $trans->Total = 75; @@ -41,7 +39,7 @@ $trans->AddItem($item); // add the item to the transaction // create the addresses -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "DE"; $shippingAddress->Region = null; $shippingAddress->City = "Berlin"; @@ -51,7 +49,7 @@ $shippingAddress->Street3 = ""; $shippingAddress->FullName = "Thomas Testing"; -$billingAddress = new BillingAddressModel(); +$billingAddress = new Barion\Models\Secure3d\BillingAddressModel(); $billingAddress->Country = "DE"; $billingAddress->Region = null; $billingAddress->City = "Berlin"; @@ -61,46 +59,46 @@ $billingAddress->Street3 = ""; // 3DS information about the payer -$payerAccountInfo = new PayerAccountInformationModel(); +$payerAccountInfo = new Barion\Models\Secure3d\PayerAccountInformationModel(); $payerAccountInfo->AccountId = "4690011905085639"; $payerAccountInfo->AccountCreated = $now; -$payerAccountInfo->AccountCreationIndicator = AccountCreationIndicator::CreatedDuringThisTransaction; +$payerAccountInfo->AccountCreationIndicator = Barion\Common\Secure3d\AccountCreationIndicator::CreatedDuringThisTransaction; $payerAccountInfo->AccountLastChanged = $now; -$payerAccountInfo->AccountChangeIndicator = AccountChangeIndicator::ChangedDuringThisTransaction; +$payerAccountInfo->AccountChangeIndicator = Barion\Common\Secure3d\AccountChangeIndicator::ChangedDuringThisTransaction; $payerAccountInfo->PasswordLastChanged = $now; -$payerAccountInfo->PasswordChangeIndicator = PasswordChangeIndicator::NoChange; +$payerAccountInfo->PasswordChangeIndicator = Barion\Common\Secure3d\PasswordChangeIndicator::NoChange; $payerAccountInfo->PurchasesInTheLastSixMonths = 6; $payerAccountInfo->ShippingAddressAdded = $now; -$payerAccountInfo->ShippingAddressUsageIndicator = ShippingAddressUsageIndicator::ThisTransaction; +$payerAccountInfo->ShippingAddressUsageIndicator = Barion\Common\Secure3d\ShippingAddressUsageIndicator::ThisTransaction; $payerAccountInfo->PaymentMethodAdded = $now; -$payerAccountInfo->PaymentMethodIndicator = PaymentMethodIndicator::ThisTransaction; +$payerAccountInfo->PaymentMethodIndicator = Barion\Common\Secure3d\PaymentMethodIndicator::ThisTransaction; $payerAccountInfo->ProvisionAttempts = 1; $payerAccountInfo->TransactionalActivityPerDay = 1; $payerAccountInfo->TransactionalActivityPerYear = 100; -$payerAccountInfo->SuspiciousActivityIndicator = SuspiciousActivityIndicator::NoSuspiciousActivityObserved; +$payerAccountInfo->SuspiciousActivityIndicator = Barion\Common\Secure3d\SuspiciousActivityIndicator::NoSuspiciousActivityObserved; // 3DS information about the purchase -$purchaseInfo = new PurchaseInformationModel(); -$purchaseInfo->DeliveryTimeframe = DeliveryTimeFrameType::OvernightShipping; +$purchaseInfo = new Barion\Models\Secure3d\PurchaseInformationModel(); +$purchaseInfo->DeliveryTimeframe = Barion\Common\Secure3d\DeliveryTimeFrameType::OvernightShipping; $purchaseInfo->DeliveryEmailAddress = $payerEmail; $purchaseInfo->PreOrderDate = $now; -$purchaseInfo->AvailabilityIndicator = AvailabilityIndicator::MerchandiseAvailable; -$purchaseInfo->ReOrderIndicator = ReOrderIndicator::FirstTimeOrdered; +$purchaseInfo->AvailabilityIndicator = Barion\Common\Secure3d\AvailabilityIndicator::MerchandiseAvailable; +$purchaseInfo->ReOrderIndicator = Barion\Common\Secure3d\ReOrderIndicator::FirstTimeOrdered; $purchaseInfo->RecurringExpiry = "2099-12-31 23:59:59"; $purchaseInfo->RecurringFrequency = "0"; -$purchaseInfo->ShippingAddressIndicator = ShippingAddressIndicator::ShipToCardholdersBillingAddress; +$purchaseInfo->ShippingAddressIndicator = Barion\Common\Secure3d\ShippingAddressIndicator::ShipToCardholdersBillingAddress; $purchaseInfo->GiftCardPurchase = null; -$purchaseInfo->PurchaseType = PurchaseType::GoodsAndServicePurchase; +$purchaseInfo->PurchaseType = Barion\Common\Secure3d\PurchaseType::GoodsAndServicePurchase; // create the request model -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; // we allow guest checkout -$psr->PaymentType = PaymentType::Immediate; // we want an immediate payment -$psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted +$psr->PaymentType = Barion\Common\PaymentType::Immediate; // we want an immediate payment +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); // both Barion wallet and bank card accepted $psr->PaymentRequestId = "TESTPAY-01"; // no more than 100 characters $psr->PayerHint = $payerEmail; // no more than 256 characters -$psr->Locale = UILocale::EN; // the UI language will be English -$psr->Currency = Currency::EUR; +$psr->Locale = Barion\Common\UILocale::EN; // the UI language will be English +$psr->Currency = Barion\Common\Currency::EUR; $psr->OrderNumber = "ORDER-0001"; // no more than 100 characters $psr->AddTransaction($trans); // add the transaction to the payment @@ -113,12 +111,12 @@ $psr->PayerHomePhoneNumber = "36301122334"; $psr->PayerAccountInformation = $payerAccountInfo; $psr->PurchaseInformation = $purchaseInfo; -$psr->ChallengePreference = ChallengePreference::NoPreference; +$psr->ChallengePreference = Barion\Common\Secure3d\ChallengePreference::NoPreference; // send the request $myPayment = $BC->PreparePayment($psr); if ($myPayment->RequestSuccessful === true) { // redirect the user to the Barion Smart Gateway - header("Location: " . BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); + header("Location: " . Barion\Common\BarionConstants::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); } \ No newline at end of file diff --git a/examples/example_start_reservation_payment.php b/examples/example_start_reservation_payment.php index 1a178bc..c0cbed7 100755 --- a/examples/example_start_reservation_payment.php +++ b/examples/example_start_reservation_payment.php @@ -8,16 +8,14 @@ * � 2015 Barion Payment Inc. */ -require_once '../library/BarionClient.php'; - $myPosKey = "11111111-1111-1111-1111-111111111111"; // <-- Replace this with your POSKey! $myEmailAddress = "mywebshop@example.com"; // <-- Replace this with your e-mail address in Barion! // Barion Client that connects to the TEST environment -$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test); +$BC = new Barion\BarionClient($myPosKey, 2, Barion\Common\BarionEnvironment::Test); // create the item models -$item1 = new ItemModel(); +$item1 = new Barion\Models\Common\ItemModel(); $item1->Name = "TestItem"; // no more than 250 characters $item1->Description = "A test item for payment"; // no more than 500 characters $item1->Quantity = 1; @@ -26,7 +24,7 @@ $item1->ItemTotal = 1000; $item1->SKU = "ITEM-01"; // no more than 100 characters -$item2 = new ItemModel(); +$item2 = new Barion\Models\Common\ItemModel(); $item2->Name = "AnotherTestItem"; // no more than 250 characters $item2->Description = "Another test item for payment"; // no more than 500 characters $item2->Quantity = 2; @@ -36,7 +34,7 @@ $item2->SKU = "ITEM-02"; // no more than 100 characters // create the transaction -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-02"; $trans->Payee = $myEmailAddress; // no more than 256 characters $trans->Total = 1500; @@ -45,7 +43,7 @@ $trans->AddItem($item2); // create the shipping address -$shippingAddress = new ShippingAddressModel(); +$shippingAddress = new Barion\Models\Secure3d\ShippingAddressModel(); $shippingAddress->Country = "HU"; $shippingAddress->Region = null; $shippingAddress->City = "Budapest"; @@ -56,16 +54,16 @@ $shippingAddress->FullName = "Teszt Tibor"; // create the request model -$psr = new PreparePaymentRequestModel(); +$psr = new Barion\Models\Payment\PreparePaymentRequestModel(); $psr->GuestCheckout = true; // we allow guest checkout -$psr->PaymentType = PaymentType::Reservation; // we want an immediate payment +$psr->PaymentType = Barion\Common\PaymentType::Reservation; // we want an immediate payment $psr->ReservationPeriod = "1:00:00:00"; // money is reserved for one day $psr->PaymentWindow = "00:20:00"; // the payment must be completed in 20 minutes -$psr->FundingSources = array(FundingSourceType::All); // both Barion wallet and bank card accepted +$psr->FundingSources = array(Barion\Common\FundingSourceType::All); // both Barion wallet and bank card accepted $psr->PaymentRequestId = "TESTPAY-02"; // no more than 100 characters $psr->PayerHint = "user@example.com"; // no more than 256 characters -$psr->Locale = UILocale::EN; // the UI language will be English -$psr->Currency = Currency::HUF; +$psr->Locale = Barion\Common\UILocale::EN; // the UI language will be English +$psr->Currency = Barion\Common\Currency::HUF; $psr->OrderNumber = "ORDER-0002"; // no more than 100 characters $psr->ShippingAddress = $shippingAddress; $psr->AddTransaction($trans); // add the transaction to the payment @@ -75,5 +73,5 @@ if ($myPayment->RequestSuccessful === true) { // redirect the user to the Barion Smart Gateway - header("Location: " . BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); + header("Location: " . Barion\Common\BarionConstants::BARION_WEB_URL_TEST . "?id=" . $myPayment->PaymentId); } \ No newline at end of file diff --git a/library/BarionClient.php b/library/BarionClient.php index 8d2ddb1..be5d76b 100755 --- a/library/BarionClient.php +++ b/library/BarionClient.php @@ -17,15 +17,32 @@ */ /* -* * BarionClient.php -* PHP library for implementing REST API calls towards the Barion payment system. -* +* PHP library for implementing REST API calls towards the Barion payment system. */ -include 'helpers' . DIRECTORY_SEPARATOR . 'loader.php'; - -class BarionClient +namespace Barion; + +use Barion\Common\BarionConstants; +use Barion\Common\BarionEnvironment; +use Barion\Common\QRCodeSize; +use Barion\Models\BaseResponseModel; +use Barion\Models\Payment\CancelAuthorizationRequestModel; +use Barion\Models\Payment\CancelAuthorizationResponseModel; +use Barion\Models\Payment\CaptureRequestModel; +use Barion\Models\Payment\CaptureResponseModel; +use Barion\Models\Payment\PreparePaymentRequestModel; +use Barion\Models\Payment\PreparePaymentResponseModel; +use Barion\Models\Payment\FinishReservationRequestModel; +use Barion\Models\Payment\FinishReservationResponseModel; +use Barion\Models\Refund\RefundRequestModel; +use Barion\Models\Refund\RefundResponseModel; +use Barion\Models\Payment\PaymentStateRequestModel; +use Barion\Models\Payment\PaymentStateResponseModel; +use Barion\Models\Payment\PaymentQRRequestModel; +use Barion\Models\ApiErrorModel; + +class BarionClient implements BarionClientInterface { private $Environment; @@ -56,14 +73,14 @@ function __construct($poskey, $version = 2, $env = BarionEnvironment::Prod, $use switch ($env) { case BarionEnvironment::Test: - $this->BARION_API_URL = BARION_API_URL_TEST; - $this->BARION_WEB_URL = BARION_WEB_URL_TEST; + $this->BARION_API_URL = BarionConstants::BARION_API_URL_TEST; + $this->BARION_WEB_URL = BarionConstants::BARION_WEB_URL_TEST; break; case BarionEnvironment::Prod: default: - $this->BARION_API_URL = BARION_API_URL_PROD; - $this->BARION_WEB_URL = BARION_WEB_URL_PROD; + $this->BARION_API_URL = BarionConstants::BARION_API_URL_PROD; + $this->BARION_WEB_URL = BarionConstants::BARION_WEB_URL_PROD; break; } @@ -71,18 +88,19 @@ function __construct($poskey, $version = 2, $env = BarionEnvironment::Prod, $use } /* -------- BARION API CALL IMPLEMENTATIONS -------- */ - - /** * Prepare a new payment * - * @param PreparePaymentRequestModel $model The request model for payment preparation - * @return PreparePaymentResponseModel Returns the response from the Barion API + * @param \Barion\Models\Payment\PreparePaymentRequestModel $model + * The request model for payment preparation + * + * @return \Barion\Models\Payment\PreparePaymentResponseModel + * Returns the response from the Barion API/ */ public function PreparePayment(PreparePaymentRequestModel $model) { $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_PREPAREPAYMENT; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_PREPAREPAYMENT; $response = $this->PostToBarion($url, $model); $rm = new PreparePaymentResponseModel(); if (!empty($response)) { @@ -96,16 +114,18 @@ public function PreparePayment(PreparePaymentRequestModel $model) } /** - * * Finish an existing reservation * - * @param FinishReservationRequestModel $model The request model for the finish process - * @return FinishReservationResponseModel Returns the response from the Barion API + * @param \Barion\Models\Payment\FinishReservationRequestModel $model + * The request model for the finish process + * + * @return \Barion\Models\Payment\FinishReservationResponseModel + * Returns the response from the Barion API */ public function FinishReservation(FinishReservationRequestModel $model) { $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_FINISHRESERVATION; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_FINISHRESERVATION; $response = $this->PostToBarion($url, $model); $rm = new FinishReservationResponseModel(); if (!empty($response)) { @@ -114,18 +134,20 @@ public function FinishReservation(FinishReservationRequestModel $model) } return $rm; } - + /** - * * Capture the previously authorized money in a Delayed Capture payment * - * @param CaptureRequestModel $model The request model for the capture process - * @return CaptureResponseModel Returns the response from the Barion API + * @param \Barion\Models\Payment\CaptureRequestModel $model + * The request model for the capture process. + * + * @return \Barion\Models\Payment\CaptureResponseModel + * Returns the response from the Barion API */ public function Capture(CaptureRequestModel $model) { $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_CAPTURE; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_CAPTURE; $response = $this->PostToBarion($url, $model); $captureResponse = new CaptureResponseModel(); if (!empty($response)) { @@ -136,16 +158,18 @@ public function Capture(CaptureRequestModel $model) } /** - * * Cancel a pending authorization on a Delayed Capture payment * - * @param CancelAuthorizationRequestModel $model The request model for cancelling the authorization - * @return CancelAuthorizationResponseModel Returns the response from the Barion API + * @param \Barion\Models\Payment\CancelAuthorizationRequestModel $model + * The request model for cancelling the authorization. + * + * @return \Barion\Models\Payment\CancelAuthorizationResponseModel + * Returns the response from the Barion API. */ public function CancelAuthorization(CancelAuthorizationRequestModel $model) { $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_CANCELAUTHORIZATION; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_CANCELAUTHORIZATION; $response = $this->PostToBarion($url, $model); $cancelAuthResponse = new CancelAuthorizationResponseModel(); if (!empty($response)) { @@ -155,17 +179,19 @@ public function CancelAuthorization(CancelAuthorizationRequestModel $model) return $cancelAuthResponse; } - /** * Refund a payment partially or totally * - * @param RefundRequestModel $model The request model for the refund process - * @return RefundResponseModel Returns the response from the Barion API + * @param \Barion\Models\Refund\RefundRequestModel $model + * The request model for the refund process/ + * + * @return \Barion\Models\Refund\RefundResponseModel + * Returns the response from the Barion API */ public function RefundPayment(RefundRequestModel $model) { $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_REFUND; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_REFUND; $response = $this->PostToBarion($url, $model); $rm = new RefundResponseModel(); if (!empty($response)) { @@ -175,18 +201,20 @@ public function RefundPayment(RefundRequestModel $model) return $rm; } - /** * Get detailed information about a given payment * - * @param string $paymentId The Id of the payment - * @return PaymentStateResponseModel Returns the response from the Barion API + * @param string $paymentId + * The Id of the payment/ + * + * @return \Barion\Models\Payment\PaymentStateResponseModel + * Returns the response from the Barion API. */ public function GetPaymentState($paymentId) { $model = new PaymentStateRequestModel($paymentId); $model->POSKey = $this->POSKey; - $url = $this->BARION_API_URL . "/v" . $this->APIVersion . API_ENDPOINT_PAYMENTSTATE; + $url = $this->BARION_API_URL . "/v" . $this->APIVersion . BarionConstants::API_ENDPOINT_PAYMENTSTATE; $response = $this->GetFromBarion($url, $model); $ps = new PaymentStateResponseModel(); if (!empty($response)) { @@ -203,11 +231,17 @@ public function GetPaymentState($paymentId) * If no username and/or password was set, this method returns NULL. * * @deprecated - * @param string $username The username of the shop's owner - * @param string $password The password of the shop's owner - * @param string $paymentId The Id of the payment - * @param string $qrCodeSize The desired size of the QR image - * @return mixed|string Returns the response of the QR request + * @param string $username + * The username of the shop's owner + * @param string $password + * The password of the shop's owner + * @param string $paymentId + * The Id of the payment + * @param string $qrCodeSize + * The desired size of the QR image + * + * @return mixed|string + * Returns the response of the QR request */ public function GetPaymentQRImage($username, $password, $paymentId, $qrCodeSize = QRCodeSize::Large) { @@ -216,16 +250,12 @@ public function GetPaymentQRImage($username, $password, $paymentId, $qrCodeSize $model->UserName = $username; $model->Password = $password; $model->Size = $qrCodeSize; - $url = $this->BARION_API_URL . API_ENDPOINT_QRCODE; + $url = $this->BARION_API_URL . BarionConstants::API_ENDPOINT_QRCODE; $response = $this->GetFromBarion($url, $model); return $response; } /* -------- CURL HTTP REQUEST IMPLEMENTATIONS -------- */ - - /* - * - */ /** * Managing HTTP POST requests * @@ -236,7 +266,7 @@ public function GetPaymentQRImage($username, $password, $paymentId, $qrCodeSize private function PostToBarion($url, $data) { $ch = curl_init(); - + $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($userAgent == "") { $cver = curl_version(); @@ -250,8 +280,8 @@ private function PostToBarion($url, $data) curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "User-Agent: $userAgent")); - - if(substr(phpversion(), 0, 3) < 5.6) { + + if (substr(phpversion(), 0, 3) < 5.6) { curl_setopt($ch, CURLOPT_SSLVERSION, 6); } @@ -279,7 +309,6 @@ private function PostToBarion($url, $data) return $output; } - /** * Managing HTTP GET requests * @@ -293,7 +322,7 @@ private function GetFromBarion($url, $data) $getData = http_build_query($data); $fullUrl = $url . '?' . $getData; - + $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($userAgent == "") { $cver = curl_version(); @@ -303,7 +332,7 @@ private function GetFromBarion($url, $data) curl_setopt($ch, CURLOPT_URL, $fullUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: $userAgent")); - + if(substr(phpversion(), 0, 3) < 5.6) { curl_setopt($ch, CURLOPT_SSLVERSION, 6); } diff --git a/library/BarionClientInterface.php b/library/BarionClientInterface.php new file mode 100755 index 0000000..f467a48 --- /dev/null +++ b/library/BarionClientInterface.php @@ -0,0 +1,126 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +* +* BarionClient.php +* PHP library for implementing REST API calls towards the Barion payment system. +* +*/ + +namespace Barion; + +use Barion\Common\QRCodeSize; +use Barion\Models\Payment\CancelAuthorizationRequestModel; +use Barion\Models\Payment\CaptureRequestModel; +use Barion\Models\Payment\PreparePaymentRequestModel; +use Barion\Models\Payment\FinishReservationRequestModel; +use Barion\Models\Refund\RefundRequestModel; + + +interface BarionClientInterface +{ + + /** + * Prepare a new payment + * + * @param \Barion\Models\Payment\PreparePaymentRequestModel $model + * The request model for payment preparation + * + * @return \Barion\Models\Payment\PreparePaymentResponseModel + * Returns the response from the Barion API/ + */ + public function PreparePayment(PreparePaymentRequestModel $model); + + /** + * Finish an existing reservation + * + * @param \Barion\Models\Payment\FinishReservationRequestModel $model + * The request model for the finish process + * + * @return \Barion\Models\Payment\FinishReservationResponseModel + * Returns the response from the Barion API + */ + public function FinishReservation(FinishReservationRequestModel $model); + + /** + * Capture the previously authorized money in a Delayed Capture payment + * + * @param \Barion\Models\Payment\CaptureRequestModel $model + * The request model for the capture process. + * + * @return \Barion\Models\Payment\CaptureResponseModel + * Returns the response from the Barion API + */ + public function Capture(CaptureRequestModel $model); + + /** + * Cancel a pending authorization on a Delayed Capture payment + * + * @param \Barion\Models\Payment\CancelAuthorizationRequestModel $model + * The request model for cancelling the authorization. + * + * @return \Barion\Models\Payment\CancelAuthorizationResponseModel + * Returns the response from the Barion API. + */ + public function CancelAuthorization(CancelAuthorizationRequestModel $model); + + /** + * Refund a payment partially or totally + * + * @param \Barion\Models\Refund\RefundRequestModel $model + * The request model for the refund process/ + * + * @return \Barion\Models\Refund\RefundResponseModel + * Returns the response from the Barion API + */ + public function RefundPayment(RefundRequestModel $model); + + /** + * Get detailed information about a given payment + * + * @param string $paymentId + * The Id of the payment/ + * + * @return \Barion\Models\Payment\PaymentStateResponseModel + * Returns the response from the Barion API. + */ + public function GetPaymentState($paymentId); + + /** + * Get the QR code image for a given payment + * + * NOTE: This call is deprecated and is only working with username & password authentication. + * If no username and/or password was set, this method returns NULL. + * + * @deprecated + * @param string $username + * The username of the shop's owner + * @param string $password + * The password of the shop's owner + * @param string $paymentId + * The Id of the payment + * @param string $qrCodeSize + * The desired size of the QR image + * + * @return mixed|string + * Returns the response of the QR request + */ + public function GetPaymentQRImage($username, $password, $paymentId, $qrCodeSize = QRCodeSize::Large); + +} \ No newline at end of file diff --git a/library/common/Constants.php b/library/common/Constants.php deleted file mode 100755 index 3489ffc..0000000 --- a/library/common/Constants.php +++ /dev/null @@ -1,34 +0,0 @@ - - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

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

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* URL constants for Barion API communication */ - -DEFINE("BARION_API_URL_PROD", "https://api.barion.com"); -DEFINE("BARION_WEB_URL_PROD", "https://secure.barion.com/Pay"); -DEFINE("BARION_API_URL_TEST", "https://api.test.barion.com"); -DEFINE("BARION_WEB_URL_TEST", "https://secure.test.barion.com/Pay"); - -DEFINE("API_ENDPOINT_PREPAREPAYMENT", "/Payment/Start"); -DEFINE("API_ENDPOINT_PAYMENTSTATE", "/Payment/GetPaymentState"); -DEFINE("API_ENDPOINT_QRCODE", "/QR/Generate"); -DEFINE("API_ENDPOINT_REFUND", "/Payment/Refund"); -DEFINE("API_ENDPOINT_FINISHRESERVATION", "/Payment/FinishReservation"); -DEFINE("API_ENDPOINT_CAPTURE", "/Payment/Capture"); -DEFINE("API_ENDPOINT_CANCELAUTHORIZATION", "/Payment/CancelAuthorization"); - -DEFINE("PAYMENT_URL", "/Pay"); \ No newline at end of file diff --git a/library/common/Enumerations.php b/library/common/Enumerations.php deleted file mode 100755 index fd2f3c3..0000000 --- a/library/common/Enumerations.php +++ /dev/null @@ -1,205 +0,0 @@ -getConstants(); - return array_key_exists($name, $constants); - } -} - -abstract class CardType -{ - const Unknown = "Unknown"; - const Mastercard = "Mastercard"; - const Maestro = "Maestro"; - const Visa = "Visa"; - const Electron = "Electron"; - const AmericanExpress = "AmericanExpress"; -} - -// -------------------- -// 3D Secure properties -// -------------------- - -abstract class AccountCreationIndicator -{ - const NoAccount = "NoAccount"; - const CreatedDuringThisTransaction = "CreatedDuringThisTransaction"; - const LessThan30Days = "LessThan30Days"; - const Between30And60Days = "Between30And60Days"; - const MoreThan60Days = "MoreThan60Days"; -} - -abstract class AccountChangeIndicator -{ - const ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; - const LessThan30Days = "LessThan30Days"; - const Between30And60Days = "Between30And60Days"; - const MoreThan60Days = "MoreThan60Days"; -} - -abstract class PasswordChangeIndicator -{ - const NoChange = "NoChange"; - const ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; - const LessThan30Days = "LessThan30Days"; - const Between30And60Days = "Between30And60Days"; - const MoreThan60Days = "MoreThan60Days"; -} - -abstract class ShippingAddressUsageIndicator -{ - const ThisTransaction = "ThisTransaction"; - const LessThan30Days = "LessThan30Days"; - const Between30And60Days = "Between30And60Days"; - const MoreThan60Days = "MoreThan60Days"; -} - -abstract class PaymentMethodIndicator -{ - const NoAccount = "NoAccount"; - const ThisTransaction = "ThisTransaction"; - const LessThan30Days = "LessThan30Days"; - const Between30And60Days = "Between30And60Days"; - const MoreThan60Days = "MoreThan60Days"; -} - -abstract class SuspiciousActivityIndicator -{ - const NoSuspiciousActivityObserved = "NoSuspiciousActivityObserved"; - const SuspiciousActivityObserved = "SuspiciousActivityObserved"; -} - -abstract class DeliveryTimeframeType -{ - const ElectronicDelivery = "ElectronicDelivery"; - const SameDayShipping = "SameDayShipping"; - const OvernightShipping = "OvernightShipping"; - const TwoDayOrMoreShipping = "TwoDayOrMoreShipping"; -} - -abstract class AvailabilityIndicator -{ - const MerchandiseAvailable = "MerchandiseAvailable"; - const FutureAvailability = "FutureAvailability"; -} - -abstract class ReOrderIndicator -{ - const FirstTimeOrdered = "FirstTimeOrdered"; - const ReOrdered = "ReOrdered"; -} - -abstract class ShippingAddressIndicator -{ - const ShipToCardholdersBillingAddress = "ShipToCardholdersBillingAddress"; - const ShipToAnotherVerifiedAddress = "ShipToAnotherVerifiedAddress"; - const ShipToDifferentAddress = "ShipToDifferentAddress"; - const ShipToStore = "ShipToStore"; - const DigitalGoods = "DigitalGoods"; - const TravelAndEventTickets = "TravelAndEventTickets"; - const Other = "Other"; -} - -abstract class PurchaseType -{ - const GoodsAndServicePurchase = "GoodsAndServicePurchase"; - const CheckAcceptance = "CheckAcceptance"; - const AccountFunding = "AccountFunding"; - const QuasiCashTransaction = "QuasiCashTransaction"; - const PrePaidVacationAndLoan = "PrePaidVacationAndLoan"; -} - -abstract class RecurrenceType -{ - const MerchantInitiatedPayment = "MerchantInitiatedPayment"; - const OneClickPayment = "OneClickPayment"; -} - -abstract class ChallengePreference -{ - const NoPreference = "NoPreference"; - const ChallengeRequired = "ChallengeRequired"; - const NoChallengeNeeded = "NoChallengeNeeded"; -} \ No newline at end of file diff --git a/library/enum/BarionConstants.php b/library/enum/BarionConstants.php new file mode 100755 index 0000000..dd0ce13 --- /dev/null +++ b/library/enum/BarionConstants.php @@ -0,0 +1,40 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* URL constants for Barion API communication */ + +namespace Barion\Common; + +interface BarionConstants { + + const BARION_API_URL_PROD = "https://api.barion.com"; + const BARION_WEB_URL_PROD = "https://secure.barion.com/Pay"; + const BARION_API_URL_TEST = "https://api.test.barion.com"; + const BARION_WEB_URL_TEST = "https://secure.test.barion.com/Pay"; + + const API_ENDPOINT_PREPAREPAYMENT = "/Payment/Start"; + const API_ENDPOINT_PAYMENTSTATE = "/Payment/GetPaymentState"; + const API_ENDPOINT_QRCODE = "/QR/Generate"; + const API_ENDPOINT_REFUND = "/Payment/Refund"; + const API_ENDPOINT_FINISHRESERVATION = "/Payment/FinishReservation"; + const API_ENDPOINT_CAPTURE = "/Payment/Capture"; + const API_ENDPOINT_CANCELAUTHORIZATION = "/Payment/CancelAuthorization"; + + const PAYMENT_URL = "/Pay"; + +} diff --git a/library/enum/BarionEnvironment.php b/library/enum/BarionEnvironment.php new file mode 100644 index 0000000..d20fef0 --- /dev/null +++ b/library/enum/BarionEnvironment.php @@ -0,0 +1,26 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface BarionEnvironment { + + const Test = "test"; + const Prod = "prod"; + +} \ No newline at end of file diff --git a/library/enum/CardType.php b/library/enum/CardType.php new file mode 100644 index 0000000..603db2e --- /dev/null +++ b/library/enum/CardType.php @@ -0,0 +1,29 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface CardType +{ + const Unknown = "Unknown"; + const Mastercard = "Mastercard"; + const Maestro = "Maestro"; + const Visa = "Visa"; + const Electron = "Electron"; + const AmericanExpress = "AmericanExpress"; +} \ No newline at end of file diff --git a/library/enum/Currency.php b/library/enum/Currency.php new file mode 100644 index 0000000..5d96940 --- /dev/null +++ b/library/enum/Currency.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface Currency +{ + const HUF = "HUF"; + const EUR = "EUR"; + const USD = "USD"; + const CZK = "CZK"; + +} diff --git a/library/enum/FundingSourceType.php b/library/enum/FundingSourceType.php new file mode 100644 index 0000000..1bdf736 --- /dev/null +++ b/library/enum/FundingSourceType.php @@ -0,0 +1,26 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface FundingSourceType +{ + const All = "All"; + const Balance = "Balance"; + const Bankcard = "Bankcard"; +} diff --git a/library/enum/PaymentStatus.php b/library/enum/PaymentStatus.php new file mode 100644 index 0000000..dcc45e0 --- /dev/null +++ b/library/enum/PaymentStatus.php @@ -0,0 +1,45 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface PaymentStatus +{ + // 10 + const Prepared = "Prepared"; + // 20 + const Started = "Started"; + // 21 + const InProgress = "InProgress"; + // 22 + const Waiting = "Waiting"; + // 25 + const Reserved = "Reserved"; + // 26 + const Authorized = "Authorized"; + // 30 + const Canceled = "Canceled"; + // 40 + const Succeeded = "Succeeded"; + // 50 + const Failed = "Failed"; + // 60 + const PartiallySucceeded = "PartiallySucceeded"; + // 70 + const Expired = "Expired"; +} diff --git a/library/enum/PaymentType.php b/library/enum/PaymentType.php new file mode 100644 index 0000000..423bb07 --- /dev/null +++ b/library/enum/PaymentType.php @@ -0,0 +1,26 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface PaymentType +{ + const Immediate = "Immediate"; + const Reservation = "Reservation"; + const DelayedCapture = "DelayedCapture"; +} diff --git a/library/enum/QRCodeSize.php b/library/enum/QRCodeSize.php new file mode 100644 index 0000000..2b6ddd0 --- /dev/null +++ b/library/enum/QRCodeSize.php @@ -0,0 +1,26 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface QRCodeSize +{ + const Small = "Small"; + const Normal = "Normal"; + const Large = "Large"; +} diff --git a/library/enum/RecurrenceResult.php b/library/enum/RecurrenceResult.php new file mode 100644 index 0000000..fd1fc00 --- /dev/null +++ b/library/enum/RecurrenceResult.php @@ -0,0 +1,27 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface RecurrenceResult +{ + const None = "None"; + const Successful = "Successful"; + const Failed = "Failed"; + const NotFound = "NotFound"; +} diff --git a/library/enum/Secure3d/AccountChangeIndicator.php b/library/enum/Secure3d/AccountChangeIndicator.php new file mode 100644 index 0000000..77e1951 --- /dev/null +++ b/library/enum/Secure3d/AccountChangeIndicator.php @@ -0,0 +1,27 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface AccountChangeIndicator +{ + const ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; + const LessThan30Days = "LessThan30Days"; + const Between30And60Days = "Between30And60Days"; + const MoreThan60Days = "MoreThan60Days"; +} \ No newline at end of file diff --git a/library/enum/Secure3d/AccountCreationIndicator.php b/library/enum/Secure3d/AccountCreationIndicator.php new file mode 100644 index 0000000..7bb1e38 --- /dev/null +++ b/library/enum/Secure3d/AccountCreationIndicator.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface AccountCreationIndicator +{ + const NoAccount = "NoAccount"; + const CreatedDuringThisTransaction = "CreatedDuringThisTransaction"; + const LessThan30Days = "LessThan30Days"; + const Between30And60Days = "Between30And60Days"; + const MoreThan60Days = "MoreThan60Days"; +} diff --git a/library/enum/Secure3d/AvailabilityIndicator.php b/library/enum/Secure3d/AvailabilityIndicator.php new file mode 100644 index 0000000..defc387 --- /dev/null +++ b/library/enum/Secure3d/AvailabilityIndicator.php @@ -0,0 +1,25 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface AvailabilityIndicator +{ + const MerchandiseAvailable = "MerchandiseAvailable"; + const FutureAvailability = "FutureAvailability"; +} \ No newline at end of file diff --git a/library/enum/Secure3d/ChallengePreference.php b/library/enum/Secure3d/ChallengePreference.php new file mode 100644 index 0000000..d74f16f --- /dev/null +++ b/library/enum/Secure3d/ChallengePreference.php @@ -0,0 +1,26 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface ChallengePreference +{ + const NoPreference = "NoPreference"; + const ChallengeRequired = "ChallengeRequired"; + const NoChallengeNeeded = "NoChallengeNeeded"; +} diff --git a/library/enum/Secure3d/DeliveryTimeframeType.php b/library/enum/Secure3d/DeliveryTimeframeType.php new file mode 100644 index 0000000..88dff49 --- /dev/null +++ b/library/enum/Secure3d/DeliveryTimeframeType.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + + +interface DeliveryTimeframeType +{ + const ElectronicDelivery = "ElectronicDelivery"; + const SameDayShipping = "SameDayShipping"; + const OvernightShipping = "OvernightShipping"; + const TwoDayOrMoreShipping = "TwoDayOrMoreShipping"; +} \ No newline at end of file diff --git a/library/enum/Secure3d/PasswordChangeIndicator.php b/library/enum/Secure3d/PasswordChangeIndicator.php new file mode 100644 index 0000000..36afd8f --- /dev/null +++ b/library/enum/Secure3d/PasswordChangeIndicator.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface PasswordChangeIndicator +{ + const NoChange = "NoChange"; + const ChangedDuringThisTransaction = "ChangedDuringThisTransaction"; + const LessThan30Days = "LessThan30Days"; + const Between30And60Days = "Between30And60Days"; + const MoreThan60Days = "MoreThan60Days"; +} diff --git a/library/enum/Secure3d/PaymentMethodIndicator.php b/library/enum/Secure3d/PaymentMethodIndicator.php new file mode 100644 index 0000000..ed16bcf --- /dev/null +++ b/library/enum/Secure3d/PaymentMethodIndicator.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface PaymentMethodIndicator +{ + const NoAccount = "NoAccount"; + const ThisTransaction = "ThisTransaction"; + const LessThan30Days = "LessThan30Days"; + const Between30And60Days = "Between30And60Days"; + const MoreThan60Days = "MoreThan60Days"; +} diff --git a/library/enum/Secure3d/PurchaseType.php b/library/enum/Secure3d/PurchaseType.php new file mode 100644 index 0000000..4a23726 --- /dev/null +++ b/library/enum/Secure3d/PurchaseType.php @@ -0,0 +1,28 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface PurchaseType +{ + const GoodsAndServicePurchase = "GoodsAndServicePurchase"; + const CheckAcceptance = "CheckAcceptance"; + const AccountFunding = "AccountFunding"; + const QuasiCashTransaction = "QuasiCashTransaction"; + const PrePaidVacationAndLoan = "PrePaidVacationAndLoan"; +} diff --git a/library/enum/Secure3d/ReOrderIndicator.php b/library/enum/Secure3d/ReOrderIndicator.php new file mode 100644 index 0000000..7148189 --- /dev/null +++ b/library/enum/Secure3d/ReOrderIndicator.php @@ -0,0 +1,25 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface ReOrderIndicator +{ + const FirstTimeOrdered = "FirstTimeOrdered"; + const ReOrdered = "ReOrdered"; +} diff --git a/library/enum/Secure3d/RecurrenceType.php b/library/enum/Secure3d/RecurrenceType.php new file mode 100644 index 0000000..99e3cbf --- /dev/null +++ b/library/enum/Secure3d/RecurrenceType.php @@ -0,0 +1,25 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface RecurrenceType +{ + const MerchantInitiatedPayment = "MerchantInitiatedPayment"; + const OneClickPayment = "OneClickPayment"; +} diff --git a/library/enum/Secure3d/ShippingAddressIndicator.php b/library/enum/Secure3d/ShippingAddressIndicator.php new file mode 100644 index 0000000..c06e5ae --- /dev/null +++ b/library/enum/Secure3d/ShippingAddressIndicator.php @@ -0,0 +1,30 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface ShippingAddressIndicator +{ + const ShipToCardholdersBillingAddress = "ShipToCardholdersBillingAddress"; + const ShipToAnotherVerifiedAddress = "ShipToAnotherVerifiedAddress"; + const ShipToDifferentAddress = "ShipToDifferentAddress"; + const ShipToStore = "ShipToStore"; + const DigitalGoods = "DigitalGoods"; + const TravelAndEventTickets = "TravelAndEventTickets"; + const Other = "Other"; +} diff --git a/library/enum/Secure3d/ShippingAddressUsageIndicator.php b/library/enum/Secure3d/ShippingAddressUsageIndicator.php new file mode 100644 index 0000000..62a44f5 --- /dev/null +++ b/library/enum/Secure3d/ShippingAddressUsageIndicator.php @@ -0,0 +1,27 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface ShippingAddressUsageIndicator +{ + const ThisTransaction = "ThisTransaction"; + const LessThan30Days = "LessThan30Days"; + const Between30And60Days = "Between30And60Days"; + const MoreThan60Days = "MoreThan60Days"; +} diff --git a/library/enum/Secure3d/SuspiciousActivityIndicator.php b/library/enum/Secure3d/SuspiciousActivityIndicator.php new file mode 100644 index 0000000..f205b81 --- /dev/null +++ b/library/enum/Secure3d/SuspiciousActivityIndicator.php @@ -0,0 +1,25 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common\Secure3d; + +interface SuspiciousActivityIndicator +{ + const NoSuspiciousActivityObserved = "NoSuspiciousActivityObserved"; + const SuspiciousActivityObserved = "SuspiciousActivityObserved"; +} diff --git a/library/enum/UILocale.php b/library/enum/UILocale.php new file mode 100644 index 0000000..f4e44c6 --- /dev/null +++ b/library/enum/UILocale.php @@ -0,0 +1,31 @@ + + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Barion\Common; + +interface UILocale +{ + const HU = "hu-HU"; + const EN = "en-US"; + const DE = "de-DE"; + const SL = "sl-SI"; + const SK = "sk-SK"; + const FR = "fr-FR"; + const CZ = "cs-CZ"; + const GR = "el-GR"; +} diff --git a/library/helpers/BarionHelper.php b/library/helpers/BarionHelper.php index 1b7d878..e61ab58 100644 --- a/library/helpers/BarionHelper.php +++ b/library/helpers/BarionHelper.php @@ -19,6 +19,8 @@ * @return null */ +namespace Barion\Helpers; + /* * Helper functions */ diff --git a/library/helpers/iBarionModel.php b/library/helpers/iBarionModel.php index 3514597..0e1e597 100755 --- a/library/helpers/iBarionModel.php +++ b/library/helpers/iBarionModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Helpers; + interface iBarionModel { public function fromJson($json); diff --git a/library/helpers/loader.php b/library/helpers/loader.php deleted file mode 100755 index aa240b9..0000000 --- a/library/helpers/loader.php +++ /dev/null @@ -1,35 +0,0 @@ - - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

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

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -include "iBarionModel.php"; -include "BarionHelper.php"; - -$include_dirs = Array( - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "common"))), - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "models"))), - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "models/common"))), - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "models/3dsecure"))), - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "models/payment"))), - realpath(join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "models/refund"))) -); - -foreach ($include_dirs as $dir) { - foreach (glob($dir . '/*.php') as $file) { - include_once $file; - } -} \ No newline at end of file diff --git a/library/models/ApiErrorModel.php b/library/models/ApiErrorModel.php index 992a1b3..3bfb105 100755 --- a/library/models/ApiErrorModel.php +++ b/library/models/ApiErrorModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models; + class ApiErrorModel { public $ErrorCode; diff --git a/library/models/BaseRequestModel.php b/library/models/BaseRequestModel.php index 627a1fc..b27360f 100755 --- a/library/models/BaseRequestModel.php +++ b/library/models/BaseRequestModel.php @@ -16,6 +16,8 @@ * limitations under the License. */ +namespace Barion\Models; + /** * Mother of all requests. For now with every request, the credentials have to be sent as well. * This will be changed to oAuth in the near future. diff --git a/library/models/BaseResponseModel.php b/library/models/BaseResponseModel.php index 182ef22..2781b07 100755 --- a/library/models/BaseResponseModel.php +++ b/library/models/BaseResponseModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models; + class BaseResponseModel { public $Errors; diff --git a/library/models/3dsecure/BillingAddressModel.php b/library/models/Secure3d/BillingAddressModel.php similarity index 68% rename from library/models/3dsecure/BillingAddressModel.php rename to library/models/Secure3d/BillingAddressModel.php index feb1cee..2813063 100644 --- a/library/models/3dsecure/BillingAddressModel.php +++ b/library/models/Secure3d/BillingAddressModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Secure3d; + +use Barion\Helpers\iBarionModel; + class BillingAddressModel implements iBarionModel { public $Country; @@ -39,13 +44,13 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->Country = jget($json, 'Country'); - $this->Region = jget($json, 'Region'); - $this->City = jget($json, 'City'); - $this->Zip = jget($json, 'Zip'); - $this->Street = jget($json, 'Street'); - $this->Street2 = jget($json, 'Street2'); - $this->Street3 = jget($json, 'Street3'); + $this->Country = \Barion\Helpers\jget($json, 'Country'); + $this->Region = \Barion\Helpers\jget($json, 'Region'); + $this->City = \Barion\Helpers\jget($json, 'City'); + $this->Zip = \Barion\Helpers\jget($json, 'Zip'); + $this->Street = \Barion\Helpers\jget($json, 'Street'); + $this->Street2 = \Barion\Helpers\jget($json, 'Street2'); + $this->Street3 = \Barion\Helpers\jget($json, 'Street3'); } } } \ No newline at end of file diff --git a/library/models/3dsecure/GiftCardPurchaseModel.php b/library/models/Secure3d/GiftCardPurchaseModel.php similarity index 81% rename from library/models/3dsecure/GiftCardPurchaseModel.php rename to library/models/Secure3d/GiftCardPurchaseModel.php index d16b173..0aad7e9 100644 --- a/library/models/3dsecure/GiftCardPurchaseModel.php +++ b/library/models/Secure3d/GiftCardPurchaseModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Secure3d; + +use Barion\Helpers\iBarionModel; + class GiftCardPurchaseModel implements iBarionModel { public $Amount; @@ -29,8 +34,8 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->Amount = jget($json, 'Amount'); - $this->Count = jget($json, 'Count'); + $this->Amount = \Barion\Helpers\jget($json, 'Amount'); + $this->Count = \Barion\Helpers\jget($json, 'Count'); } } } \ No newline at end of file diff --git a/library/models/3dsecure/PayerAccountInformationModel.php b/library/models/Secure3d/PayerAccountInformationModel.php similarity index 56% rename from library/models/3dsecure/PayerAccountInformationModel.php rename to library/models/Secure3d/PayerAccountInformationModel.php index d3b4580..aa3cff6 100644 --- a/library/models/3dsecure/PayerAccountInformationModel.php +++ b/library/models/Secure3d/PayerAccountInformationModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Secure3d; + +use Barion\Helpers\iBarionModel; + class PayerAccountInformationModel implements iBarionModel { public $AccountId; @@ -57,22 +62,22 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->AccountId = jget($json, 'AccountId'); - $this->AccountCreated = jget($json, 'AccountCreated'); - $this->AccountCreationIndicator = jget($json, 'AccountCreationIndicator'); - $this->AccountLastChanged = jget($json, 'AccountLastChanged'); - $this->AccountChangeIndicator = jget($json, 'AccountChangeIndicator'); - $this->PasswordLastChanged = jget($json, 'PasswordLastChanged'); - $this->PasswordChangeIndicator = jget($json, 'PasswordChangeIndicator'); - $this->PurchasesInTheLastSixMonths = jget($json, 'PurchasesInTheLastSixMonths'); - $this->ShippingAddressAdded = jget($json, 'ShippingAddressAdded'); - $this->ShippingAddressUsageIndicator = jget($json, 'ShippingAddressUsageIndicator'); - $this->PaymentMethodAdded = jget($json, 'PaymentMethodAdded'); - $this->PaymentMethodIndicator = jget($json, 'PaymentMethodIndicator'); - $this->ProvisionAttempts = jget($json, 'ProvisionAttempts'); - $this->TransactionalActivityPerDay = jget($json, 'TransactionalActivityPerDay'); - $this->TransactionalActivityPerYear = jget($json, 'TransactionalActivityPerYear'); - $this->SuspiciousActivityIndicator = jget($json, 'SuspiciousActivityIndicator'); + $this->AccountId = \Barion\Helpers\jget($json, 'AccountId'); + $this->AccountCreated = \Barion\Helpers\jget($json, 'AccountCreated'); + $this->AccountCreationIndicator = \Barion\Helpers\jget($json, 'AccountCreationIndicator'); + $this->AccountLastChanged = \Barion\Helpers\jget($json, 'AccountLastChanged'); + $this->AccountChangeIndicator = \Barion\Helpers\jget($json, 'AccountChangeIndicator'); + $this->PasswordLastChanged = \Barion\Helpers\jget($json, 'PasswordLastChanged'); + $this->PasswordChangeIndicator = \Barion\Helpers\jget($json, 'PasswordChangeIndicator'); + $this->PurchasesInTheLastSixMonths = \Barion\Helpers\jget($json, 'PurchasesInTheLastSixMonths'); + $this->ShippingAddressAdded = \Barion\Helpers\jget($json, 'ShippingAddressAdded'); + $this->ShippingAddressUsageIndicator = \Barion\Helpers\jget($json, 'ShippingAddressUsageIndicator'); + $this->PaymentMethodAdded = \Barion\Helpers\jget($json, 'PaymentMethodAdded'); + $this->PaymentMethodIndicator = \Barion\Helpers\jget($json, 'PaymentMethodIndicator'); + $this->ProvisionAttempts = \Barion\Helpers\jget($json, 'ProvisionAttempts'); + $this->TransactionalActivityPerDay = \Barion\Helpers\jget($json, 'TransactionalActivityPerDay'); + $this->TransactionalActivityPerYear = \Barion\Helpers\jget($json, 'TransactionalActivityPerYear'); + $this->SuspiciousActivityIndicator = \Barion\Helpers\jget($json, 'SuspiciousActivityIndicator'); } } } \ No newline at end of file diff --git a/library/models/3dsecure/PurchaseInformationModel.php b/library/models/Secure3d/PurchaseInformationModel.php similarity index 61% rename from library/models/3dsecure/PurchaseInformationModel.php rename to library/models/Secure3d/PurchaseInformationModel.php index a7ef931..6488845 100644 --- a/library/models/3dsecure/PurchaseInformationModel.php +++ b/library/models/Secure3d/PurchaseInformationModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Secure3d; + +use Barion\Helpers\iBarionModel; + class PurchaseInformationModel implements iBarionModel { public $DeliveryTimeframe; @@ -45,16 +50,16 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->DeliveryTimeframe = jget($json, 'DeliveryTimeframe'); - $this->DeliveryEmailAddress = jget($json, 'DeliveryEmailAddress'); - $this->PreOrderDate = jget($json, 'PreOrderDate'); - $this->AvailabilityIndicator = jget($json, 'AvailabilityIndicator'); - $this->ReOrderIndicator = jget($json, 'ReOrderIndicator'); - $this->RecurringExpiry = jget($json, 'RecurringExpiry'); - $this->RecurringFrequency = jget($json, 'RecurringFrequency'); - $this->ShippingAddressIndicator = jget($json, 'ShippingAddressIndicator'); - $this->GiftCardPurchase = jget($json, 'GiftCardPurchase'); - $this->PurchaseType = jget($json, 'PurchaseType'); + $this->DeliveryTimeframe = \Barion\Helpers\jget($json, 'DeliveryTimeframe'); + $this->DeliveryEmailAddress = \Barion\Helpers\jget($json, 'DeliveryEmailAddress'); + $this->PreOrderDate = \Barion\Helpers\jget($json, 'PreOrderDate'); + $this->AvailabilityIndicator = \Barion\Helpers\jget($json, 'AvailabilityIndicator'); + $this->ReOrderIndicator = \Barion\Helpers\jget($json, 'ReOrderIndicator'); + $this->RecurringExpiry = \Barion\Helpers\jget($json, 'RecurringExpiry'); + $this->RecurringFrequency = \Barion\Helpers\jget($json, 'RecurringFrequency'); + $this->ShippingAddressIndicator = \Barion\Helpers\jget($json, 'ShippingAddressIndicator'); + $this->GiftCardPurchase = \Barion\Helpers\jget($json, 'GiftCardPurchase'); + $this->PurchaseType = \Barion\Helpers\jget($json, 'PurchaseType'); } } } \ No newline at end of file diff --git a/library/models/3dsecure/ShippingAddressModel.php b/library/models/Secure3d/ShippingAddressModel.php similarity index 66% rename from library/models/3dsecure/ShippingAddressModel.php rename to library/models/Secure3d/ShippingAddressModel.php index b2c2ff4..c716fcf 100644 --- a/library/models/3dsecure/ShippingAddressModel.php +++ b/library/models/Secure3d/ShippingAddressModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Secure3d; + +use Barion\Helpers\iBarionModel; + class ShippingAddressModel implements iBarionModel { public $Country; @@ -41,14 +46,14 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->Country = jget($json, 'Country'); - $this->Region = jget($json, 'Region'); - $this->City = jget($json, 'City'); - $this->Zip = jget($json, 'Zip'); - $this->Street = jget($json, 'Street'); - $this->Street2 = jget($json, 'Street2'); - $this->Street3 = jget($json, 'Street3'); - $this->FullName = jget($json, 'FullName'); + $this->Country = \Barion\Helpers\jget($json, 'Country'); + $this->Region = \Barion\Helpers\jget($json, 'Region'); + $this->City = \Barion\Helpers\jget($json, 'City'); + $this->Zip = \Barion\Helpers\jget($json, 'Zip'); + $this->Street = \Barion\Helpers\jget($json, 'Street'); + $this->Street2 = \Barion\Helpers\jget($json, 'Street2'); + $this->Street3 = \Barion\Helpers\jget($json, 'Street3'); + $this->FullName = \Barion\Helpers\jget($json, 'FullName'); } } } \ No newline at end of file diff --git a/library/models/common/BankCardModel.php b/library/models/common/BankCardModel.php index 3be3391..568c98b 100644 --- a/library/models/common/BankCardModel.php +++ b/library/models/common/BankCardModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Common; + +use Barion\Helpers\iBarionModel; + class BankCardModel implements iBarionModel { public $MaskedPan; @@ -33,10 +38,10 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->MaskedPan = jget($json, 'MaskedPan'); - $this->BankCardType = jget($json, 'BankCardType'); - $this->ValidThruYear = jget($json, 'ValidThruYear'); - $this->ValidThruMonth = jget($json, 'ValidThruMonth'); + $this->MaskedPan = \Barion\Helpers\jget($json, 'MaskedPan'); + $this->BankCardType = \Barion\Helpers\jget($json, 'BankCardType'); + $this->ValidThruYear = \Barion\Helpers\jget($json, 'ValidThruYear'); + $this->ValidThruMonth = \Barion\Helpers\jget($json, 'ValidThruMonth'); } } } \ No newline at end of file diff --git a/library/models/common/FundingInformationModel.php b/library/models/common/FundingInformationModel.php index 90ee61b..a59ff8c 100644 --- a/library/models/common/FundingInformationModel.php +++ b/library/models/common/FundingInformationModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Common; + +use Barion\Helpers\iBarionModel; + class FundingInformationModel implements iBarionModel { public $BankCard; @@ -30,8 +35,8 @@ public function fromJson($json) { if (!empty($json)) { $this->BankCard = new BankCardModel(); - $this->BankCard->fromJson(jget($json, 'BankCard')); - $this->AuthorizationCode = jget($json, 'AuthorizationCode'); + $this->BankCard->fromJson(\Barion\Helpers\jget($json, 'BankCard')); + $this->AuthorizationCode = \Barion\Helpers\jget($json, 'AuthorizationCode'); } } } \ No newline at end of file diff --git a/library/models/common/ItemModel.php b/library/models/common/ItemModel.php index d35ddf6..b41569b 100644 --- a/library/models/common/ItemModel.php +++ b/library/models/common/ItemModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Common; + +use Barion\Helpers\iBarionModel; + class ItemModel implements iBarionModel { public $Name; @@ -39,13 +44,13 @@ function __construct() public function fromJson($json) { if (!empty($json)) { - $this->Name = jget($json, 'Name'); - $this->Description = jget($json, 'Description'); - $this->Quantity = jget($json, 'Quantity'); - $this->Unit = jget($json, 'Unit'); - $this->UnitPrice = jget($json, 'UnitPrice'); - $this->ItemTotal = jget($json, 'ItemTotal'); - $this->SKU = jget($json, 'SKU'); + $this->Name = \Barion\Helpers\jget($json, 'Name'); + $this->Description = \Barion\Helpers\jget($json, 'Description'); + $this->Quantity = \Barion\Helpers\jget($json, 'Quantity'); + $this->Unit = \Barion\Helpers\jget($json, 'Unit'); + $this->UnitPrice = \Barion\Helpers\jget($json, 'UnitPrice'); + $this->ItemTotal = \Barion\Helpers\jget($json, 'ItemTotal'); + $this->SKU = \Barion\Helpers\jget($json, 'SKU'); } } } \ No newline at end of file diff --git a/library/models/common/UserModel.php b/library/models/common/UserModel.php index 712d398..6db9f05 100644 --- a/library/models/common/UserModel.php +++ b/library/models/common/UserModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Common; + +use Barion\Helpers\iBarionModel; + class UserModel implements iBarionModel { public $Name; diff --git a/library/models/common/UserNameModel.php b/library/models/common/UserNameModel.php index a676d6b..41c1ac4 100644 --- a/library/models/common/UserNameModel.php +++ b/library/models/common/UserNameModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Common; + +use Barion\Helpers\iBarionModel; + class UserNameModel implements iBarionModel { public $LoginName; diff --git a/library/models/payment/CancelAuthorizationRequestModel.php b/library/models/payment/CancelAuthorizationRequestModel.php index d67acc2..70d3a21 100644 --- a/library/models/payment/CancelAuthorizationRequestModel.php +++ b/library/models/payment/CancelAuthorizationRequestModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\BaseRequestModel; + class CancelAuthorizationRequestModel extends BaseRequestModel { public $PaymentId; diff --git a/library/models/payment/CancelAuthorizationResponseModel.php b/library/models/payment/CancelAuthorizationResponseModel.php index a245f65..e389eed 100644 --- a/library/models/payment/CancelAuthorizationResponseModel.php +++ b/library/models/payment/CancelAuthorizationResponseModel.php @@ -15,6 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\BaseResponseModel; + class CancelAuthorizationResponseModel extends BaseResponseModel implements iBarionModel { public $IsSuccessful; @@ -38,10 +44,10 @@ public function fromJson($json) if (!empty($json)) { parent::fromJson($json); - $this->IsSuccessful = jget($json, 'IsSuccessful'); - $this->PaymentId = jget($json, 'PaymentId'); - $this->PaymentRequestId = jget($json, 'PaymentRequestId'); - $this->Status = jget($json, 'Status'); + $this->IsSuccessful = \Barion\Helpers\jget($json, 'IsSuccessful'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); + $this->PaymentRequestId = \Barion\Helpers\jget($json, 'PaymentRequestId'); + $this->Status = \Barion\Helpers\jget($json, 'Status'); $this->Transactions = array(); diff --git a/library/models/payment/CaptureRequestModel.php b/library/models/payment/CaptureRequestModel.php index f35643b..7e2c9ec 100644 --- a/library/models/payment/CaptureRequestModel.php +++ b/library/models/payment/CaptureRequestModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\BaseRequestModel; + class CaptureRequestModel extends BaseRequestModel { public $PaymentId; diff --git a/library/models/payment/CaptureResponseModel.php b/library/models/payment/CaptureResponseModel.php index f483a83..ab63ff1 100644 --- a/library/models/payment/CaptureResponseModel.php +++ b/library/models/payment/CaptureResponseModel.php @@ -15,6 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\BaseResponseModel; + class CaptureResponseModel extends BaseResponseModel implements iBarionModel { public $IsSuccessful; @@ -38,10 +44,10 @@ public function fromJson($json) if (!empty($json)) { parent::fromJson($json); - $this->IsSuccessful = jget($json, 'IsSuccessful'); - $this->PaymentId = jget($json, 'PaymentId'); - $this->PaymentRequestId = jget($json, 'PaymentRequestId'); - $this->Status = jget($json, 'Status'); + $this->IsSuccessful = \Barion\Helpers\jget($json, 'IsSuccessful'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); + $this->PaymentRequestId = \Barion\Helpers\jget($json, 'PaymentRequestId'); + $this->Status = \Barion\Helpers\jget($json, 'Status'); $this->Transactions = array(); diff --git a/library/models/payment/FinishReservationRequestModel.php b/library/models/payment/FinishReservationRequestModel.php index 6f737a3..8203cda 100644 --- a/library/models/payment/FinishReservationRequestModel.php +++ b/library/models/payment/FinishReservationRequestModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\BaseRequestModel; + class FinishReservationRequestModel extends BaseRequestModel { public $PaymentId; diff --git a/library/models/payment/FinishReservationResponseModel.php b/library/models/payment/FinishReservationResponseModel.php index e7b0b5f..20b54bd 100644 --- a/library/models/payment/FinishReservationResponseModel.php +++ b/library/models/payment/FinishReservationResponseModel.php @@ -15,6 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\BaseResponseModel; + class FinishReservationResponseModel extends BaseResponseModel implements iBarionModel { public $IsSuccessful; @@ -38,10 +44,10 @@ public function fromJson($json) if (!empty($json)) { parent::fromJson($json); - $this->IsSuccessful = jget($json, 'IsSuccessful'); - $this->PaymentId = jget($json, 'PaymentId'); - $this->PaymentRequestId = jget($json, 'PaymentRequestId'); - $this->Status = jget($json, 'Status'); + $this->IsSuccessful = \Barion\Helpers\jget($json, 'IsSuccessful'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); + $this->PaymentRequestId = \Barion\Helpers\jget($json, 'PaymentRequestId'); + $this->Status = \Barion\Helpers\jget($json, 'Status'); $this->Transactions = array(); diff --git a/library/models/payment/PayeeTransactionModel.php b/library/models/payment/PayeeTransactionModel.php index 1771c42..f5b7222 100644 --- a/library/models/payment/PayeeTransactionModel.php +++ b/library/models/payment/PayeeTransactionModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + class PayeeTransactionModel { public $POSTransactionId; diff --git a/library/models/payment/PayeeTransactionToFinishModel.php b/library/models/payment/PayeeTransactionToFinishModel.php index a7c7ca5..0be233c 100644 --- a/library/models/payment/PayeeTransactionToFinishModel.php +++ b/library/models/payment/PayeeTransactionToFinishModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + class PayeeTransactionToFinishModel { public $TransactionId; diff --git a/library/models/payment/PaymentQRRequestModel.php b/library/models/payment/PaymentQRRequestModel.php index 1a8d4cc..d2169e6 100644 --- a/library/models/payment/PaymentQRRequestModel.php +++ b/library/models/payment/PaymentQRRequestModel.php @@ -15,6 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Common\QRCodeSize; +use Barion\Models\BaseRequestModel; + class PaymentQRRequestModel extends BaseRequestModel { public $UserName; diff --git a/library/models/payment/PaymentStateRequestModel.php b/library/models/payment/PaymentStateRequestModel.php index eb4a6d8..9654744 100644 --- a/library/models/payment/PaymentStateRequestModel.php +++ b/library/models/payment/PaymentStateRequestModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\BaseRequestModel; + class PaymentStateRequestModel extends BaseRequestModel { public $PaymentId; diff --git a/library/models/payment/PaymentStateResponseModel.php b/library/models/payment/PaymentStateResponseModel.php index c09f7db..61d1e92 100644 --- a/library/models/payment/PaymentStateResponseModel.php +++ b/library/models/payment/PaymentStateResponseModel.php @@ -15,6 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\Common\FundingInformationModel; +use Barion\Models\BaseResponseModel; + class PaymentStateResponseModel extends BaseResponseModel implements iBarionModel { public $PaymentId; @@ -76,32 +83,32 @@ public function fromJson($json) if (!empty($json)) { parent::fromJson($json); - $this->PaymentId = jget($json, 'PaymentId'); - $this->PaymentRequestId = jget($json, 'PaymentRequestId'); - $this->OrderNumber = jget($json, 'OrderNumber'); - $this->POSId = jget($json, 'POSId'); - $this->POSName = jget($json, 'POSName'); - $this->POSOwnerEmail = jget($json, 'POSOwnerEmail'); - $this->Status = jget($json, 'Status'); - $this->PaymentType = jget($json, 'PaymentType'); - $this->FundingSource = jget($json, 'FundingSource'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); + $this->PaymentRequestId = \Barion\Helpers\jget($json, 'PaymentRequestId'); + $this->OrderNumber = \Barion\Helpers\jget($json, 'OrderNumber'); + $this->POSId = \Barion\Helpers\jget($json, 'POSId'); + $this->POSName = \Barion\Helpers\jget($json, 'POSName'); + $this->POSOwnerEmail = \Barion\Helpers\jget($json, 'POSOwnerEmail'); + $this->Status = \Barion\Helpers\jget($json, 'Status'); + $this->PaymentType = \Barion\Helpers\jget($json, 'PaymentType'); + $this->FundingSource = \Barion\Helpers\jget($json, 'FundingSource'); if(!empty($json['FundingInformation'])) { $this->FundingInformation = new FundingInformationModel(); - $this->FundingInformation->fromJson(jget($json, 'FundingInformation')); + $this->FundingInformation->fromJson(Barion\Helpers\jget($json, 'FundingInformation')); } - $this->AllowedFundingSources = jget($json, 'AllowedFundingSources'); - $this->GuestCheckout = jget($json, 'GuestCheckout'); - $this->CreatedAt = jget($json, 'CreatedAt'); - $this->ValidUntil = jget($json, 'ValidUntil'); - $this->CompletedAt = jget($json, 'CompletedAt'); - $this->ReservedUntil = jget($json, 'ReservedUntil'); - $this->Total = jget($json, 'Total'); - $this->Currency = jget($json, 'Currency'); - $this->RecurrenceResult = jget($json, 'RecurrenceResult'); - $this->SuggestedLocale = jget($json, 'SuggestedLocale'); - $this->FraudRiskScore = jget($json, 'FraudRiskScore'); - $this->RedirectUrl = jget($json, 'RedirectUrl'); - $this->CallbackUrl = jget($json, 'CallbackUrl'); + $this->AllowedFundingSources = \Barion\Helpers\jget($json, 'AllowedFundingSources'); + $this->GuestCheckout = \Barion\Helpers\jget($json, 'GuestCheckout'); + $this->CreatedAt = \Barion\Helpers\jget($json, 'CreatedAt'); + $this->ValidUntil = \Barion\Helpers\jget($json, 'ValidUntil'); + $this->CompletedAt = \Barion\Helpers\jget($json, 'CompletedAt'); + $this->ReservedUntil = \Barion\Helpers\jget($json, 'ReservedUntil'); + $this->Total = \Barion\Helpers\jget($json, 'Total'); + $this->Currency = \Barion\Helpers\jget($json, 'Currency'); + $this->RecurrenceResult = \Barion\Helpers\jget($json, 'RecurrenceResult'); + $this->SuggestedLocale = \Barion\Helpers\jget($json, 'SuggestedLocale'); + $this->FraudRiskScore = \Barion\Helpers\jget($json, 'FraudRiskScore'); + $this->RedirectUrl = \Barion\Helpers\jget($json, 'RedirectUrl'); + $this->CallbackUrl = \Barion\Helpers\jget($json, 'CallbackUrl'); $this->Transactions = array(); diff --git a/library/models/payment/PaymentTransactionModel.php b/library/models/payment/PaymentTransactionModel.php index 637167a..3bdebff 100644 --- a/library/models/payment/PaymentTransactionModel.php +++ b/library/models/payment/PaymentTransactionModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\Common\ItemModel; + class PaymentTransactionModel { public $POSTransactionId; diff --git a/library/models/payment/PreparePaymentRequestModel.php b/library/models/payment/PreparePaymentRequestModel.php index 9611664..b3d7473 100644 --- a/library/models/payment/PreparePaymentRequestModel.php +++ b/library/models/payment/PreparePaymentRequestModel.php @@ -15,6 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Common\PaymentType; +use Barion\Common\FundingSourceType; +use Barion\Models\BaseRequestModel; + class PreparePaymentRequestModel extends BaseRequestModel { public $PaymentType; diff --git a/library/models/payment/PreparePaymentResponseModel.php b/library/models/payment/PreparePaymentResponseModel.php index d03034b..0530918 100644 --- a/library/models/payment/PreparePaymentResponseModel.php +++ b/library/models/payment/PreparePaymentResponseModel.php @@ -15,6 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\BaseResponseModel; + class PreparePaymentResponseModel extends BaseResponseModel implements iBarionModel { public $PaymentId; @@ -41,11 +47,11 @@ public function fromJson($json) { if (!empty($json)) { parent::fromJson($json); - $this->PaymentId = jget($json, 'PaymentId'); - $this->PaymentRequestId = jget($json, 'PaymentRequestId'); - $this->Status = jget($json, 'Status'); - $this->QRUrl = jget($json, 'QRUrl'); - $this->RecurrenceResult = jget($json, 'RecurrenceResult'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); + $this->PaymentRequestId = \Barion\Helpers\jget($json, 'PaymentRequestId'); + $this->Status = \Barion\Helpers\jget($json, 'Status'); + $this->QRUrl = \Barion\Helpers\jget($json, 'QRUrl'); + $this->RecurrenceResult = \Barion\Helpers\jget($json, 'RecurrenceResult'); $this->Transactions = array(); if (!empty($json['Transactions'])) { diff --git a/library/models/payment/TransactionDetailModel.php b/library/models/payment/TransactionDetailModel.php index ee77bcc..c776d46 100644 --- a/library/models/payment/TransactionDetailModel.php +++ b/library/models/payment/TransactionDetailModel.php @@ -15,6 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; +use Barion\Models\Common\ItemModel; +use Barion\Models\Common\UserModel; + class TransactionDetailModel implements iBarionModel { public $TransactionId; diff --git a/library/models/payment/TransactionResponseModel.php b/library/models/payment/TransactionResponseModel.php index 88828c6..c7dc05f 100644 --- a/library/models/payment/TransactionResponseModel.php +++ b/library/models/payment/TransactionResponseModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Helpers\iBarionModel; + class TransactionResponseModel implements iBarionModel { public $POSTransactionId; diff --git a/library/models/payment/TransactionToCaptureModel.php b/library/models/payment/TransactionToCaptureModel.php index 8014a26..8624df2 100644 --- a/library/models/payment/TransactionToCaptureModel.php +++ b/library/models/payment/TransactionToCaptureModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\Common\ItemModel; + class TransactionToCaptureModel { public $TransactionId; diff --git a/library/models/payment/TransactionToFinishModel.php b/library/models/payment/TransactionToFinishModel.php index e9473ac..07a43f3 100644 --- a/library/models/payment/TransactionToFinishModel.php +++ b/library/models/payment/TransactionToFinishModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + +use Barion\Models\Common\ItemModel; + class TransactionToFinishModel { public $TransactionId; diff --git a/library/models/payment/TransactionToRefundModel.php b/library/models/payment/TransactionToRefundModel.php index 32ab049..0f9c638 100644 --- a/library/models/payment/TransactionToRefundModel.php +++ b/library/models/payment/TransactionToRefundModel.php @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Payment; + class TransactionToRefundModel { public $TransactionId; diff --git a/library/models/refund/RefundRequestModel.php b/library/models/refund/RefundRequestModel.php index f44e74b..d1ec906 100644 --- a/library/models/refund/RefundRequestModel.php +++ b/library/models/refund/RefundRequestModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +namespace Barion\Models\Refund; + +use Barion\Models\BaseRequestModel; +use Barion\Models\Payment\TransactionToRefundModel; + class RefundRequestModel extends BaseRequestModel { public $PaymentId; diff --git a/library/models/refund/RefundResponseModel.php b/library/models/refund/RefundResponseModel.php index a3b6acc..c53e1af 100644 --- a/library/models/refund/RefundResponseModel.php +++ b/library/models/refund/RefundResponseModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +namespace Barion\Models\Refund; + +use Barion\Helpers\iBarionModel; +use Barion\Models\BaseResponseModel; + class RefundResponseModel extends BaseResponseModel implements iBarionModel { public $PaymentId; @@ -32,7 +37,7 @@ public function fromJson($json) if (!empty($json)) { parent::fromJson($json); - $this->PaymentId = jget($json, 'PaymentId'); + $this->PaymentId = \Barion\Helpers\jget($json, 'PaymentId'); $this->RefundedTransactions = array(); if (!empty($json['RefundedTransactions'])) { diff --git a/library/models/refund/RefundedTransactionModel.php b/library/models/refund/RefundedTransactionModel.php index 4e1715f..e99b867 100644 --- a/library/models/refund/RefundedTransactionModel.php +++ b/library/models/refund/RefundedTransactionModel.php @@ -15,6 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Barion\Models\Refund; + +use Barion\Helpers\iBarionModel; + class RefundedTransactionModel implements iBarionModel { public $TransactionId; diff --git a/readme.md b/readme.md index 11916f7..edb406c 100755 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ Copy the contents of the **barion** library into the desired folder. Be sure to Include the **BarionClient** class in your PHP script: ```php -require_once 'library/BarionClient.php'; +use Barion\BarionClient; ``` Then instantiate a Barion client. To achieve this, you must supply three parameters. @@ -67,16 +67,16 @@ The environment to connect to. This can be the test system, or the production en ```php // Test environment -$environment = BarionEnvironment::Test; +$environment = Barion\Common\BarionEnvironment::Test; // Production environment -$environment = BarionEnvironment::Prod; +$environment = Barion\Common\BarionEnvironment::Prod; ``` -With these parameters you can create an instance of the **BarionClient** class: +With these parameters you can create an instance of the **Barion\BarionClient** class: ```php -$BC = new BarionClient($myPosKey, $apiVersion, $environment); +$BC = new Barion\BarionClient($myPosKey, $apiVersion, $environment); ``` If you're having problems with the SSL connection then you can set the fourth parameter to true: `$useBundledRootCerts` @@ -92,10 +92,10 @@ Using the library, managing a payment process consists of two steps: To start an online payment, you have to create one or more **Payment Transaction** objects, add transaction **Items** to them, then group these transactions together in a **Payment** object. -First, create an **ItemModel**: +First, create an **Barion\Models\Common\ItemModel**: ```php -$item = new ItemModel(); +$item = new Barion\Models\Common\ItemModel(); $item->Name = "TestItem"; $item->Description = "A test product"; $item->Quantity = 1; @@ -105,30 +105,30 @@ $item->ItemTotal = 1000; $item->SKU = "ITEM-01"; ``` -Then create a **PaymentTransactionModel** and add the **Item** mentioned above to it: +Then create a **Barion\Models\Payment\PaymentTransactionModel** and add the **Item** mentioned above to it: ```php -$trans = new PaymentTransactionModel(); +$trans = new Barion\Models\Payment\PaymentTransactionModel(); $trans->POSTransactionId = "TRANS-01"; $trans->Payee = "webshop@example.com"; $trans->Total = 1000; -$trans->Currency = Currency::HUF; +$trans->Currency = Barion\Common\Currency::HUF; $trans->Comment = "Test transaction containing the product"; $trans->AddItem($item); ``` -Finally, create a **PreparePaymentRequestModel** and add the **PaymentTransactionModel** mentioned above to it: +Finally, create a **Barion\Models\Payment\PreparePaymentRequestModel** and add the **Barion\Models\Payment\PaymentTransactionModel** mentioned above to it: ```php -$ppr = new PreparePaymentRequestModel(); +$ppr = new Barion\Models\Payment\PreparePaymentRequestModel(); $ppr->GuestCheckout = true; -$ppr->PaymentType = PaymentType::Immediate; -$ppr->FundingSources = array(FundingSourceType::All); +$ppr->PaymentType = Barion\Common\PaymentType::Immediate; +$ppr->FundingSources = array(Barion\Common\FundingSourceType::All); $ppr->PaymentRequestId = "PAYMENT-01"; $ppr->PayerHint = "user@example.com"; -$ppr->Locale = UILocale::EN; +$ppr->Locale = Barion\Common\UILocale::EN; $ppr->OrderNumber = "ORDER-0001"; -$ppr->Currency = Currency::HUF; +$ppr->Currency = Barion\Common\Currency::HUF; $ppr->RedirectUrl = "http://webshop.example.com/afterpayment"; $ppr->CallbackUrl = "http://webshop.example.com/processpayment"; $ppr->AddTransaction($trans); @@ -146,7 +146,7 @@ $myPayment = $BC->PreparePayment($ppr); The Barion API now prepares a payment entity that can be paid by anyone. -The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **PreparePaymentResponseModel** object. +The **$myPayment** variable holds the response received from the Barion API, which is an instance of a **Barion\Models\Payment\PreparePaymentRequestModel** object. ### 1.3. Redirecting the user to the Barion Smart Gateway