Skip to content

Commit

Permalink
Merge pull request #7 from gopaycommunity/fix/eet
Browse files Browse the repository at this point in the history
Fix eet example and refactor data
  • Loading branch information
gopayprovoz authored Feb 21, 2017
2 parents 35fd946 + 5f9caa0 commit 379b683
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 207 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/vendor/
# IDE
/nbproject/
.idea

# APP
/vendor/
/bin/
!/bin/jenkins.sh
/var/
/phpunit.xml
.idea
/vendor
composer.phar
composer.sh
182 changes: 0 additions & 182 deletions examples/create-payment-eet.php

This file was deleted.

146 changes: 146 additions & 0 deletions examples/eet-payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use GoPay\Definition\Language;
use GoPay\Definition\Payment\Currency;
use GoPay\Definition\Payment\PaymentInstrument;
use GoPay\Definition\Payment\BankSwiftCode;
use GoPay\Definition\Payment\VatRate;
use GoPay\Definition\Payment\PaymentItemType;

$gopay = GoPay\payments([
'goid' => 'my goid',
'clientId' => '[email protected]',
'clientSecret' => 'my secret',
'isProductionMode' => false,
'language' => Language::CZECH
]);

// Create standard payment
$payment = [
'payer' => [
'default_payment_instrument' => PaymentInstrument::BANK_ACCOUNT,
'allowed_payment_instruments' => [PaymentInstrument::BANK_ACCOUNT],
'default_swift' => BankSwiftCode::FIO_BANKA, 'FIOBCZPP',
'allowed_swifts' => [BankSwiftCode::FIO_BANKA, BankSwiftCode::MBANK],
'contact' => [
'first_name' => 'Zbynek',
'last_name' => 'Zak',
'email' => '[email protected]',
'phone_number' => '+420777456123',
'city' => 'C.Budejovice',
'street' => 'Plana 67',
'postal_code' => '373 01',
'country_code' => 'CZE'
],
],
'target' => ['type' => 'ACCOUNT', 'goid' => '8123456789'],
'amount' => 1000,
'currency' => Currency::CZECH_CROWNS,
'order_number' => '001',
'order_description' => 'obuv',
'items' => [
[
'type' => 'ITEM',
'name' => 'obuv',
'product_url' => 'https://www.eshop.cz/boty/lodicky',
'ean' => 1234567890123,
'amount' => 119990,
'count' => 1,
'vat_rate' => VatRate::RATE_4
],
[
'type' => PaymentItemType::ITEM,
'name' => 'oprava podpatku',
'product_url' => 'https://www.eshop.cz/boty/opravy',
'ean' => 1234567890189,
'amount' => 19960,
'count' => 1,
'vat_rate' => VatRate::RATE_3
],
],
'additional_params' => [
['name' => 'invoicenumber', 'value' => '2015001003'],
],
'callback' => [
'return_url' => 'https://www.eshop.cz/return',
'notification_url' => 'https://www.eshop.cz/notify'
],
'lang' => Language::CZECH
];

$eet = [
'eet' => [
'celk_trzba' => 139950,
'zakl_dan1' => 99165,
'dan1' => 20825,
'zakl_dan2' => 17357,
'dan2' => 2604,
'mena' => Currency::CZECH_CROWNS
]
];

$paymentWithEet = $payment + $eet;
$createPaymentResponse = $gopay->createPayment($paymentWithEet);

// Refund payment
$refundPaymentResponse = $gopay->refundPayment(3000006620, [
'amount' => 119990,
'items' => [
[
'type' => PaymentItemType::ITEM,
'name' => 'lodicky',
'product_url' => 'https://www.eshop.cz/boty/damske/lodicky-cervene',
'ean' => 1234567890123,
'amount' => -119990,
'count' => 1,
'vat_rate' => VatRate::RATE_4
],
],
'eet' => [
'celk_trzba' => -119990,
'zakl_dan1' => -99165,
'dan1' => -20825,
'dan2' => -2604
],
]);

// Create reccurent payment
$recurrence = [
'recurrence' => [
'recurrence_cycle' => 'DAY',
'recurrence_period' => '7',
'recurrence_date_to' => '2015-12-31'
]
];

$reccurentPaymentResponse = $gopay->createPayment($paymentWithEet + $recurrence);

// After reccurent payment is created, you can withold money
$reccurenceResponse = $gopay->createRecurrence(3000006620, [
'amount' => '500',
'currency' => Currency::CZECH_CROWNS,
'order_number' => 'Nakup',
'order_description' => '2016-0001254',
'items' => [
[
'type' => PaymentItemType::ITEM,
'name' => 'lodicky',
'product_url' => 'https://www.eshop.cz/boty//lodicky',
'ean' => 1234567890123,
'amount' => 119990,
'count' => 1,
'vat_rate' => VatRate::RATE_4
],
],
'eet' => [
'celk_trzba' => 119990,
'zakl_dan1' => 99165,
'dan1' => 20825,
'mena' => Currency::CZECH_CROWNS
],
'additional_params' => [
['name' => 'invoicenumber', 'value' => '2016001004'],
]
]);
2 changes: 1 addition & 1 deletion src/Definition/Payment/PaymentItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class PaymentItemType
const ITEM = 'ITEM';
const DISCOUNT = 'DISCOUNT';
const DELIVERY = 'DELIVERY';
}
}
2 changes: 1 addition & 1 deletion src/Definition/Payment/VatRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class VatRate
const RATE_2 = 10;
const RATE_3 = 15;
const RATE_4 = 21;
}
}
2 changes: 1 addition & 1 deletion src/GoPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function buildUrl($urlPath)
{
static $urls = [
true => 'https://gate.gopay.cz/',
false => 'http://gopay-gw:8180/gp/'
false => 'https://gw.sandbox.gopay.com/'
];
return $urls[(bool) $this->getConfig('isProductionMode')] . $urlPath;
}
Expand Down
Loading

0 comments on commit 379b683

Please sign in to comment.