Merhabalar, üzerinde uğraştığım bir sitem var burada bakiye yüklemek için weepay.co'yu kullanacağım ve iframe ile olsun istiyorum iframi açtırıp her ödeme almaya kadar her şeyi sorunsuz hallediyorum ama sonucun ne olduğunu iframe içinde yazdıramıyorum. Konu hakkında bilgili olanlar yardımcı olursa çok sevinirim.
bakiyenin yüklendiği profil sayfası
işlemin yapıldığı process/addbalance.php
callback in yapıldığı ana dizindeki test.php
ilgili sayfalar bunlar fakat dediğim gibi sms kodu girildikten sonra iframe bembeyaz kalıyor
bakiyenin yüklendiği profil sayfası
PHP:
<div class="tab-pane fade" id="nav-addBalance" role="tabpanel"
aria-labelledby="nav-addBalance-tab">
<div class="profile__address">
<div class="row">
<div class="col-md-6" id="current-balance" style="display: block;">
<h4>Mevcut Bakiye</h4>
<p class="text-success">$100</p>
</div>
<div class="col-md-6" id="balance-form" style="display: block;">
<h4>Bakiye Yükle</h4>
<div class="form-group">
<label for="amount">Yüklenecek Bakiye Miktarı (TL):</label>
<input type="number" id="amount" name="amount" class="form-control mb-2"
required>
</div>
<button type="button" class="btn btn-primary btn-block"
id="load-balance">Devam Et</button>
</div>
</div>
</div>
<div id="payment-iframe-container" style="display: none;">
<iframe src="" id="payment-iframe" frameborder="0"
style="width: 100%; height: 500px;"></iframe>
</div>
<script>
document.getElementById('load-balance').addEventListener('click', function() {
document.getElementById('current-balance').style.display = 'none';
document.getElementById('balance-form').style.display = 'none';
$.ajax({
url: 'process/addbalance.php',
method: 'POST',
data: {
amount: $('#amount').val()
}, // Yükleme miktarını gönder
dataType: 'json',
success: function(response) {
if (response.status === "success") {
alert(response
.message);
var iframe = document.getElementById(
'payment-iframe');
iframe.src = response
.paymentPageUrl;
document.getElementById('payment-iframe-container')
.style.display = 'block';
} else {
toastr.error(response.message);
}
},
error: function() {
alert('Bir hata oluştu. Lütfen tekrar deneyin.');
}
});
});
</script>
</div>
işlemin yapıldığı process/addbalance.php
PHP:
<?php
// Bakiye miktarını alma
$amount = isset($_POST['amount']) ? $_POST['amount'] : null;
if ($amount === null || $amount <= 0) {
// Boş veri veya 0 miktarı hatalı, bir hata yanıtı gönder
$response = array(
"status" => "error",
"message" => "Geçersiz bakiye miktarı. Lütfen geçerli bir miktar girin."
);
echo json_encode($response);
} else {
require_once '../libs/vendor/autoload.php';
require_once('../libs/vendor/weepay/weepay-php/weepayBootstrap.php');
$options = new \weepay\Auth();
$options->setBayiID(""); // weepay tarafından verilen bayiId
$options->setApiKey(""); // weepay tarafından verilen apiKey
$options->setSecretKey(""); // weepay tarafından verilen secretKey
$options->setBaseUrl("https://api.weepay.co");
//Request
$request = new \weepay\Request\FormInitializeRequest();
$request->setOrderId('11');
$request->setIpAddress('192.168.2.1');
$request->setPrice('0.10');
$request->setCurrency(\weepay\Model\Currency::TL);
$request->setLocale(\weepay\Model\Locale::TR);
$request->setDescription('Açıklama Alanı');
$request->setCallBackUrl('http://localhost/beverlyecommerce/test.php');
$request->setPaymentGroup(\weepay\Model\PaymentGroup::PRODUCT);
$request->setPaymentChannel(\weepay\Model\PaymentChannel::WEB);
//Customer
$customer = new \weepay\Model\Customer();
$customer->setCustomerId(1235); // Üye işyeri müşteri Id
$customer->setCustomerName("isim"); //Üye işyeri müşteri ismi
$customer->setCustomerSurname("soyisim"); //Üye işyeri müşteri Soyisim
$customer->setGsmNumber("50XXXXXX"); //Üye işyeri müşteri Cep Tel
$customer->setEmail("[email protected]"); //Üye işyeri müşteri ismi
$customer->setIdentityNumber("00032222721"); //Üye işyeri müşteri TC numarası
$customer->setCity("istanbul"); //Üye işyeri müşteri il
$customer->setCountry("turkey"); //Üye işyeri müşteri ülke
$request->setCustomer($customer);
//Adresler
// Fatura Adresi
$BillingAddress = new \weepay\Model\Address();
$BillingAddress->setContactName("isim soyisim");
$BillingAddress->setAddress("Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27");
$BillingAddress->setCity("istanbul");
$BillingAddress->setCountry("turkey");
$BillingAddress->setZipCode("34164");
$request->setBillingAddress($BillingAddress);
//Kargo / Teslimat Adresi
$ShippingAddress = new \weepay\Model\Address();
$ShippingAddress->setContactName("isim soyisim");
$ShippingAddress->setAddress("Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27");
$ShippingAddress->setCity("istanbul");
$ShippingAddress->setCountry("turkey");
$ShippingAddress->setZipCode("34164");
$request->setShippingAddress($ShippingAddress);
// Sipariş Ürünleri
$Products = array();
// Birinci Ürün
$firstProducts = new \weepay\Model\Product();
$firstProducts->setName("Ürün Bir");
$firstProducts->setProductId(12344);
$firstProducts->setProductPrice(0.10);
$firstProducts->setItemType(\weepay\Model\ProductType::PHYSICAL);
$Products[0] = $firstProducts;
// İkinci Ürün
$secondProducts = new \weepay\Model\Product();
$secondProducts->setName("Ürün İki");
$secondProducts->setProductId("C550A100");
$secondProducts->setProductPrice(0.10);
$secondProducts->setItemType(\weepay\Model\ProductType::PHYSICAL);
$Products[1] = $secondProducts;
// Üçüncü Ürün
$thirdProducts = new \weepay\Model\Product();
$thirdProducts->setName("Ürün Üç");
$thirdProducts->setProductId("1000");
$thirdProducts->setProductPrice("0.10");
$thirdProducts->setItemType(\weepay\Model\ProductType::PHYSICAL);
$Products[2] = $thirdProducts;
$request->setProducts($Products);
$checkoutFormInitialize = \weepay\Model\CheckoutFormInitialize::create($request, $options);
if ($checkoutFormInitialize->getStatus() == 'success') {
$response = array(
"status" => "success",
"message" => "Ödeme başarıyla tamamlandı.",
"paymentStatus" => true, // Ödeme başarılı olduğunu belirtmek için ekledik
"paymentPageUrl" => $checkoutFormInitialize->getPaymentPageUrl() // Ödeme sayfasının URL'sini ekledik
);
echo json_encode($response);
} else {
$response = array(
"status" => "error",
"message" => "Bakiye yükleme sırasında bir hata oluştu.",
"paymentStatus" => false // Ödeme başarısız olduğunu belirtmek için ekledik
);
echo json_encode($response);
}
}
?>
callback in yapıldığı ana dizindeki test.php
PHP:
<?php
require_once 'libs/vendor/weepay/weepay-php/samples/Options.php';
$orderid = $_POST['paymentId'];
// Request
$request = new \weepay\Request\GetPaymentRequest();
$request->setOrderId("11");
$request->setPaymentId("5942687");
$request->setLocale(\weepay\Model\Locale::TR);
$getPaymentRequest = \weepay\Model\GetPaymentRequestInitialize::create($request, Options::Auth());
if ($getPaymentRequest->getStatus() == 'success') {
if ($getPaymentRequest->getPaymentStatus() == 'SUCCESS') {
// Ödeme başarılı ise basari.php sayfasına yönlendir
header("Location: basari.php");
exit();
} else if ($getPaymentRequest->getPaymentStatus() == 'FAILURE') {
// Ödeme başarısız ise basarisiz.php sayfasına yönlendir
header("Location: basarisiz.php");
exit();
}
} else {
// Ödeme sonucu alınamadı ise hata mesajı göster
echo "Ödeme sonucu alınamadı.";
}
?>
ilgili sayfalar bunlar fakat dediğim gibi sms kodu girildikten sonra iframe bembeyaz kalıyor