| @@ 44-67 (lines=24) @@ | ||
| 41 | * @param InvoiceInterface $invoice |
|
| 42 | * @return RedirectPurchaseResponse |
|
| 43 | */ |
|
| 44 | public function requestPurchase(InvoiceInterface $invoice) |
|
| 45 | { |
|
| 46 | /** |
|
| 47 | * @var \Omnipay\BitPay\Message\PurchaseResponse |
|
| 48 | */ |
|
| 49 | $response = $this->gateway->purchase([ |
|
| 50 | 'transactionId' => $invoice->getId(), |
|
| 51 | 'description' => $invoice->getDescription(), |
|
| 52 | 'amount' => $this->moneyFormatter->format($invoice->getAmount()), |
|
| 53 | 'currency' => $invoice->getCurrency()->getCode(), |
|
| 54 | 'returnUrl' => $invoice->getReturnUrl(), |
|
| 55 | 'notifyUrl' => $invoice->getNotifyUrl(), |
|
| 56 | 'cancelUrl' => $invoice->getCancelUrl(), |
|
| 57 | ])->send(); |
|
| 58 | ||
| 59 | if ($response->getRedirectUrl() === null) { |
|
| 60 | throw new MerchantException('Failed to request purchase'); |
|
| 61 | } |
|
| 62 | ||
| 63 | $response = new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData()); |
|
| 64 | $response->setMethod('GET'); |
|
| 65 | ||
| 66 | return $response; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @param array $data |
|
| @@ 34-57 (lines=24) @@ | ||
| 31 | * @param InvoiceInterface $invoice |
|
| 32 | * @return RedirectPurchaseResponse |
|
| 33 | */ |
|
| 34 | public function requestPurchase(InvoiceInterface $invoice) |
|
| 35 | { |
|
| 36 | /** |
|
| 37 | * @var \Omnipay\CoinGate\Message\PurchaseResponse $response |
|
| 38 | */ |
|
| 39 | $response = $this->gateway->purchase([ |
|
| 40 | 'transactionId' => $invoice->getId(), |
|
| 41 | 'currency' => $invoice->getCurrency()->getCode(), |
|
| 42 | 'description' => $invoice->getDescription(), |
|
| 43 | 'amount' => $this->moneyFormatter->format($invoice->getAmount()), |
|
| 44 | 'returnUrl' => $invoice->getReturnUrl(), |
|
| 45 | 'cancelUrl' => $invoice->getCancelUrl(), |
|
| 46 | 'notifyUrl' => $invoice->getNotifyUrl(), |
|
| 47 | ])->send(); |
|
| 48 | ||
| 49 | if ($response->getRedirectUrl() === null) { |
|
| 50 | throw new MerchantException('Failed to request purchase'); |
|
| 51 | } |
|
| 52 | ||
| 53 | $response = new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData()); |
|
| 54 | $response->setMethod('GET'); |
|
| 55 | ||
| 56 | return $response; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @param array $data |
|