Skip to content

Commit

Permalink
Merge pull request #17 from academe/pr15
Browse files Browse the repository at this point in the history
Pr15plus
  • Loading branch information
judgej authored Dec 7, 2016
2 parents db8e24e + c71e69c commit 05507df
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 2 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,35 @@ The sequence number starts at 1 for the first capture, and must be incremented f
subsequent capture. It should be taken from the [Notification Callback](#notification-callback),
see below.

For invoicing module some additional parameters have to be provided:

```php
$lines[] = new \Omnipay\Payone\Extend\Item([
'id' => '{merchant-site-stock-ID}',
'name' => '{product-name}',
'itemType' => 'goods', // Available types: goods, shipping etc.
'quantity' => 2,
'price' => 123,
'vat' => 20, // Optional
]);

$items = new ItemBag($lines);
```

And in capture request:

```php
'items' => $items,
'sequenceNumber' => 1,
'settleAccount' => false,
'invoiceid' => 1,
'invoiceDeliveryMode' => 'P', // PDF, for others look into documentation
'invoiceDeliveryDate' => date('Ymd'),
'invoiceAppendix' => 'This is your invoice appendix'
```
Note that the email field in card details has to be passed to authorize method in pre-authorization step since it's
the email that will be used by Payone to send invoice to customer.

### Server API Void

To void an authorized payment:
Expand Down
92 changes: 91 additions & 1 deletion src/Message/ShopServerCaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ class ShopServerCaptureRequest extends ShopServerAuthorizeRequest
const SETTLE_ACCOUNT_NO = 'no';
const SETTLE_ACCOUNT_AUTO = 'auto';

/**
* Values for the invoiceDeliveryMode parameter.
*/
const INVOICE_DELIVERY_MODE_POST = 'M'; // aka Mail
const INVOICE_DELIVERY_MODE_PDF = 'P'; // via email
const INVOICE_DELIVERY_MODE_NONE = 'N'; // no delivery

/**
* The "request" parameter.
*/
Expand Down Expand Up @@ -48,12 +55,36 @@ public function getData()
$data['settleaccount'] = $this->getSettleAccount();
}

if ($this->getDataItems()) {
$data = array_merge($data, $this->getDataItems());
}

if ($this->getMerchantInvoiceId()) {
$data['invoiceid'] = $this->getMerchantInvoiceId();
}

if ($this->getInvoiceDeliveryMode()) {
$data['invoice_deliverymode'] = $this->getInvoiceDeliveryMode();
}

if ($this->getInvoiceDeliveryDate()) {
$data['invoice_deliverydate'] = $this->getInvoiceDeliveryDate();
}

if ($this->getInvoiceDeliveryEndDate()) {
$data['invoice_deliveryenddate'] = $this->getInvoiceDeliveryEndDate();
}

if ($this->getInvoiceAppendix()) {
$data['invoiceappendix'] = $this->getInvoiceAppendix();
}

return $data;
}

protected function createResponse($data)
{
return $this->response = new ShopCaptureResponse($this, $data);
return $this->response = new ShopServerCaptureResponse($this, $data);
}

/**
Expand Down Expand Up @@ -103,4 +134,63 @@ public function getSettleAccount()
{
return $this->getParameter('settleAccount');
}

public function setMerchantInvoiceId($invoiceId)
{
return $this->setParameter('merchantInvoiceId', $invoiceId);
}

public function getMerchantInvoiceId()
{
return $this->getParameter('merchantInvoiceId');
}

/**
* See static::INVOICE_DELIVERY_MODE_*
*/
public function setInvoiceDeliveryMode($deliveryMode)
{
return $this->setParameter('invoiceDeliveryMode', $deliveryMode);
}

public function getInvoiceDeliveryMode()
{
return $this->getParameter('invoiceDeliveryMode');
}

/**
* @param string $deliveryDate Format YYYYMMDD
*/
public function setInvoiceDeliveryDate($deliveryDate)
{
return $this->setParameter('invoiceDeliveryDate', $deliveryDate);
}

public function getInvoiceDeliveryDate()
{
return $this->getParameter('invoiceDeliveryDate');
}

/**
* @param string $deliveryEndDate Format YYYYMMDD
*/
public function setInvoiceDeliveryEndDate($deliveryEndDate)
{
return $this->setParameter('invoiceDeliveryEndDate', $deliveryEndDate);
}

public function getInvoiceDeliveryEndDate()
{
return $this->getParameter('invoiceDeliveryEndDate');
}

public function setInvoiceAppendix($invoiceAppendix)
{
return $this->setParameter('invoiceAppendix', $invoiceAppendix);
}

public function getInvoiceAppendix()
{
return $this->getParameter('invoiceAppendix');
}
}
2 changes: 1 addition & 1 deletion src/Message/ShopServerVoidRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ShopServerVoidRequest extends ShopServerCaptureRequest
{
public function getData()
{
// Settling the account while taking noting will void the authorization.
// Settling the account while taking nothing will void the authorization.
$this->setAmount(0.00);
$this->setSettleAccount(true);

Expand Down

0 comments on commit 05507df

Please sign in to comment.