|
5 | 5 |
|
6 | 6 | namespace Omnipay\Eway\Message; |
7 | 7 |
|
| 8 | +use Omnipay\Eway\RapidDirectGateway; |
| 9 | +use Omnipay\Omnipay; |
| 10 | + |
8 | 11 | /** |
9 | 12 | * eWAY Rapid Direct Create Card Request |
10 | 13 | * |
@@ -78,6 +81,25 @@ public function sendData($data) |
78 | 81 | ->setAuth($this->getApiKey(), $this->getPassword()) |
79 | 82 | ->send(); |
80 | 83 |
|
81 | | - return $this->response = new RapidDirectCreateCardResponse($this, $httpResponse->json()); |
| 84 | + $this->response = new RapidDirectCreateCardResponse($this, $httpResponse->json()); |
| 85 | + |
| 86 | + if ($this->getAction() === 'Purchase' && $this->response->isSuccessful()) { |
| 87 | + /** @var RapidDirectGateway $purchaseGateway */ |
| 88 | + $purchaseGateway = Omnipay::create('Eway_RapidDirect'); |
| 89 | + $purchaseGateway->setApiKey($this->getApiKey()); |
| 90 | + $purchaseGateway->setPassword($this->getPassword()); |
| 91 | + $purchaseGateway->setTestMode($this->getTestMode()); |
| 92 | + $purchaseResponse = $purchaseGateway->purchase(array( |
| 93 | + 'amount' => $this->getAmount(), |
| 94 | + 'currency' => $this->getCurrency(), |
| 95 | + 'description' => $this->getDescription(), |
| 96 | + 'transactionId' => $this->getTransactionId(), |
| 97 | + 'card' => $this->getCard(), |
| 98 | + 'cardReference' => $this->response->getCardReference(), |
| 99 | + ))->send(); |
| 100 | + $this->response->setPurchaseResponse($purchaseResponse); |
| 101 | + } |
| 102 | + |
| 103 | + return $this->response; |
82 | 104 | } |
83 | 105 | } |
0 commit comments