Skip to content

Commit

Permalink
Add further optional parameters; inloine/iframe support.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Apr 8, 2018
1 parent 8a84f97 commit 07daab7
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 17 deletions.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,28 @@ there will be no expiry date. Just the previously saved `cardReference` is passe
in. The `cardReference` is a generic term used for a number of card and non-card
payment methods.

## Redirect Mode

This is the standard mode for authorizing a payment, where the user will be taken
to a remove payment form and returned when they have finished.

The redirect can be either a `POST` or a `GET` redirect, defaulting to `POST`.
The `setRedirectmethod()` parameter takes either "GET" or "POST" to set the
redirection mode.

## iframe Mode (aka Inline Mode)

By putting the redirect mode into GET `mode`, the URL for the iframe becomes the
redirect URL: `$response->getRedirectUrl()`

The iframe content is put into a simplified theme by setting `$request->setInline(true)`

```php
$response = $gateway->purchase(['inline' => true, 'redirectMethod' => 'GET', ...]);

echo '<iframe width="600" height="500" frameborder="0" border="0" src="'.$response->getRedirectUrl().'" />';
```

## Hidden Mode

This mode requires credit card details to be passed through your merchant application.
Expand All @@ -290,17 +312,6 @@ It is not supported by this release of the driver drue to the PCI requirements i

### Shared Optional Parameters

* Merchant Specific Parameters
* customTheme
* mfaReference
* refno2
* Refno3
* virtualCardno
* uppStartTarget
* uppReturnTarget
* uppTermsLink An external link to the merchant’s terms and conditions
* uppDiscountAmount
* mode
* Customer name and address details (this varies across payment methods)
* Basket details

Expand Down
108 changes: 107 additions & 1 deletion src/Message/AbstractRedirectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,21 @@ public function getData()
$data['expy'] = $card->getExpiryDate('y');
$data['aliasCC'] = $card->getNumber();
}

// Hidden mode has PCI requirements when used, since the merchant
// site will be handling the CVV entered by the user.
// Better not to use it. But it's here for more complete support.

if ($this->getHiddenMode()) {
if ($card->getCvv()) {
$data['hiddenMode'] = 'yes';
$data['cvv'] = $card->getCvv();
}
}
}

// The card reference be provided without a card object and without
// an expiry date.

if ($this->getCardReference()) {
$data['aliasCC'] = $this->getCardReference();
}
Expand All @@ -85,6 +95,50 @@ public function getData()
$data['language'] = $this->getLanguage();
}

if ($this->getTermsLink()) {
$data['uppTermsLink'] = $this->getTermsLink();
}

if ($this->getStartTarget()) {
$data['uppStartTarget'] = $this->getStartTarget();
}

if ($this->getReturnTarget()) {
$data['uppReturnTarget'] = $this->getReturnTarget();
}

if ($this->getCustomTheme()) {
$data['customTheme'] = $this->getCustomTheme();
}

if ($this->getForceRedirect()) {
$data['mode'] = 'forceRedirect';
}

// When using PayPal, always ask for a copy of the address entered.
// This will work for PayPal Express only.

if ($this->getPaymentMethod() === Gateway::PAYMENT_METHOD_PAP) {
$data['uppCustomerDetails'] = 'return';
}

if ($this->getInline()) {
$data['theme'] = 'Inline';
}

// The Discount Amount is in minor units.
// A Money\Money object would be better for Omnipay 3.x

if ($this->getDiscountAmount() !== null) {
$data['uppDiscountAmount'] = $this->getDiscountAmount();
}

// An array of custom parameters can be included.

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

if ($this->requestType) {
$data['reqtype'] = $this->requestType;
}
Expand Down Expand Up @@ -124,6 +178,18 @@ public function getData()
// Swiss PostFinance Card
$data = $this->extraParamsPFC($data);
break;
case Gateway::PAYMENT_METHOD_MFA:
// MFGroup Check Out (Credit Check)
$data = $this->extraParamsMFA($data);
break;
case Gateway::PAYMENT_METHOD_ELV:
// SEPA Direct Debit / ELV
$data = $this->extraParamsELV($data);
break;
case Gateway::PAYMENT_METHOD_MFG:
// MFGroup Financial Request (authorization)
$data = $this->extraParamsMFG($data);
break;
}

// These URLs are optional here, if set in the account.
Expand Down Expand Up @@ -167,6 +233,46 @@ protected function extraParamsPFC(array $data)
return $data;
}

/**
* Additional parameters for MFGroup Check Out (Credit Check) (MFA)/
*/
protected function extraParamsMFA(array $data)
{
if ($this->getMfaReference()) {
$data['mfaReference'] = $this->getMfaReference();
}

return $data;
}

/**
* Additional parameters for SEPA Direct Debit / ELV (ELV)/
*/
protected function extraParamsELV(array $data)
{
if ($this->getRefno2()) {
$data['refno2'] = $this->getRefno2();
}

if ($this->getRefno3()) {
$data['refno3'] = $this->getRefno3();
}

return $data;
}

/**
* Additional parameters for MFGroup Financial Request (authorization) (MFG)/
*/
protected function extraParamsMFG(array $data)
{
if ($this->getVirtualCardno()) {
$data['virtualCardno'] = $this->getVirtualCardno();
}

return $data;
}

/**
* @return ResponseInterface
*/
Expand Down
6 changes: 1 addition & 5 deletions src/Message/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ public function getRedirectMethod()
*/
public function getRedirectData()
{
if ($this->getRedirectMethod() === 'POST') {
return array_diff_key($this->getData(), ['redirectMethod' => null]);
} else {
return [];
}
return array_diff_key($this->getData(), ['redirectMethod' => null]);
}

/**
Expand Down
Loading

0 comments on commit 07daab7

Please sign in to comment.