Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Coinbase Commerce Magento: transfer to a new repo
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim-s committed Jun 15, 2018
1 parent 323f69b commit f1d3e5c
Show file tree
Hide file tree
Showing 40 changed files with 2,036 additions and 1 deletion.
59 changes: 59 additions & 0 deletions Api/CoinbaseRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Coinbase Commerce
*/
namespace CoinbaseCommerce\PaymentGateway\Api;

/**
* Coinbase Commerce repository interface.
*/
interface CoinbaseRepositoryInterface
{
/**
* Lists orders that match specified search criteria.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria The search criteria.
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseSearchResultInterface Order search result interface.
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);

/**
* Loads a specified order.
*
* @param int $id The order ID.
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface Order interface.
*/
public function get($id);

/**
* Loads a specified order.
*
* @param string $incrementId Increment id of order in store.
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface Order interface.
*/
public function getByIncrementId($incrementId);

/**
* Loads a specified order.
*
* @param string $chargeCode Charge code of coinbase order.
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface Order interface.
*/
public function getByChargeCode($chargeCode);

/**
* Deletes a specified order.
*
* @param \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface $entity The order ID.
* @return bool
*/
public function delete(\CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface $entity);

/**
* Performs persist operations for a specified order.
*
* @param \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface $entity The order ID.
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface Order interface.
*/
public function save(\CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface $entity);
}
133 changes: 133 additions & 0 deletions Api/Data/CoinbaseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?php

namespace CoinbaseCommerce\PaymentGateway\Api\Data;

interface CoinbaseInterface
{
/**
* Constants for keys of data array. Identical to the name of the getter in snake case
*/
const ID = 'id';
const STORE_ORDER_ID = 'store_order_id';
const COINBASE_CHARGE_CODE = 'coinbase_charge_code';
const TRANSACTION_ID = 'transaction_id';
const COINBASE_STATUS = 'coinbase_status';
const COINS_RECEIVED = 'coins_received';
const COINS_EXPECTED = 'coins_expected';
const RECEIVED_CURRENCY = 'received_currency';
const TOTAL_PAID = 'total_paid';
/**
* @return int
*/
public function getId();

/**
* @param int $id
* @return void
*/
public function setId($id);

/**
* Gets the magento store increment ID for the order.
*
* @return string|null Increment ID.
*/
public function getStoreOrderId();

/**
* @param string $incrementId
* @return void
*/
public function setStoreOrderId($incrementId);

/**
* Gets charge code provided by coinbase.
*
* @return string|null Increment ID.
*/
public function getCoinbaseChargeCode();

/**
* @param string $code
* @return void
*/
public function setCoinbaseChargeCode($code);

/**
* Gets the transaction id of coinbase payment.
*
* @return string|null Transaction Id.
*/
public function getTransactionId();

/**
* @param string $id
* @return void
*/
public function setTransactionId($id);

/**
* Gets status of coinbase payment.
*
* @return string|null Status.
*/
public function getCoinbaseStatus();

/**
* @param string $status
* @return void
*/
public function setCoinbaseStatus($status);

/**
* Gets the amount of coins received.
*
* @return float|null Amount received.
*/
public function getCoinsReceived();

/**
* @param float $amount
* @return void
*/
public function setCoinsReceived($amount);

/**
* Gets the amount of coins expected from customer.
*
* @return float|null Amount received.
*/
public function getCoinsExpected();

/**
* @param float $amount
* @return void
*/
public function setCoinsExpected($amount);

/**
* Gets currency in which coins are received.
*
* @return string|null Currency.
*/
public function getReceivedCurrency();

/**
* @param string $currency
* @return void
*/
public function setReceivedCurrency($currency);

/**
* Gets the amount of money paid, converted from coins.
*
* @return float|null Amount received.
*/
public function getTotalPaid();

/**
* @param float $amount
* @return void
*/
public function setTotalPaid($amount);
}
19 changes: 19 additions & 0 deletions Api/Data/CoinbaseSearchResultInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace CoinbaseCommerce\PaymentGateway\Api\Data;

use Magento\Framework\Api\SearchResultsInterface;

interface CoinbaseSearchResultInterface extends SearchResultsInterface
{
/**
* @return \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface[]
*/
public function getItems();

/**
* @param \CoinbaseCommerce\PaymentGateway\Api\Data\CoinbaseInterface[] $items
* @return void
*/
public function setItems(array $items);
}
56 changes: 56 additions & 0 deletions Block/Adminhtml/Order/View/Details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Coinbase Commerce
*/

namespace CoinbaseCommerce\PaymentGateway\Block\Adminhtml\Order\View;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Api\OrderRepositoryInterface;
use CoinbaseCommerce\PaymentGateway\Api\CoinbaseRepositoryInterface;

class Details extends Template
{
private $orderRepository;
private $coinbaseRepository;

public function __construct(
Context $context,
OrderRepositoryInterface $orderRepository,
CoinbaseRepositoryInterface $coinbaseRepository
) {
parent::__construct($context);
$this->orderRepository = $orderRepository;
$this->coinbaseRepository = $coinbaseRepository;
}

private function getOrder()
{
$order = $this->orderRepository->get($this->getRequest()->getParam('order_id'));
return $order;
}

private function getCoinbaseRecord()
{
return $this->coinbaseRepository->getByIncrementId($this->getOrder()->getIncrementId());
}

public function isPaymentMadeInCoinbase()
{
return $this->getOrder()->getPayment()->getMethod() == 'coinbasemethod';
}

public function getCoinsDetail()
{
$record = $this->getCoinbaseRecord();
$data['expectedCoins'] = $record->getCoinsExpected() . ' ' . $record->getReceivedCurrency();
$data['amount'] = $record->getCoinsReceived() . ' ' . $record->getReceivedCurrency();
$data['status'] = $record->getCoinbaseStatus();
$data['code'] = $record->getCoinbaseChargeCode();
$data['transactionId'] = $record->getTransactionId();
$data['totalPaid'] = $record->getTotalPaid();
$data['orderPlacedCurrency'] = $this->getOrder()->getOrderCurrencyCode();
return $data;
}
}
18 changes: 18 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/Disable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Coinbase Commerce
*/

namespace CoinbaseCommerce\PaymentGateway\Block\Adminhtml\System\Config\Form\Field;

use Magento\Framework\Data\Form\Element\AbstractElement;

class Disable extends \Magento\Config\Block\System\Config\Form\Field
{

protected function _getElementHtml(AbstractElement $element)
{
$element->setData('readonly', 1);
return $element->getElementHtml();
}
}
Loading

0 comments on commit f1d3e5c

Please sign in to comment.