Skip to content

Instantly share code, notes, and snippets.

@ksmylmz
Created November 15, 2020 11:30
Show Gist options
  • Select an option

  • Save ksmylmz/f36bb3081fd07a1a3560c796bce2a26f to your computer and use it in GitHub Desktop.

Select an option

Save ksmylmz/f36bb3081fd07a1a3560c796bce2a26f to your computer and use it in GitHub Desktop.
<?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