Created
November 15, 2020 11:30
-
-
Save ksmylmz/f36bb3081fd07a1a3560c796bce2a26f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class PaymentController { | |
| public function pay() | |
| { | |
| //sepet verilerini session'dan alalim | |
| $basket = $_SESSION["basket"]; | |
| //kullanici bilgileri | |
| $customer = $_SESSION["customer"]; | |
| $toplam = 0; | |
| ///sepeti toplayalim | |
| foreach ($basket["products"] as $urun) { | |
| $toplam += $urun['price']; | |
| } | |
| //kullanilan kartin bilgileri | |
| $CredidCardInfo = $_POST["CredidCardInfo"]; | |
| //Ödeme işlemini yapacak servisine istekte bulunuyoruz. | |
| $paymentResult = API::post("stripe", [ | |
| "credit_card" => $CredidCardInfo, | |
| "customer" => $customer, | |
| "price" => $toplam | |
| ]); | |
| if ($paymentResult["success"]) | |
| { | |
| //bilgiler doğrılandı, 3D ödeme için doğrulama servisine yönlendir. | |
| return redirect($paymentResult["redirect_url"]); | |
| } else { | |
| // Başarısız doğrulama hata mesajı döndür. | |
| throw new Exception("Payment Failure"." - ". $paymentResult["error_message"]); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment