alttantire / ptt-payment-sdk
PTT智能商户PHP支付SDK
v2.1.0
2022-10-13 15:57 UTC
Requires
README
安装
$ composer require alttantire/ptt-payment-sdk
为了使用PHP类进行集成,您可以访问PTT智能商户PHP支付类仓库。
使用
您可以使用以下方法进行API调用。
3D交易启动
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam $callback_url = "https://www.orneksitesadresiniz.com/payment-response.php"; //### Sipariş Bilgileri $orderId = ""; // Sipariş numarası her sipariş için tekil olmalıdır. Boş bırakıldığında sistem tarafından otomatik üretilir $amount = 1090; // 10 TL 90 kuruş $instalment = 0; // Taksit sayısı - Tek çekim için 0 //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); try { $payment = $gateway->threeDPayment($callback_url, $amount, $instalment, $orderId); } catch (Exception $e) { print_r($e); } $three_d_session_id = $payment->ThreeDSessionId; $form_post_url = $gateway->getFormUrl();
3D支付完成
使用在3D交易启动步骤中创建的ThreeDSessionId值进行表单POST。
<form role="form" method="post" action="https://payment.testdgpf.dgpaysit.com/api/Payment/ProcessCardForm"> <input type="hidden" name="ThreeDSessionId" value="XXXXXXXX"> <input type="text" name="CardHolderName" placeholder="İsim Soyisim" required/> <input type="text" name="CardNo" placeholder="Kredi Kart Numarası" required autofocus/> <input type="text" name="ExpireDate" placeholder="AA/YY" required/> <input type="text" name="Cvv" placeholder="CVV" required/> <button type="submit">3D ile Ödemeyi Tamamla</button> </form>
联合支付(iframe)
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam $callback_url = "https://www.orneksitesadresiniz.com/payment-response.php"; //### Sipariş Bilgileri $orderId = ""; // Sipariş numarası her sipariş için tekil olmalıdır. Boş bırakıldığında sistem tarafından otomatik üretilir $amount = 1090; // 10 TL 90 kuruş $instalment = 0; // Taksit sayısı - Tek çekim için 0 //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); try { $payment = $gateway->startPaymentThreeDSession($callback_url, $amount, $instalment, $orderId); } catch (Exception $e) { print_r($e); } $iframe_url = $gateway->getFrameUrl($payment->ThreeDSessionId);
<iframe src="<?php echo $iframe_url ?>" style=" width:100%; height: 550px;position: relative;" frameborder="0" allowfullscreen></iframe>
支付查询
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam $callback_url = "https://www.orneksitesadresiniz.com/payment-response.php"; //### Sipariş Bilgileri $orderId = "20221011999"; // Sipariş numarası //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); $paymentCheck = $gateway->inquiry($orderId); echo "<pre>"; print_r($paymentCheck);
交易列表
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); /* * Sipariş numarası dolu gönderildiğinde o siparişe ait tüm işlemleri listeler. * Sipariş numarası boş gönderildiğinde o tarihteki tüm siparişleri listeler */ $orderId = "20221011999"; /* * Sipariş tarihi integer olmalıdır. * Listesi istenen tarih YYYYAAGG formatında yazılmalıdır. */ $date = 20221011; try { $paymentCheck = $gateway->history($date, $orderId, $page = 1, $pageSize = 10); } catch (Exception $e) { print_r($e); } echo "<pre>"; print_r($paymentCheck);
取消
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam //### Sipariş Bilgileri $orderId = "20221011999"; // Sipariş numarası //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); $paymentCheck = $gateway->void($orderId); print_r($paymentCheck);
退款
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam //### Sipariş Bilgileri $orderId = "202210109"; // Sipariş numarası $amount=125; // İade edilecek tutar. 1 TL 25 Kuruş //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); $paymentCheck = $gateway->refund($orderId, $amount); print_r($paymentCheck);
3D预授权
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); //### Sipariş Bilgileri $amount=24990; // 249 TL 90 Kuruş $installment=0; // Tek çekim $orderId=""; // Sipariş numarası - Boş gönderildiğinde sistem tarafından otomatik üretilir $description=""; // Opsiyonel sipariş açıklaması $callback_url = "https://www.orneksitesadresiniz.com/payment-response.php"; try { $preAuth = $gateway->threeDPreAuth($callbackUrl, $amount, $installment, $orderId, $description); $ThreeDSessionId = $preAuth->ThreeDSessionId; print_r($preAuth); } catch (Exception $e) { print_r($e); }
3D后授权
<?php use AkilliEsnaf\Gateway; include "vendor/autoload.php"; //### Sanal POS Üye İşyeri Ayarları $apiUser = "Entegrasyon_01"; // Api kullanıcı adınız $clientId = "1000000032"; // Api müşteri numaranız $apiPass = "gkk4l2*TY112"; // Api şifreniz $environment = "TEST"; // "LIVE" - Gerçek ortam | "TEST" - Test ortam //### API Gateway $gateway = new Gateway($environment, $clientId, $apiUser, $apiPass); //### Sipariş Bilgileri $amount=14990; // Otorizasyondan tahsil edilcek tutar. 149 TL 90 Kuruş $orderId=""; // Sipariş numarası try { $postAuth = $gateway->threeDPostAuth( $orderId, $amount ); print_r($postAuth); } catch (Exception $e) { print_r($e); }