Example #1
0
 public function testStartFullOk()
 {
     \Paynl\Config::setApiToken('123456789012345678901234567890');
     \Paynl\Config::setServiceId('SL-1234-5678');
     $result = $this->startTransactionFull();
     $this->validateStartResult($result);
 }
 public function initSettings()
 {
     $storeId = $this->getStore();
     $apitoken = $this->_scopeConfig->getValue('payment/paynl/apitoken', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     $serviceId = $this->_scopeConfig->getValue('payment/paynl/serviceid', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     \Paynl\Config::setApitoken($apitoken);
     \Paynl\Config::setServiceId($serviceId);
 }
Example #3
0
 public function testRefundAdd()
 {
     $this->setDummyData('refund');
     \Paynl\Config::setApiToken('123456789012345678901234567890');
     \Paynl\Config::setServiceId('SL-1234-5678');
     $result = $this->refundAddFull();
     $this->assertInstanceOf('\\Paynl\\Result\\Refund\\Add', $result);
     $this->assertStringStartsWith('RF-', $result->getRefundId());
 }
Example #4
0
 /**
  * Configures the sdk with the API token and serviceId
  *
  * @return bool TRUE when config loaded, FALSE when the apitoken or serviceId are empty
  */
 public function configureSDK()
 {
     $apiToken = $this->getApiToken();
     $serviceId = $this->getServiceId();
     if (!empty($apiToken) && !empty($serviceId)) {
         \Paynl\Config::setApiToken($apiToken);
         \Paynl\Config::setServiceId($serviceId);
         return true;
     }
     return false;
 }
Example #5
0
 public function testRequireServiceIdException()
 {
     $this->setExpectedException('\\Paynl\\Error\\Required\\ServiceId');
     \Paynl\Config::setServiceId('');
     \Paynl\Helper::requireServiceId();
 }
Example #6
0
File: config.php Project: paynl/sdk
<?php

\Paynl\Config::setApiToken('bf81d83f6f8ca32bca272dfdcaf2f14902ff41');
\Paynl\Config::setServiceId('SL-3490-4320');
//optional: you can download it on https://curl.haxx.se/ca/cacert.pem
//\Paynl\Config::setCAInfoLocation('path/to/cacert.pem');
Example #7
0
<?php

require_once '../vendor/autoload.php';
require_once 'config.php';
// don't forget to set the serviceId
// This is your service, where the transaction will be added to
\Paynl\Config::setServiceId('SL-1234-1234');
try {
    $result = Paynl\Alliance\Invoice::add(array('merchantId' => 'M-1234-1234', 'invoiceId' => 'INV012345', 'amount' => 25.75, 'description' => 'Test invoice', 'invoiceUrl' => 'http://url.to.the/invoice.pdf', 'makeYesterday' => true));
    echo $result->referenceId();
} catch (\Exception $e) {
    echo "Error occurred: " . $e->getMessage();
}
Example #8
0
 public function testServiceId()
 {
     \Paynl\Config::setServiceId('my-service-id');
     $this->assertEquals('my-service-id', \Paynl\Config::getServiceId());
 }
Example #9
0
 public function execute()
 {
     try {
         /** @var \Magento\Checkout\Model\Type\Onepage $onepage */
         $onepage = $this->_objectManager->get('Magento\\Checkout\\Model\\Type\\Onepage');
         /** @var \Magento\Quote\Model\Quote $quote */
         $quote = $onepage->getQuote();
         $quote->collectTotals();
         $quote->reserveOrderId();
         $orderId = $quote->getReservedOrderId();
         $payment = $quote->getPayment()->getMethodInstance();
         $total = $quote->getGrandTotal();
         $items = $quote->getAllVisibleItems();
         $currency = $quote->getQuoteCurrencyCode();
         $returnUrl = $this->_url->getUrl('paynl/finish/');
         $exchangeUrl = $this->_url->getUrl('paynl/exchange/');
         $paymentOptionId = $payment->getPaymentOptionId();
         $arrBillingAddress = $quote->getBillingAddress()->toArray();
         $arrShippingAddress = $quote->getShippingAddress()->toArray();
         $enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
         $address = array();
         $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
         $address['streetName'] = $arrAddress[0];
         $address['houseNumber'] = $arrAddress[1];
         $address['zipCode'] = $arrBillingAddress['postcode'];
         $address['city'] = $arrBillingAddress['city'];
         $address['country'] = $arrBillingAddress['country_id'];
         $shippingAddress = array();
         $arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
         $shippingAddress['streetName'] = $arrAddress2[0];
         $shippingAddress['houseNumber'] = $arrAddress2[1];
         $shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
         $shippingAddress['city'] = $arrShippingAddress['city'];
         $shippingAddress['country'] = $arrShippingAddress['country_id'];
         $data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra1' => $quote->getId(), 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
         $data['address'] = $address;
         $data['shippingAddress'] = $shippingAddress;
         $data['enduser'] = $enduser;
         $arrProducts = array();
         foreach ($items as $item) {
             $arrItem = $item->toArray();
             if ($arrItem['price_incl_tax'] != null) {
                 $product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty'], 'tax' => $arrItem['tax_amount']);
             }
             $arrProducts[] = $product;
         }
         //shipping
         $shippingCost = $quote->getShippingAddress()->getShippingInclTax();
         $shippingTax = $quote->getShippingAddress()->getShippingTaxAmount();
         $shippingDescription = $quote->getShippingAddress()->getShippingDescription();
         $arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
         // kortingen
         $discount = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
         if ($discount > 0) {
             $arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
         }
         $data['products'] = $arrProducts;
         if ($this->_config->isTestMode()) {
             $data['testmode'] = 1;
         }
         $data['ipaddress'] = $quote->getRemoteIp();
         \Paynl\Config::setApiToken($this->_config->getApiToken());
         \Paynl\Config::setServiceId($this->_config->getServiceId());
         $transaction = \Paynl\Transaction::start($data);
         $onepage->saveOrder();
         $this->_redirect($transaction->getRedirectUrl());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong, please try again later'));
         $this->_redirect('checkout/cart');
     }
 }
Example #10
0
 public function testGetBanksInvalidPaymentMethod()
 {
     $this->setDummyData();
     \Paynl\Config::setServiceId('SL-1234-5678');
     \Paynl\Config::setApiToken('123456789012345678901234567890');
     $banks = \Paynl\Paymentmethods::getBanks(12345);
     //Non existent paymentmethod
     $this->assertInternalType('array', $banks);
     foreach ($banks as $bank) {
         $this->assertArrayHasKey('id', $bank);
         $this->assertArrayHasKey('name', $bank);
         $this->assertArrayHasKey('visibleName', $bank);
     }
 }