my-fatoorah /
omnipay-myfatoorah
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * MyFatoorah Gateway |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace Omnipay\Myfatoorah; |
||
| 8 | |||
| 9 | use Omnipay\Common\AbstractGateway; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * MyFatoorah Gateway. |
||
| 13 | * |
||
| 14 | * Example: |
||
| 15 | * |
||
| 16 | * <code> |
||
| 17 | |||
| 18 | // Create a gateway for the MyFatoorah Gateway |
||
| 19 | $gateway = Omnipay::create('Myfatoorah'); |
||
| 20 | $gateway->setApiKey('rLtt6JWvbUHDDhsZnfpAhpYk4dxYDQkbcPTyGaKp2TYqQgG7FGZ5Th_WD53Oq8Ebz6A53njUoo1w3pjU1D4vs_ZMqFiz_j0urb_BH9Oq9VZoKFoJEDAbRZepGcQanImyYrry7Kt6MnMdgfG5jn4HngWoRdKduNNyP4kzcp3mRv7x00ahkm9LAK7ZRieg7k1PDAnBIOG3EyVSJ5kK4WLMvYr7sCwHbHcu4A5WwelxYK0GMJy37bNAarSJDFQsJ2ZvJjvMDmfWwDVFEVe_5tOomfVNt6bOg9mexbGjMrnHBnKnZR1vQbBtQieDlQepzTZMuQrSuKn-t5XZM7V6fCW7oP-uXGX-sMOajeX65JOf6XVpk29DP6ro8WTAflCDANC193yof8-f5_EYY-3hXhJj7RBXmizDpneEQDSaSz5sFk0sV5qPcARJ9zGG73vuGFyenjPPmtDtXtpx35A-BVcOSBYVIWe9kndG3nclfefjKEuZ3m4jL9Gg1h2JBvmXSMYiZtp9MR5I6pvbvylU_PP5xJFSjVTIz7IQSjcVGO41npnwIxRXNRxFOdIUHn0tjQ-7LwvEcTXyPsHXcMD8WtgBh-wxR8aKX7WPSsT1O8d8reb2aR7K3rkV3K82K_0OgawImEpwSvp9MNKynEAJQS6ZHe_J_l77652xwPNxMRTMASk1ZsJL'); |
||
| 21 | $gateway->setTestMode('true');// true in case of test token and empty '' in case of live token! |
||
| 22 | // Create Invoice URL |
||
| 23 | /*$data = array(); |
||
| 24 | $data['Amount'] = '50'; |
||
| 25 | $data['OrderRef'] = '5342652460'; |
||
| 26 | $data['Currency'] = 'KWD'; |
||
| 27 | $data['returnUrl'] = 'http://localomnipay.com/myfatoorah.php'; |
||
| 28 | $data['Card']['firstName'] = 'fname'; |
||
| 29 | $data['Card']['lastName'] = 'lname'; |
||
| 30 | $data['Card']['email'] = '[email protected]'; |
||
| 31 | // |
||
| 32 | // Do a purchase transaction on the gateway |
||
| 33 | $transaction = $gateway->purchase($data)->send(); |
||
| 34 | if ($transaction->isSuccessful()) { |
||
| 35 | $invoiceId = $transaction->getTransactionReference(); |
||
| 36 | echo "Invoice Id = " . $invoiceId . "<br>"; |
||
| 37 | $redirectUrl = $transaction->getRedirectUrl(); |
||
| 38 | echo "Redirect Url = <a href='$redirectUrl' target='_blank'>" . $redirectUrl . "</a><br>"; |
||
| 39 | } else { |
||
| 40 | echo $transaction->getMessage(); |
||
| 41 | } */ |
||
| 42 | // In the callback, Get Payment status for specific Payment ID |
||
| 43 | /* $callBackData = ['paymentId' => '100202113817903101']; |
||
| 44 | $callback = $gateway->completePurchase($callBackData)->send(); |
||
| 45 | if ($callback->isSuccessful()) { |
||
| 46 | echo "<pre>"; |
||
| 47 | print_r($callback->getPaymentStatus('5342652460', '100202113817903101')); |
||
| 48 | } else { |
||
| 49 | echo $callback->getMessage(); |
||
| 50 | } */ |
||
| 51 | |||
| 52 | // Refund specific Payment ID |
||
| 53 | /* $refundData = ['paymentId' => '100202113817903101', 'Amount'=>1]; |
||
| 54 | $refund = $gateway->refund($refundData)->send(); |
||
| 55 | if ($refund->isSuccessful()) { |
||
| 56 | echo "<pre>"; |
||
| 57 | print_r($refund->getRefundInfo()); |
||
| 58 | } else { |
||
| 59 | echo $refund->getMessage(); |
||
| 60 | } */ |
||
| 61 | /* |
||
| 62 | * |
||
| 63 | * </code> |
||
| 64 | * |
||
| 65 | * @link https://developer.myfatoorah.com |
||
| 66 | */ |
||
| 67 | class Gateway extends AbstractGateway { |
||
| 68 | |||
| 69 | public function getName() { |
||
| 70 | return 'Myfatoorah'; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Get default parameters for this gateway |
||
| 75 | * |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | public function getDefaultParameters() { |
||
| 79 | return [ |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 80 | 'apiKey' => '', |
||
| 81 | 'testMode' => false |
||
| 82 | ]; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Get the gateway apiKey key |
||
| 87 | * |
||
| 88 | * @return string |
||
| 89 | */ |
||
| 90 | public function getApiKey() { |
||
| 91 | return $this->getParameter('apiKey'); |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Set the gateway apiKey key |
||
| 96 | * |
||
| 97 | * @param string $value |
||
| 98 | * @return Gateway provides a fluent interface. |
||
| 99 | */ |
||
| 100 | public function setApiKey($value) { |
||
| 101 | return $this->setParameter('apiKey', $value); |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Get the gateway Test mode |
||
| 106 | * |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | public function getTestMode() { |
||
| 110 | return $this->getParameter('testMode'); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Set the gateway Test mode |
||
| 115 | * |
||
| 116 | * @param string $value |
||
| 117 | * @return Gateway provides a fluent interface. |
||
| 118 | */ |
||
| 119 | public function setTestMode($value) { |
||
| 120 | return $this->setParameter('testMode', $value); |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * completeAuthorize Request |
||
| 125 | * |
||
| 126 | * |
||
| 127 | * @param array|array $parameters |
||
| 128 | * @return \Omnipay\Myfatoorah\Message\Response |
||
| 129 | */ |
||
| 130 | public function purchase(array $parameters = array()) { |
||
| 131 | return $this->createRequest('\Omnipay\Myfatoorah\Message\CompleteAuthorizeRequest', $parameters); |
||
|
0 ignored issues
–
show
|
|||
| 132 | } |
||
| 133 | |||
| 134 | /** |
||
| 135 | * completePurchase Request |
||
| 136 | * |
||
| 137 | * |
||
| 138 | * @param array|array $parameters |
||
| 139 | * @return \Omnipay\Myfatoorah\Message\Response |
||
| 140 | */ |
||
| 141 | public function completePurchase(array $parameters = array()) { |
||
| 142 | return $this->createRequest('\Omnipay\Myfatoorah\Message\CompletePurchase', $parameters); |
||
|
0 ignored issues
–
show
|
|||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * refund Request |
||
| 147 | * |
||
| 148 | * |
||
| 149 | * @param array|array $parameters |
||
| 150 | * @return \Omnipay\Myfatoorah\Message\Response |
||
| 151 | */ |
||
| 152 | public function refund(array $parameters = array()) { |
||
| 153 | return $this->createRequest('\Omnipay\Myfatoorah\Message\RefundRequest', $parameters); |
||
|
0 ignored issues
–
show
|
|||
| 154 | } |
||
| 155 | |||
| 156 | } |
||
| 157 |