| @@ 12-46 (lines=35) @@ | ||
| 9 | /** |
|
| 10 | * @method Response send() |
|
| 11 | */ |
|
| 12 | class AuthorizeRequest extends AbstractRequest |
|
| 13 | {
|
|
| 14 | use HasGateway, HasPaymentMethodData, HasGatewaySpecificFields; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @return array |
|
| 18 | * @throws \Omnipay\Common\Exception\InvalidCreditCardException |
|
| 19 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
|
| 20 | * @throws \Omnipay\Spreedly\Exception\InvalidPaymentMethodException |
|
| 21 | */ |
|
| 22 | public function getData() |
|
| 23 | {
|
|
| 24 | $this->validate('amount', 'currency');
|
|
| 25 | ||
| 26 | $data = $this->validateAndGetPaymentMethodData(); |
|
| 27 | ||
| 28 | $data = $this->fillGatewaySpecificFields($data); |
|
| 29 | ||
| 30 | $data = $this->fillExistingParameters($data, [ |
|
| 31 | 'amount' => 'amount_integer', |
|
| 32 | 'currency_code' => 'currency', |
|
| 33 | ]); |
|
| 34 | ||
| 35 | return ['transaction' => $data]; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return string |
|
| 40 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
|
| 41 | */ |
|
| 42 | public function getEndpoint() |
|
| 43 | {
|
|
| 44 | return $this->getGatewayEndpoint() . 'authorize'; |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 12-46 (lines=35) @@ | ||
| 9 | /** |
|
| 10 | * @method Response send() |
|
| 11 | */ |
|
| 12 | class PurchaseRequest extends AbstractRequest |
|
| 13 | {
|
|
| 14 | use HasGateway, HasPaymentMethodData, HasGatewaySpecificFields; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @return array |
|
| 18 | * @throws \Omnipay\Common\Exception\InvalidCreditCardException |
|
| 19 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
|
| 20 | * @throws \Omnipay\Spreedly\Exception\InvalidPaymentMethodException |
|
| 21 | */ |
|
| 22 | public function getData() |
|
| 23 | {
|
|
| 24 | $this->validate('amount', 'currency');
|
|
| 25 | ||
| 26 | $data = $this->validateAndGetPaymentMethodData(); |
|
| 27 | ||
| 28 | $data = $this->fillGatewaySpecificFields($data); |
|
| 29 | ||
| 30 | $data = $this->fillExistingParameters($data, [ |
|
| 31 | 'amount' => 'amount_integer', |
|
| 32 | 'currency_code' => 'currency', |
|
| 33 | ]); |
|
| 34 | ||
| 35 | return ['transaction' => $data]; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return string |
|
| 40 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
|
| 41 | */ |
|
| 42 | public function getEndpoint() |
|
| 43 | {
|
|
| 44 | return $this->getGatewayEndpoint() . 'purchase'; |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||