diff --git a/.gitignore b/.gitignore
index 625fe2c..89068f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,9 @@
/build
/vendor
-composer.lock
-composer.phar
-phpunit.xml
-phpunit.phar
-php-cs-fixer.phar
-cache.properties
+/composer.lock
+/composer.phar
+/phpunit.xml
+/phpunit.phar
+/php-cs-fixer.phar
+/cache.properties
+/behat.yml
diff --git a/README.md b/README.md
index 3be2386..c501c56 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ If you want to use Veritrans Payment API without Omnipay, we suggest you check o
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply run:
- $ php composer.phar require andylibrian/omnipay-veritrans:dev-master
+ $ php composer.phar require andylibrian/omnipay-veritrans
## Basic Usage
diff --git a/behat.yml.dist b/behat.yml.dist
new file mode 100644
index 0000000..3970075
--- /dev/null
+++ b/behat.yml.dist
@@ -0,0 +1,22 @@
+default:
+ suites:
+ default:
+ contexts:
+ - FeatureContext
+ filters:
+ tags: "~@javascript"
+ javascript:
+ contexts:
+ - FeatureContext
+ filters:
+ tags: "@javascript"
+ extensions:
+ Behat\MinkExtension\ServiceContainer\MinkExtension:
+ sessions:
+ default:
+ goutte: ~
+ javascript:
+ selenium2: ~
+ base_url: http://localhost/sites/omnipay-veritrans/demo
+ selenium2: ~
+ browser_name: firefox
diff --git a/composer.json b/composer.json
index 94cb9cd..4d9e4c5 100644
--- a/composer.json
+++ b/composer.json
@@ -29,7 +29,12 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "~1.4",
- "omnipay/tests": "~2.0"
+ "omnipay/tests": "~2.0",
+ "behat/behat": "~3.0",
+ "behat/mink": "~1.6",
+ "behat/mink-extension": "~2.0",
+ "behat/mink-goutte-driver": "~1.1",
+ "behat/mink-selenium2-driver": "~1.2"
},
"autoload": {
"psr-4": {
@@ -43,7 +48,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "0.1.x-dev"
+ "dev-master": "2.0.x-dev"
}
}
}
diff --git a/demo/bri_epay/checkout_bri_epay.php b/demo/bri_epay/checkout_bri_epay.php
new file mode 100644
index 0000000..0d8fb61
--- /dev/null
+++ b/demo/bri_epay/checkout_bri_epay.php
@@ -0,0 +1,33 @@
+setServerKey($serverKey);
+$gateway->setEnvironment('sandbox');
+
+$data = array(
+ 'transactionId' => mt_rand(1, 99999999),
+ 'amount' => $_POST['amount'] . '.00',
+ 'card' => new CreditCard(),
+ 'currency' => 'IDR',
+);
+
+$response = $gateway->authorize($data)->send();
+
+if ($response->isSuccessful()) {
+ // payment success, update database
+ var_dump($successful);
+ var_dump($response);
+} elseif ($response->isRedirect()) {
+ // redirect to offsite payment gateway
+ $response->redirect();
+} else {
+ var_dump('else');
+ echo $response->getMessage();
+}
diff --git a/demo/bri_epay/form.html b/demo/bri_epay/form.html
new file mode 100644
index 0000000..72be427
--- /dev/null
+++ b/demo/bri_epay/form.html
@@ -0,0 +1,47 @@
+
+
+ Codestin Search App
+
+
+
+
+ BRI ePay Transaction
+
+
+
+
diff --git a/demo/cimb_clicks/checkout_cimb_clicks.php b/demo/cimb_clicks/checkout_cimb_clicks.php
new file mode 100644
index 0000000..b101e46
--- /dev/null
+++ b/demo/cimb_clicks/checkout_cimb_clicks.php
@@ -0,0 +1,38 @@
+setServerKey($serverKey);
+$gateway->setEnvironment('sandbox');
+
+$data = array(
+ 'transactionId' => mt_rand(1, 99999999),
+ 'amount' => $_POST['amount'] . '.00',
+ 'card' => new CreditCard(),
+ 'currency' => 'IDR',
+ 'cimb_clicks' => [
+ 'description' => 'Demo',
+ ],
+);
+
+$response = $gateway->authorize($data)->send();
+
+if ($response->isSuccessful()) {
+ // payment success, update database
+ var_dump($successful);
+ var_dump($response);
+} elseif ($response->isRedirect()) {
+ // redirect to offsite payment gateway
+ $response->redirect();
+} else {
+ var_dump('else');
+ echo $response->getMessage();
+}
+
+var_dump('x');
diff --git a/demo/cimb_clicks/form.html b/demo/cimb_clicks/form.html
new file mode 100644
index 0000000..defac90
--- /dev/null
+++ b/demo/cimb_clicks/form.html
@@ -0,0 +1,47 @@
+
+
+ Codestin Search App
+
+
+
+
+ CIMB Clicks Transaction
+
+
+
+
diff --git a/demo/mandiri_clickpay/checkout_mandiri.php b/demo/mandiri_clickpay/checkout_mandiri.php
new file mode 100644
index 0000000..eee6787
--- /dev/null
+++ b/demo/mandiri_clickpay/checkout_mandiri.php
@@ -0,0 +1,38 @@
+setServerKey($serverKey);
+$gateway->setEnvironment('sandbox');
+
+$data = array(
+ 'transactionId' => mt_rand(1, 99999999),
+ 'amount' => $_POST['input2'] . '.00',
+ 'card' => new CreditCard(),
+ 'currency' => 'IDR',
+ 'mandiri_clickpay' => [
+ 'card_number' => $_POST['card-number'],
+ 'input1' => $_POST['input1'],
+ 'input2' => $_POST['input2'],
+ 'input3' => $_POST['input3'],
+ 'token' => $_POST['token'],
+ ],
+);
+
+$response = $gateway->authorize($data)->send();
+
+if ($response->isSuccessful()) {
+ // payment success, update database
+ echo 'Transaksi Sukses';
+} elseif ($response->isRedirect()) {
+ // redirect to offsite payment gateway
+ $response->redirect();
+} else {
+ echo $response->getMessage();
+}
diff --git a/demo/mandiri_clickpay/form.html b/demo/mandiri_clickpay/form.html
new file mode 100644
index 0000000..9bad1f1
--- /dev/null
+++ b/demo/mandiri_clickpay/form.html
@@ -0,0 +1,42 @@
+
+
+ Codestin Search App
+
+
+ Mandiri Clickpay Transaction
+
+ - Activate your Mandiri Token
+ - Insert Mandiri Token password
+ - Click 3 when Mandiri Token displays APPLI.
+ - Fill "Input 1": Last 10 digit of your Mandiri Debit card
+ - Fill "Input 2": Transaction Value
+ - Fill "Input 3": Request Number
+ - Fill your Mandiri Token response into “Challenge Token”
+
+
+
+
+
+
diff --git a/demo/tcash/checkout_tcash.php b/demo/tcash/checkout_tcash.php
new file mode 100644
index 0000000..773be8f
--- /dev/null
+++ b/demo/tcash/checkout_tcash.php
@@ -0,0 +1,36 @@
+setServerKey($serverKey);
+$gateway->setEnvironment('sandbox');
+
+$data = array(
+ 'transactionId' => mt_rand(1, 99999999),
+ 'amount' => '100000.00',
+ 'card' => new CreditCard(),
+ 'currency' => 'IDR',
+ 'telkomsel_cash' => [
+ 'customer' => $_POST['token-number'],
+ 'promo' => false,
+ 'is_reversal' => 0,
+ ],
+);
+
+$response = $gateway->authorize($data)->send();
+
+if ($response->isSuccessful()) {
+ // payment success, update database
+ echo 'Transaksi Sukses';
+} elseif ($response->isRedirect()) {
+ // redirect to offsite payment gateway
+ $response->redirect();
+} else {
+ echo $response->getMessage();
+}
diff --git a/demo/tcash/form.html b/demo/tcash/form.html
new file mode 100644
index 0000000..14b4374
--- /dev/null
+++ b/demo/tcash/form.html
@@ -0,0 +1,16 @@
+
+
+ Codestin Search App
+
+
+ T-Cash Transaction
+
+
+
+
diff --git a/demo/xl_tunai/checkout_xl_tunai.php b/demo/xl_tunai/checkout_xl_tunai.php
new file mode 100644
index 0000000..fc8a0e8
--- /dev/null
+++ b/demo/xl_tunai/checkout_xl_tunai.php
@@ -0,0 +1,32 @@
+setServerKey($serverKey);
+$gateway->setEnvironment('sandbox');
+
+$data = array(
+ 'transactionId' => mt_rand(1, 99999999),
+ 'amount' => '100000.00',
+ 'card' => new CreditCard(),
+ 'currency' => 'IDR',
+);
+
+$response = $gateway->authorize($data)->send();
+
+if ($response->isSuccessful()) {
+ // payment success, display ID and order ID
+ var_dump($response->getData());
+ echo 'Transaksi Sukses';
+} elseif ($response->isRedirect()) {
+ // redirect to offsite payment gateway
+ $response->redirect();
+} else {
+ echo $response->getMessage();
+}
diff --git a/demo/xl_tunai/form.html b/demo/xl_tunai/form.html
new file mode 100644
index 0000000..757dc07
--- /dev/null
+++ b/demo/xl_tunai/form.html
@@ -0,0 +1,13 @@
+
+
+ Codestin Search App
+
+
+ XL Tunai Transaction
+
+
+
+
+
diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php
new file mode 100644
index 0000000..bd95eef
--- /dev/null
+++ b/features/bootstrap/FeatureContext.php
@@ -0,0 +1,127 @@
+visitPath('/cimb_clicks/form.html');
+ }
+
+ /**
+ * @Given I am on Mandiri Clickpay Checkout Form
+ */
+ public function iAmOnMandiriClickpayCheckoutForm()
+ {
+ $this->visitPath('/mandiri_clickpay/form.html');
+ }
+
+ /**
+ * @Given I pay
+ */
+ public function iPay()
+ {
+ $this->pressButton('btn-pay');
+ }
+
+ /**
+ * @Then I should be redirected to Veritrans Cimb Clicks Page
+ * @Then I should be redirected to Veritrans BRI Epay Page
+ */
+ public function iShouldBeRedirectedToVeritransCimbClicksPage()
+ {
+ sleep(2);
+ $this->urlMatches('/api.sandbox.veritrans.co.id/');
+ }
+
+ /**
+ * Checks that current session address matches regex.
+ *
+ * @param string $regex
+ *
+ * @throws ExpectationException
+ */
+ public function urlMatches($regex)
+ {
+ $actual = $this->getSession()->getCurrentUrl();
+ $message = sprintf('Current page "%s" does not match the regex "%s".', $actual, $regex);
+
+ $this->assert((bool) preg_match($regex, $actual), $message);
+ }
+
+ /**
+ * Asserts a condition.
+ *
+ * @param bool $condition
+ * @param string $message Failure message
+ *
+ * @throws ExpectationException when the condition is not fulfilled
+ */
+ private function assert($condition, $message)
+ {
+ if ($condition) {
+ return;
+ }
+
+ throw new ExpectationException($message, $this->getSession());
+ }
+
+ /**
+ * @Then I proceed with success CIMB accountID
+ */
+ public function iProceedWithSuccessCimbAccountid()
+ {
+ $this->fillField('account', 'testuser00');
+ $button = $this->getSession()->getPage()->find('css', 'form[action=payment] button[type=submit]');
+ $button->press();
+ }
+
+ /**
+ * @Given I am on BRI Epay Checkout Form
+ */
+ public function iAmOnBriEpayCheckoutForm()
+ {
+ $this->visitPath('/bri_epay/form.html');
+ }
+
+ /**
+ * @Then I proceed with success BRI Epay accountID
+ */
+ public function iProceedWithSuccessBRIEpayAccountid()
+ {
+ $this->fillField('username', 'testuser00');
+ $button = $this->getSession()->getPage()->find('css', 'form[action=payment] button[type=submit]');
+ $button->press();
+ }
+
+ /**
+ * @Given I am on TCash Checkout Form
+ */
+ public function iAmOnTcashCheckoutForm()
+ {
+ $this->visitPath('/tcash/form.html');
+ }
+}
diff --git a/features/bri_epay.feature b/features/bri_epay.feature
new file mode 100644
index 0000000..5e98240
--- /dev/null
+++ b/features/bri_epay.feature
@@ -0,0 +1,14 @@
+@javascript
+Feature: BRI Epay
+ In order to buy a product
+ As a website user
+ I need to be able to pay using BRI Epay
+
+ Scenario: Follow checkout journey
+ Given I am on BRI Epay Checkout Form
+ And I pay
+ Then I should be redirected to Veritrans BRI Epay Page
+ And I proceed with success BRI Epay accountID
+ Then I should see "Transaksi Sukses"
+
+
diff --git a/features/cimb_clicks.feature b/features/cimb_clicks.feature
new file mode 100644
index 0000000..6c77423
--- /dev/null
+++ b/features/cimb_clicks.feature
@@ -0,0 +1,14 @@
+@javascript
+Feature: CIMB Clicks
+ In order to buy a product
+ As a website user
+ I need to be able to pay using CIMB Clicks
+
+ Scenario: Follow checkout journey
+ Given I am on CIMB Clicks Checkout Form
+ And I pay
+ Then I should be redirected to Veritrans Cimb Clicks Page
+ And I proceed with success CIMB accountID
+ Then I should see "Transaksi Sukses"
+
+
diff --git a/features/mandiri_clickpay.feature b/features/mandiri_clickpay.feature
new file mode 100644
index 0000000..d129ddf
--- /dev/null
+++ b/features/mandiri_clickpay.feature
@@ -0,0 +1,11 @@
+Feature: Mandiri Clickpay
+ In order to buy a product
+ As a website user
+ I need to be able to pay using Mandiri Clickpay
+
+ Scenario: Follow checkout journey
+ Given I am on Mandiri Clickpay Checkout Form
+ And I pay
+ Then I should see "Transaksi Sukses"
+
+
diff --git a/features/tcash.feature b/features/tcash.feature
new file mode 100644
index 0000000..7749b51
--- /dev/null
+++ b/features/tcash.feature
@@ -0,0 +1,11 @@
+Feature: TCash
+ In order to buy a product
+ As a website user
+ I need to be able to pay using TCash
+
+ Scenario: Follow checkout journey
+ Given I am on TCash Checkout Form
+ And I pay
+ Then I should see "Transaksi Sukses"
+
+
diff --git a/src/VTDirect/BRIEpayGateway.php b/src/VTDirect/BRIEpayGateway.php
new file mode 100644
index 0000000..146c2f9
--- /dev/null
+++ b/src/VTDirect/BRIEpayGateway.php
@@ -0,0 +1,57 @@
+ '',
+ 'environment' => 'production',
+ );
+ }
+
+ public function setServerKey($key)
+ {
+ $this->setParameter('serverKey', $key);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function authorize(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\BRIEpay\TransactionChargeRequest',
+ $parameters
+ );
+ }
+
+ public function purchase(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\BRIEpay\TransactionChargeRequest',
+ $parameters
+ );
+ }
+}
diff --git a/src/VTDirect/CimbClicksGateway.php b/src/VTDirect/CimbClicksGateway.php
new file mode 100644
index 0000000..7a651d2
--- /dev/null
+++ b/src/VTDirect/CimbClicksGateway.php
@@ -0,0 +1,57 @@
+ '',
+ 'environment' => 'production',
+ );
+ }
+
+ public function setServerKey($key)
+ {
+ $this->setParameter('serverKey', $key);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function authorize(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\CimbClicks\TransactionChargeRequest',
+ $parameters
+ );
+ }
+
+ public function purchase(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\CimbClicks\TransactionChargeRequest',
+ $parameters
+ );
+ }
+}
diff --git a/src/VTDirect/MandiriClickpayGateway.php b/src/VTDirect/MandiriClickpayGateway.php
new file mode 100644
index 0000000..413508b
--- /dev/null
+++ b/src/VTDirect/MandiriClickpayGateway.php
@@ -0,0 +1,57 @@
+ '',
+ 'environment' => 'production',
+ );
+ }
+
+ public function setServerKey($key)
+ {
+ $this->setParameter('serverKey', $key);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function authorize(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\MandiriClickpay\TransactionChargeRequest',
+ $parameters
+ );
+ }
+
+ public function purchase(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\MandiriClickpay\TransactionChargeRequest',
+ $parameters
+ );
+ }
+}
diff --git a/src/VTDirect/Message/AbstractRequest.php b/src/VTDirect/Message/AbstractRequest.php
new file mode 100644
index 0000000..3d506cf
--- /dev/null
+++ b/src/VTDirect/Message/AbstractRequest.php
@@ -0,0 +1,80 @@
+getParameter('environment');
+
+ if ($env === 'production') {
+ return self::BASE_URL_PRODUCTION;
+ } else {
+ return self::BASE_URL_SANDBOX;
+ }
+ }
+
+ public function getHttpMethod()
+ {
+ return 'POST';
+ }
+
+ public function setServerKey($value)
+ {
+ $this->setParameter('serverKey', $value);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function sendData($data)
+ {
+ // don't throw exceptions for 4xx errors
+ $this->httpClient->getEventDispatcher()->addListener(
+ 'request.error',
+ function ($event) {
+ if ($event['response']->isClientError()) {
+ $event->stopPropagation();
+ }
+ }
+ );
+
+ $httpRequest = $this->httpClient->createRequest(
+ $this->getHttpMethod(),
+ $this->getEndpoint(),
+ null,
+ $data
+ );
+
+ $httpResponse = $httpRequest
+ ->setHeader('Authorization', 'Basic '.base64_encode($this->getServerKey().':'))
+ ->setHeader('Content-Type', 'application/json')
+ ->setHeader('Accept', 'application/json')
+ ->send();
+
+ return $this->response = $this->createResponse($httpResponse->json());
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/Message/BRIEpay/Response.php b/src/VTDirect/Message/BRIEpay/Response.php
new file mode 100644
index 0000000..8ecb166
--- /dev/null
+++ b/src/VTDirect/Message/BRIEpay/Response.php
@@ -0,0 +1,44 @@
+getCode(), array('200'));
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return !empty($this->data['redirect_url']);
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return $this->data['redirect_url'];
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/BRIEpay/TransactionChargeRequest.php b/src/VTDirect/Message/BRIEpay/TransactionChargeRequest.php
new file mode 100644
index 0000000..ca96016
--- /dev/null
+++ b/src/VTDirect/Message/BRIEpay/TransactionChargeRequest.php
@@ -0,0 +1,63 @@
+getAmountInteger();
+
+ // this is a workaround because IDR is not supported by default
+ // we need to divide by 100 to get normal amount.
+ if ($this->getCurrency() === 'IDR') {
+ $amountInteger /= 100;
+ }
+
+ $data = array(
+ 'payment_type' => 'bri_epay',
+ 'transaction_details' => array(
+ 'order_id' => $this->getTransactionId(),
+ 'gross_amount' => $amountInteger,
+ ),
+ 'customer_details' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'email' => $this->getCard()->getEmail(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'billing_address' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'address' => $this->getCard()->getBillingAddress1(),
+ 'city' => $this->getCard()->getBillingCity(),
+ 'postal_code' => $this->getCard()->getBillingPostcode(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'country_code' => $this->getCard()->getBillingCountry(),
+ ),
+ 'shipping_address' => array(
+ 'address' => $this->getCard()->getShippingAddress1(),
+ 'city' => $this->getCard()->getShippingCity(),
+ 'postal_code' => $this->getCard()->getShippingPostcode(),
+ 'phone' => $this->getCard()->getShippingPhone(),
+ 'country_code' => $this->getCard()->getShippingCountry(),
+ ),
+ ),
+ );
+
+ $dataStr = json_encode($data);
+
+ return $dataStr;
+ }
+
+ public function getEndpoint()
+ {
+ return $this->getBaseUrl().'/charge';
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/Message/CimbClicks/Response.php b/src/VTDirect/Message/CimbClicks/Response.php
new file mode 100644
index 0000000..eb5587c
--- /dev/null
+++ b/src/VTDirect/Message/CimbClicks/Response.php
@@ -0,0 +1,44 @@
+getCode(), array('200'));
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return !empty($this->data['redirect_url']);
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return $this->data['redirect_url'];
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/CimbClicks/TransactionChargeRequest.php b/src/VTDirect/Message/CimbClicks/TransactionChargeRequest.php
new file mode 100644
index 0000000..07e228a
--- /dev/null
+++ b/src/VTDirect/Message/CimbClicks/TransactionChargeRequest.php
@@ -0,0 +1,74 @@
+setParameter('cimb_clicks', $value);
+ }
+
+ public function getCimbClicks()
+ {
+ return $this->getParameter('cimb_clicks');
+ }
+
+ public function getData()
+ {
+ $amountInteger = $this->getAmountInteger();
+
+ // this is a workaround because IDR is not supported by default
+ // we need to divide by 100 to get normal amount.
+ if ($this->getCurrency() === 'IDR') {
+ $amountInteger /= 100;
+ }
+
+ $data = array(
+ 'payment_type' => 'cimb_clicks',
+ 'cimb_clicks' => $this->getCimbClicks(),
+ 'transaction_details' => array(
+ 'order_id' => $this->getTransactionId(),
+ 'gross_amount' => $amountInteger,
+ ),
+ 'customer_details' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'email' => $this->getCard()->getEmail(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'billing_address' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'address' => $this->getCard()->getBillingAddress1(),
+ 'city' => $this->getCard()->getBillingCity(),
+ 'postal_code' => $this->getCard()->getBillingPostcode(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'country_code' => $this->getCard()->getBillingCountry(),
+ ),
+ 'shipping_address' => array(
+ 'address' => $this->getCard()->getShippingAddress1(),
+ 'city' => $this->getCard()->getShippingCity(),
+ 'postal_code' => $this->getCard()->getShippingPostcode(),
+ 'phone' => $this->getCard()->getShippingPhone(),
+ 'country_code' => $this->getCard()->getShippingCountry(),
+ ),
+ ),
+ );
+
+ $dataStr = json_encode($data);
+
+ return $dataStr;
+ }
+
+ public function getEndpoint()
+ {
+ return $this->getBaseUrl().'/charge';
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/Message/MandiriClickpay/Response.php b/src/VTDirect/Message/MandiriClickpay/Response.php
new file mode 100644
index 0000000..e6553c2
--- /dev/null
+++ b/src/VTDirect/Message/MandiriClickpay/Response.php
@@ -0,0 +1,44 @@
+data['transaction_status'] == 'settlement';
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return false;
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return null;
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/MandiriClickpay/TransactionChargeRequest.php b/src/VTDirect/Message/MandiriClickpay/TransactionChargeRequest.php
new file mode 100644
index 0000000..55f71f9
--- /dev/null
+++ b/src/VTDirect/Message/MandiriClickpay/TransactionChargeRequest.php
@@ -0,0 +1,74 @@
+setParameter('mandiri_clickpay', $value);
+ }
+
+ public function getMandiriClickpay()
+ {
+ return $this->getParameter('mandiri_clickpay');
+ }
+
+ public function getData()
+ {
+ $amountInteger = $this->getAmountInteger();
+
+ // this is a workaround because IDR is not supported by default
+ // we need to divide by 100 to get normal amount.
+ if ($this->getCurrency() === 'IDR') {
+ $amountInteger /= 100;
+ }
+
+ $data = array(
+ 'payment_type' => 'mandiri_clickpay',
+ 'mandiri_clickpay' => $this->getMandiriClickpay(),
+ 'transaction_details' => array(
+ 'order_id' => $this->getTransactionId(),
+ 'gross_amount' => $amountInteger,
+ ),
+ 'customer_details' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'email' => $this->getCard()->getEmail(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'billing_address' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'address' => $this->getCard()->getBillingAddress1(),
+ 'city' => $this->getCard()->getBillingCity(),
+ 'postal_code' => $this->getCard()->getBillingPostcode(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'country_code' => $this->getCard()->getBillingCountry(),
+ ),
+ 'shipping_address' => array(
+ 'address' => $this->getCard()->getShippingAddress1(),
+ 'city' => $this->getCard()->getShippingCity(),
+ 'postal_code' => $this->getCard()->getShippingPostcode(),
+ 'phone' => $this->getCard()->getShippingPhone(),
+ 'country_code' => $this->getCard()->getShippingCountry(),
+ ),
+ ),
+ );
+
+ $dataStr = json_encode($data);
+
+ return $dataStr;
+ }
+
+ public function getEndpoint()
+ {
+ return $this->getBaseUrl().'/charge';
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/Message/Response.php b/src/VTDirect/Message/Response.php
new file mode 100644
index 0000000..3d38c6b
--- /dev/null
+++ b/src/VTDirect/Message/Response.php
@@ -0,0 +1,44 @@
+getCode(), array('200'));
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return !empty($this->data['redirect_url']);
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return $this->data['redirect_url'] ?: null;
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/TCash/Response.php b/src/VTDirect/Message/TCash/Response.php
new file mode 100644
index 0000000..01b5008
--- /dev/null
+++ b/src/VTDirect/Message/TCash/Response.php
@@ -0,0 +1,44 @@
+data['transaction_status'] == 'settlement';
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return false;
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return null;
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/TCash/TransactionChargeRequest.php b/src/VTDirect/Message/TCash/TransactionChargeRequest.php
new file mode 100644
index 0000000..996d4cc
--- /dev/null
+++ b/src/VTDirect/Message/TCash/TransactionChargeRequest.php
@@ -0,0 +1,74 @@
+setParameter('telkomsel_cash', $value);
+ }
+
+ public function getTelkomselCash()
+ {
+ return $this->getParameter('telkomsel_cash');
+ }
+
+ public function getData()
+ {
+ $amountInteger = $this->getAmountInteger();
+
+ // this is a workaround because IDR is not supported by default
+ // we need to divide by 100 to get normal amount.
+ if ($this->getCurrency() === 'IDR') {
+ $amountInteger /= 100;
+ }
+
+ $data = array(
+ 'payment_type' => 'telkomsel_cash',
+ 'telkomsel_cash' => $this->getTelkomselCash(),
+ 'transaction_details' => array(
+ 'order_id' => $this->getTransactionId(),
+ 'gross_amount' => $amountInteger,
+ ),
+ 'customer_details' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'email' => $this->getCard()->getEmail(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'billing_address' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'address' => $this->getCard()->getBillingAddress1(),
+ 'city' => $this->getCard()->getBillingCity(),
+ 'postal_code' => $this->getCard()->getBillingPostcode(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'country_code' => $this->getCard()->getBillingCountry(),
+ ),
+ 'shipping_address' => array(
+ 'address' => $this->getCard()->getShippingAddress1(),
+ 'city' => $this->getCard()->getShippingCity(),
+ 'postal_code' => $this->getCard()->getShippingPostcode(),
+ 'phone' => $this->getCard()->getShippingPhone(),
+ 'country_code' => $this->getCard()->getShippingCountry(),
+ ),
+ ),
+ );
+
+ $dataStr = json_encode($data);
+
+ return $dataStr;
+ }
+
+ public function getEndpoint()
+ {
+ return $this->getBaseUrl().'/charge';
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/Message/XLTunai/Response.php b/src/VTDirect/Message/XLTunai/Response.php
new file mode 100644
index 0000000..f7bef07
--- /dev/null
+++ b/src/VTDirect/Message/XLTunai/Response.php
@@ -0,0 +1,44 @@
+data['status_code'] == '201';
+ }
+
+ public function getCode()
+ {
+ return $this->data['status_code'];
+ }
+
+ public function getMessage()
+ {
+ return $this->data['status_message'];
+ }
+
+ public function isRedirect()
+ {
+ return false;
+ }
+
+ public function getRedirectMethod()
+ {
+ return 'GET';
+ }
+
+ public function getRedirectUrl()
+ {
+ return null;
+ }
+
+ public function getRedirectData()
+ {
+ return array();
+ }
+}
diff --git a/src/VTDirect/Message/XLTunai/TransactionChargeRequest.php b/src/VTDirect/Message/XLTunai/TransactionChargeRequest.php
new file mode 100644
index 0000000..4043f5c
--- /dev/null
+++ b/src/VTDirect/Message/XLTunai/TransactionChargeRequest.php
@@ -0,0 +1,63 @@
+getAmountInteger();
+
+ // this is a workaround because IDR is not supported by default
+ // we need to divide by 100 to get normal amount.
+ if ($this->getCurrency() === 'IDR') {
+ $amountInteger /= 100;
+ }
+
+ $data = array(
+ 'payment_type' => 'xl_tunai',
+ 'transaction_details' => array(
+ 'order_id' => $this->getTransactionId(),
+ 'gross_amount' => $amountInteger,
+ ),
+ 'customer_details' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'email' => $this->getCard()->getEmail(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'billing_address' => array(
+ 'first_name' => $this->getCard()->getFirstName(),
+ 'last_name' => $this->getCard()->getLastName(),
+ 'address' => $this->getCard()->getBillingAddress1(),
+ 'city' => $this->getCard()->getBillingCity(),
+ 'postal_code' => $this->getCard()->getBillingPostcode(),
+ 'phone' => $this->getCard()->getBillingPhone(),
+ 'country_code' => $this->getCard()->getBillingCountry(),
+ ),
+ 'shipping_address' => array(
+ 'address' => $this->getCard()->getShippingAddress1(),
+ 'city' => $this->getCard()->getShippingCity(),
+ 'postal_code' => $this->getCard()->getShippingPostcode(),
+ 'phone' => $this->getCard()->getShippingPhone(),
+ 'country_code' => $this->getCard()->getShippingCountry(),
+ ),
+ ),
+ );
+
+ $dataStr = json_encode($data);
+
+ return $dataStr;
+ }
+
+ public function getEndpoint()
+ {
+ return $this->getBaseUrl().'/charge';
+ }
+
+ public function createResponse($data)
+ {
+ return new Response($this, $data);
+ }
+}
diff --git a/src/VTDirect/TCashGateway.php b/src/VTDirect/TCashGateway.php
new file mode 100644
index 0000000..08f0af3
--- /dev/null
+++ b/src/VTDirect/TCashGateway.php
@@ -0,0 +1,57 @@
+ '',
+ 'environment' => 'production',
+ );
+ }
+
+ public function setServerKey($key)
+ {
+ $this->setParameter('serverKey', $key);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function authorize(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\TCash\TransactionChargeRequest',
+ $parameters
+ );
+ }
+
+ public function purchase(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\TCash\TransactionChargeRequest',
+ $parameters
+ );
+ }
+}
diff --git a/src/VTDirect/XLTunaiGateway.php b/src/VTDirect/XLTunaiGateway.php
new file mode 100644
index 0000000..069c426
--- /dev/null
+++ b/src/VTDirect/XLTunaiGateway.php
@@ -0,0 +1,57 @@
+ '',
+ 'environment' => 'production',
+ );
+ }
+
+ public function setServerKey($key)
+ {
+ $this->setParameter('serverKey', $key);
+ }
+
+ public function getServerKey()
+ {
+ return $this->getParameter('serverKey');
+ }
+
+ public function setEnvironment($env)
+ {
+ $this->setParameter('environment', $env);
+ }
+
+ public function getEnvironment()
+ {
+ return $this->getParameter('environment');
+ }
+
+ public function authorize(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\XLTunai\TransactionChargeRequest',
+ $parameters
+ );
+ }
+
+ public function purchase(array $parameters = array())
+ {
+ return $this->createRequest(
+ '\Omnipay\Veritrans\VTDirect\Message\XLTunai\TransactionChargeRequest',
+ $parameters
+ );
+ }
+}