Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Buijsrogge committed Mar 15, 2017
2 parents 74c56bc + 765269f commit 733b3cd
Show file tree
Hide file tree
Showing 50 changed files with 4,369 additions and 156 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/.idea
/.idea/

/tmp/

/tests/.env

composer.phar
/vendor/
/vendor/
195 changes: 130 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This package will connect to the JSON API of Buckaroo, if you prefer SOAP over J
This package uses [Composer](https://getcomposer.org/) as PHP dependency manager, you need to run the following command within the root of your project.

```
composer require sebudesign/buckaroo-php-json
composer require sebudesign/buckaroo-json
```

### Usage
Expand All @@ -18,7 +18,11 @@ composer require sebudesign/buckaroo-php-json
require 'vendor/autoload.php';

use SeBuDesign\BuckarooJson\Transaction;
use SeBuDesign\BuckarooJson\Service;
use SeBuDesign\BuckarooJson\TransactionStatus;
use SeBuDesign\BuckarooJson\Parts\IpAddress;
use SeBuDesign\BuckarooJson\Parts\Service;
use SeBuDesign\BuckarooJson\Parts\OriginalTransactionReference;
use SeBuDesign\BuckarooJson\Parts\ContinueOnIncomplete;

class Foo
{
Expand All @@ -27,12 +31,17 @@ class Foo
// Replace your website-key and secret-key with your keys
$transaction = new Transaction('website-key', 'secret-key');

// Create a test transaction
$transaction->putInTestMode();

// Set the currency of the transaction
$transaction->setCurrency('EUR');

// Set the amount credit or debit
// Set the amount credit
$transaction->setAmountCredit(1.99);
// $transaction->setAmountDebit(1.99);

// Set the amount debit
$transaction->setAmountDebit(1.99);

// Set the unique invoice number
$transaction->setInvoice('UniqueInvoice');
Expand All @@ -44,120 +53,176 @@ class Foo
$transaction->setDescription('Your transaction description');

// Set the client IP
$transaction->setClientIp('127.0.0.1');
$oIpAddress = new IpAddress();
$oIpAddress->setAddress('127.0.0.1');
$transaction->setClientIP($oIpAddress);

// Set the client user agent
$transaction->setClientUserAgent('google-chrome');

// Set the return url
$transaction->setReturnUrl('https://google.com/');
$transaction->setReturnURL('https://google.com/');

// Set the return url in case of a cancellation
$transaction->setCancelUrl('https://google.com/');
$transaction->setReturnURLCancel('https://google.com/');

// Set the return url in case of an error
$transaction->setErrorUrl('https://google.com/');
$transaction->setReturnURLError('https://google.com/');

// Set the return url in case of a rejection
$transaction->setRejectUrl('https://google.com/');
$transaction->setReturnURLReject('https://google.com/');

// Set the original transaction object
$transaction->setOriginalTransaction('type', 'reference');
$oOriginalTransactionReference = new OriginalTransactionReference();
$oOriginalTransactionReference->setType('type');
$oOriginalTransactionReference->setReference('reference');
$transaction->setOriginalTransactionReference($oOriginalTransactionReference);

// Set the push url to push the transaction status to
$transaction->setPushUrl('https://google.com/');
$transaction->setPushURL('https://google.com/');

// Set the push url to push the transaction status in case of a failure
$transaction->setFailurePushUrl('https://google.com/');
$transaction->setPushURLFailure('https://google.com/');

// Set the original transaction key
$transaction->setOriginalTransactionKey('original-transaction-key');

// Do you want to start a recurring payment?
$transaction->startRecurringPayment();
// Default: false
$transaction->setStartRecurrent(true);

// Continue on incomplete payment?
$transaction->continueOnIncomplete();
// Default: ContinueOnIncomplete::No
$transaction->setContinueOnIncomplete(ContinueOnIncomplete::RedirectToHTML);

// Add a service
$service = new Service();
$service->setName('name');
$service->setAction('action');
$service->setVersion(3);

// Service parameters
$service->addParameter('name', 'value');
$service->addParameter('name', 'value', 'group-type', 'group-id');
$service->addParameter('name', 'value', 'group-id', 'group-type');

$service->hasParameter('name'); // true
$service->hasParameter('foo'); // false

$service->getParameter('name');
$service->removeParameter('name');

$transaction->addService($service);

// Add a custom parameter
$transaction->addCustomParameter('name', 'value');
// Has a custom parameter
$transaction->hasCustomParameter('name');
// Remove a custom parameter
$transaction->removeCustomParameter('name');
// Has a custom parameter
$transaction->hasCustomParameter('name');

// Add an additional parameter
$transaction->addAdditionalParameter('name', 'value');
// Has an additional parameter
$transaction->hasAdditionalParameter('name');
// Remove an additional parameter
$transaction->removeAdditionalParameter('name');
// has an additional parameter
$transaction->hasAdditionalParameter('name');

// Start the transaction
$transactionAction = $transaction->start();
$transactionResponse = $transaction->start();

var_dump(
$transactionAction->getTransactionKey(),
$transactionAction->getOrder(),
$transactionAction->getIssuingCountry(),
$transactionAction->getInvoice(),
$transactionAction->getServiceCode(),
$transactionAction->getCurrency(),
$transactionAction->getAmountDebit(),
$transactionAction->getAmountCredit(),
$transactionAction->getTransactionType(),
$transactionAction->getMutationType(),
$transactionAction->getRelatedTransactions(),
$transactionAction->getRelatedTransactions()[1]->getType(),
$transactionAction->getRelatedTransactions()[1]->getTransactionKey(),
$transactionAction->getConsumerMessage(),
$transactionAction->getConsumerMessage()->hasToRead(),
$transactionAction->getConsumerMessage()->getCulture(),
$transactionAction->getConsumerMessage()->getTitle(),
$transactionAction->getConsumerMessage()->getPlainText(),
$transactionAction->getConsumerMessage()->getHtmlText(),
$transactionAction->isTest(),
$transactionAction->isFirstRecurring(),
$transactionAction->isRecurring(),
$transactionAction->getClientName(),
$transactionAction->getPayerHash(),
$transactionAction->getPaymentKey(),
$transactionAction->getStatus()->getCode(),
$transactionAction->getStatus()->getDescription(),
$transactionAction->getSubStatus()->getCode(),
$transactionAction->getSubStatus()->getDescription(),
$transactionAction->getStatusChangedAt(),
$transactionAction->getRequiredAction()->hasToRedirect(),
$transactionAction->getRequiredAction()->getName(),
$transactionAction->getRequiredAction()->isDeprecated(),
$transactionAction->getRequiredAction()->getRedirectUrl(),
$transactionAction->getRequiredAction()->getRequestedInformation(),
$transactionAction->getRequiredAction()->getPayRemainderDetails()->getRemainderAmount(),
$transactionAction->getRequiredAction()->getPayRemainderDetails()->getCurrency(),
$transactionAction->getServices(),
$transactionAction->getServices()[1]->getName(),
$transactionAction->getServices()[1]->getAction(),
$transactionAction->getServices()[1]->getVersion(),
$transactionAction->getServices()[1]->getParameters(),
$transactionAction->getCustomParameters(),
$transactionAction->getAdditionalParameters(),
$transactionAction->hasErrors(),
$transactionAction->getErrors(),
$transactionResponse->getTransactionKey(),
$transactionResponse->getOrder(),
$transactionResponse->getIssuingCountry(),
$transactionResponse->getInvoice(),
$transactionResponse->getServiceCode(),
$transactionResponse->getCurrency(),
$transactionResponse->getAmountDebit(),
$transactionResponse->getAmountCredit(),
$transactionResponse->getTransactionType(),
$transactionResponse->getMutationType(),
$transactionResponse->getRelatedTransactions(),
$transactionResponse->hasConsumerMessage(),
$transactionResponse->hasToReadConsumerMessage(),
$transactionResponse->getConsumerMessage(),
$transactionResponse->isTest(),
$transactionResponse->hasStartedRecurringPayment(),
$transactionResponse->isRecurringPayment(),
$transactionResponse->isCancelable(),
$transactionResponse->getCustomerName(),
$transactionResponse->getPayerHash(),
$transactionResponse->getPaymentKey(),
$transactionResponse->getStatusCode(),
$transactionResponse->getStatusSubCode(),
$transactionResponse->getDateTimeOfStatusChange(),
$transactionResponse->hasRequiredAction(),
$transactionResponse->getRequestedInformation(),
$transactionResponse->hasToRedirect(),
$transactionResponse->hasToPayRemainder(),
$transactionResponse->getRemainderAmount(),
$transactionResponse->getRemainderCurrency(),
$transactionResponse->getRemainderGroupTransaction(),
$transactionResponse->getRedirectUrl(),
$transactionResponse->getServices(),
$transactionResponse->getService('name'),
$transactionResponse->getServiceParameters('name'),
$transactionResponse->getCustomParameters(),
$transactionResponse->getAdditionalParameters(),
$transactionResponse->hasErrors(),
$transactionResponse->getErrors()
);
}

public function getTransactionStatus()
{
$transactionStatus = new TransactionStatus('website-key', 'secret-key');
$transactionResponse = $transactionStatus->get('transaction-key');

if ($transactionAction->getRequiredAction()->hasToRedirect()) {
header('Location: ' . $transactionAction->getRequiredAction()->getRedirectUrl());
}
var_dump(
$transactionResponse->getTransactionKey(),
$transactionResponse->getOrder(),
$transactionResponse->getIssuingCountry(),
$transactionResponse->getInvoice(),
$transactionResponse->getServiceCode(),
$transactionResponse->getCurrency(),
$transactionResponse->getAmountDebit(),
$transactionResponse->getAmountCredit(),
$transactionResponse->getTransactionType(),
$transactionResponse->getMutationType(),
$transactionResponse->getRelatedTransactions(),
$transactionResponse->hasConsumerMessage(),
$transactionResponse->hasToReadConsumerMessage(),
$transactionResponse->getConsumerMessage(),
$transactionResponse->isTest(),
$transactionResponse->hasStartedRecurringPayment(),
$transactionResponse->isRecurringPayment(),
$transactionResponse->isCancelable(),
$transactionResponse->getCustomerName(),
$transactionResponse->getPayerHash(),
$transactionResponse->getPaymentKey(),
$transactionResponse->getStatusCode(),
$transactionResponse->getStatusSubCode(),
$transactionResponse->getDateTimeOfStatusChange(),
$transactionResponse->hasRequiredAction(),
$transactionResponse->getRequestedInformation(),
$transactionResponse->hasToRedirect(),
$transactionResponse->hasToPayRemainder(),
$transactionResponse->getRemainderAmount(),
$transactionResponse->getRemainderCurrency(),
$transactionResponse->getRemainderGroupTransaction(),
$transactionResponse->getRedirectUrl(),
$transactionResponse->getServices(),
$transactionResponse->getService('name'),
$transactionResponse->getServiceParameters('name'),
$transactionResponse->getCustomParameters(),
$transactionResponse->getAdditionalParameters(),
$transactionResponse->hasErrors(),
$transactionResponse->getErrors()
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "sebudesign/buckaroo-php-json",
"name": "sebudesign/buckaroo-json",
"description": "Connect to the JSON API from Buckaroo",
"keywords": ["PHP", "Buckaroo", "JSON"],
"type": "library",
Expand All @@ -20,7 +20,9 @@
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^6.0",
"fzaninotto/faker": "^1.6",
"vlucas/phpdotenv": "^2.4"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 733b3cd

Please sign in to comment.