Skip to content

Commit ecf58c7

Browse files
Add method to createCard (token) for Rapid transparent redirect gateway
1 parent a038da1 commit ecf58c7

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* eWAY Rapid Shared Page Create Card Request
4+
*/
5+
6+
namespace Omnipay\Eway\Message;
7+
8+
/**
9+
* eWAY Rapid Shared Page Create Card Request
10+
*
11+
* Creates a payment URL using eWAY's Responsive Shared Page
12+
*
13+
* @link https://eway.io/api-v3/#responsive-shared-page
14+
*/
15+
class RapidCreateCardRequest extends RapidPurchaseRequest
16+
{
17+
protected $action;
18+
19+
/**
20+
* @return string|NULL
21+
*/
22+
public function getAction()
23+
{
24+
return $this->action;
25+
}
26+
27+
/**
28+
* @param string $action
29+
*/
30+
public function setAction($action)
31+
{
32+
$this->action = $action;
33+
}
34+
35+
public function getData()
36+
{
37+
$this->validate('returnUrl');
38+
39+
$data = $this->getBaseData();
40+
41+
$data['TransactionType'] = 'Purchase';
42+
$data['RedirectUrl'] = $this->getReturnUrl();
43+
44+
// Shared page parameters (optional)
45+
$data['CancelUrl'] = $this->getCancelUrl();
46+
47+
$data['Payment'] = array();
48+
49+
if ($this->getAction() === 'Purchase') {
50+
$data['Payment']['TotalAmount'] = (int) $this->getAmountInteger();
51+
$data['Payment']['InvoiceNumber'] = $this->getTransactionId();
52+
$data['Payment']['InvoiceDescription'] = $this->getDescription();
53+
$data['Payment']['CurrencyCode'] = $this->getCurrency();
54+
$data['Payment']['InvoiceReference'] = $this->getInvoiceReference();
55+
$data['Method'] = 'TokenPayment';
56+
} else {
57+
$data['Method'] = 'CreateTokenCustomer';
58+
$data['Payment']['TotalAmount'] = 0;
59+
}
60+
61+
return $data;
62+
}
63+
}

src/RapidGateway.php

+5
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@ public function refund(array $parameters = array())
7676
{
7777
return $this->createRequest('\Omnipay\Eway\Message\RefundRequest', $parameters);
7878
}
79+
80+
public function createCard(array $parameters = array())
81+
{
82+
return $this->createRequest('\Omnipay\Eway\Message\RapidCreateCardRequest', $parameters);
83+
}
7984
}

0 commit comments

Comments
 (0)