> For the complete documentation index, see [llms.txt](https://developer.weepay.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.weepay.co/api/odeme-formu-olusturma.md).

# Ödeme Formu Oluşturma

## Ödeme Formu Başlatma

* [API servisine gönderilmesi gereken parametreler](/api/odeme-formu-olusturma.md#oedeme-olusturma)
* [Örnek kodlar](/api/odeme-formu-olusturma.md#api-servisi-istek-oernek-kodlar)
* [API servisinden geri dönen parametreler](/api/odeme-formu-olusturma.md#api-servisinden-doenen-sonuc-oernekleri)
* [Ödeme servisi kullanım çeşitleri](/api/odeme-formu-olusturma.md#oedeme-servisi-kullanim-cesitleri)
* [3D dönüşündeki(CallBack) parametreleri](/api/odeme-formu-olusturma.md#3d-secure-callback-parametreleri)

## Ödeme Oluşturma

<mark style="color:green;">`POST`</mark> `https://api.weepay.co/Payment/PaymentCreate`

Ödeme servisi için gerekli parametreler.

#### Path Parameters

| Name      | Type    | Description                                                |
| --------- | ------- | ---------------------------------------------------------- |
| Auth      | array   | Auth array altında bayiId, apiKey ve secretKey gönderilir. |
| bayiId    | integer | weepay tarafından verilerin bayi id.                       |
| apiKey    | string  | weepay tarafından apiKey.                                  |
| secretKey | string  | weepay tarafından verilen secretKey                        |

#### Request Body

| Name            | Type   | Description                                                                                                                                      |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Data            | string | Data array altında gönderilecek parametreler                                                                                                     |
| orderId         | string | Üye iş yeri sipariş id.                                                                                                                          |
| ipAddress       | string | Alıcıya ait ip adresi.                                                                                                                           |
| locale          | string | Geri dönüş dili                                                                                                                                  |
| paidPrice       | number | Ödeme tutarı (Kuruş kısmı nokta ile yazılır. Örn: 35.50)                                                                                         |
| currency        | string | Para birimi TL, USD, EUR, GBP                                                                                                                    |
| callBackUrl     | string | İşlemin sonucunun dönüleceği URL adresiniz.                                                                                                      |
| description     | string | Sipariş açıklaması                                                                                                                               |
| Customer        | array  | Customer array altında gönderilecek parametreler                                                                                                 |
| customerId      | string | Üye işyeri tarafındaki alıcıya ait id.                                                                                                           |
| customerName    | string | Üye işyeri tarafındaki alıcıya ait isim bilgisi.                                                                                                 |
| customerSurname | string | Üye işyeri tarafındaki alıcıya ait soyisim bilgisi.                                                                                              |
| gsmNumber       | number | Üye işyeri tarafındaki alıcıya ait gsm bilgisi.                                                                                                  |
| email           | string | Üye işyeri tarafındaki alıcıya ait email bilgisi.                                                                                                |
| identityNumber  | number | Üye işyeri tarafındaki alıcıya ait TCKN.                                                                                                         |
| city            | string | Üye işyeri tarafındaki alıcıya ait şehir bilgisi.                                                                                                |
| country         | string | Üye işyeri tarafındaki alıcıya ait ülke bilgisi.                                                                                                 |
| BillingAddress  | string | BillingAddress array altında gönderilecek parametreler                                                                                           |
| contactName     | string | Üye işyeri tarafındaki fatura adresi ad soyad bilgisi.                                                                                           |
| address         | string | Üye işyeri tarafındaki fatura adresi adres bilgisi.                                                                                              |
| city            | string | Üye işyeri tarafındaki fatura adresi şehir bilgisi.                                                                                              |
| country         | string | Üye işyeri tarafındaki fatura adresi ülke bilgisi.                                                                                               |
| district        | string | Üye işyeri tarafındaki fatura adresi bölge bilgisi.                                                                                              |
| zipCode         | number | Üye işyeri tarafındaki fatura adresi posta kodu.                                                                                                 |
| ShippingAddress | string | SippingAddres array'i altında gönderilecek bilgiler                                                                                              |
| contactName     | string | Üye işyeri tarafındaki teslimat adresi, ad, soyad bilgisi. Sepetteki ürünlerden en az 1 tanesi fiziksel ürün (itemType=PHYSICAL) ise zorunludur. |
| address         | string | Üye işyeri tarafındaki teslimat adresi. Sepetteki ürünlerden en az 1 tanesi fiziksel ürün (itemType=PHYSICAL) ise zorunludur.                    |
| city            | string | Üye işyeri tarafındaki teslimat adresi şehir bilgisi. Sepetteki ürünlerden en az 1 tanesi fiziksel ürün (itemType=PHYSICAL) ise zorunludur.      |
| country         | string | Üye işyeri tarafındaki teslimat adresi ülke bilgisi. Sepetteki ürünlerden en az 1 tanesi fiziksel ürün (itemType=PHYSICAL) ise zorunludur.       |
| district        | number | Üye işyeri tarafındaki fatura adresi bölge bilgisi.                                                                                              |
| zipCode         | string | Üye işyeri tarafındaki teslimat adresi posta kodu.                                                                                               |
| Products        | string | Products array altında gönderilecek parametreler                                                                                                 |
| productId       | string | Üye işyeri tarafındaki ürüne ait id.                                                                                                             |
| name            | string | Üye işyeri tarafındaki ürüne ait isim bilgisi.                                                                                                   |
| productPrice    | number | Üye işyeri tarafındaki ürünlere ait tutar.tutarlar toplamı paidPrice alanına eşit olmalıdır.                                                     |
| itemType        | string | Üye işyeri tarafındaki ürüne ait tip. Geçerli enum değerler: **PHYSICAL** ve **VIRTUAL**.                                                        |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## API servisi istek örnek kodlar

{% tabs %}
{% tab title="Json" %}

```javascript
// Request JSON example;
{
"Auth": {
		"bayiId":"22",
		"apiKey": "XXXXXXXXX",
		"secretKey": "XXXXXXXXXXXXXXXX"
		},
"Data":{
 "orderId":1,
 "currency":"TL", 
 "locale":"tr",
 "paidPrice":"0.16", 
 "ipAddress":"192.168.1.1", 
 "installmentNumber":1, // Uygulanacak Taksit Sayısı
 "description":"Açıkalama", // Açıklama
 "callBackUrl":"http://Sitem.com/callBack"// Response URL
},
"Customer":{
	"customerId":"1", // alıcı müşteri Id 
	"customerName":"isim", //alıcı ismi 
	"customerSurname":"soyisim", // alıcı Soyismi
	"gsmNumber":"50XXXXXXX",// alıcı cep telefonu
	"email":"hello@weepay.co", // alıcı mail
	"identityNumber":"112312312313132", // alıcı TC kimlik numarası
	 "city":"istanbul",// alıcı  şehir
	 "country":"Turkey" // alıcı ülke
},
 "BillingAddress": {
		"contactName":"isim soyisim",
		"address":"Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
		"city":"istanbul",
		"country":"turkey",
		"zipCode":34164
},
 "ShippingAddress": {
		"contactName":"isim soyisim",
		"address":"Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
		"city":"istanbul",
		"country":"turkey",
		"zipCode":34164
},
 "Products":
   [
    {"productId":"B104A", "name":"ürün bir","productPrice":2.3, "itemType":"PHYSICAL"},
 	  {"productId":"C1087", "name":"ürün iki","productPrice":2.3, "itemType":"PHYSICAL" },
 		{"productId":"12233352", "name":"ürün üç","productPrice":2.3, "itemType":"PHYSICAL" }
   ]
}
```

{% endtab %}

{% tab title="PHP" %}

```php

// https://github.com/weepay/weepay-php  PHP lib.
// composer or weepay initialize Bootstrap
// Auth
$options = new \weepay\Auth();
$options->setBayiID("xxxxxx");// weepay tarafıdan verilen bayiId
$options->setApiKey("xxxx-xxxx-xxx");// weepay tarafıdan verilen apiKey
$options->setSecretKey("xxxxxxx-xxxxxxxxx-xx-xx"); // weepay tarafıdan 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('https://websitem.com/callback');
$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("helo@weepay.co"); //Ü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);

echo "<div id='weePay-checkout-form' class='popup'>";
print_r($checkoutFormInitialize);








```

{% endtab %}

{% tab title="Node" %}

```javascript
// https://github.com/weepay/weepay-nodejs node.js SDK.
// npm install weepay-nodejs or Add dependency 'weepay-nodejs' 
// in your package.json file
// check sdk in samples folder CreatePaymentForm.js samples 
// Node.js v12.0.0 or later

const  weepay = require('weepay-nodejs');

weepay.configure({
    bayiId: "bayiId",
    apiKey: "apiKey",
    secretKey: "secretKey",
    baseUrl: "https://test-api.weepay.co"
});

const request = {
    data: {
        orderId: 1,
        ipAddress: "192.168.2.1",
        paidPrice: 0.10,
        currency: Currency.TL,
        locale: Locale.TR,
        description: "Açıklama Alanı",
        callBackUrl: "https://websitem.com/callback",
        paymentGroup: PaymentGroup.PRODUCT,
        paymentChannel: PaymentChannel.WEB
    },
    customer: {
        customerId: 1234,
        customerName: "isim",
        customerSurname: "soyisim",
        gsmNumber: "50XXXXXX",
        email: "helo@weepay.co",
        identityNumber: "00032222721",
        city: "istanbul",
        country: "turkey"
    },
    billingAddress: {
        contactName: "isim soyisim",
        address: "Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
        city: "istanbul",
        country: "turkey",
        zipCode: "34164"
    },
    shippingAddress: {
        contactName: "isim soyisim",
        address: "Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
        city: "istanbul",
        country: "turkey",
        zipCode: "34164"
    },
    products: [
        {
            name: "first product",
            productPrice: "30.00",
            itemType: ProductType.PHYSICAL,
            productId: "1234"
        },
        {
            name: "first product",
            productPrice: "30.00",
            itemType: ProductType.PHYSICAL,
            productId: "1234"
        },
    ]
}

weepay.formInitialize(request).then(function (res) {
    if (res.status == "success") {
        console.log(res.CheckoutFormData);
    } else {
        console.log(res.message)
    }
});


```

{% endtab %}

{% tab title="Javascript" %}

```javascript
// check sample :  https://github.com/weepay/weepay-javascript/blob/main/samples/createpayment.html
// import weepay javascript library
var weepay = new weepayInit();

        weepay.configure({
            bayiId: "bayiId",
            apiKey: "apiKey",
            secretKey: "secretKey",
            baseUrl: "https://api.weepay.co"
        })

var request = {
            data: {
                orderId: 1,
                ipAddress: "192.168.2.1",
                paidPrice: 0.10,
                currency: Constants.Currency.TL,
                locale: Constants.Locale.TR,
                description: "Açıklama Alanı",
                cardHolderName: "isim soyisim",
                cardNumber: "555555555555555",
                expireMonth: "01",
                expireYear: "22",
                cvcNumber: "233",
                installmentNumber: 1,
                paymentGroup: Constants.PaymentGroup.PRODUCT,
                paymentChannel: Constants.PaymentChannel.WEB
            },
            customer: {
                customerId: 1234,
                customerName: "isim",
                customerSurname: "soyisim",
                gsmNumber: "50XXXXXX",
                email: "helo@weepay.co",
                identityNumber: "00032222721",
                city: "istanbul",
                country: "turkey"
            },
            billingAddress: {
                contactName: "isim soyisim",
                address: "Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
                city: "istanbul",
                country: "turkey",
                zipCode: "34164"
            },
            shippingAddress: {
                contactName: "isim soyisim",
                address: "Abdurrahman Nafiz Gürman,Mh, G. Ali Rıza Gürcan Cd. No:27",
                city: "istanbul",
                country: "turkey",
                zipCode: "34164"
            },
            products: [
                {
                    name: "first product",
                    productPrice: "30.00",
                    itemType: Constants.ProductType.PHYSICAL,
                    productId: "1234"
                },
                {
                    name: "first product",
                    productPrice: "30.00",
                    itemType: Constants.ProductType.PHYSICAL,
                    productId: "1234"
                },
            ]
        }

weepay.createPayment(request, function (response) {
            if (response.status == "failure") {
                console.log(response.message);
            } else {
                console.log(response)
            }
        });
```

{% endtab %}

{% tab title="Java" %}

```java
// https://github.com/weepay/weepay-java java SDK.
// if you use maven, if not check github page others installation
//<dependency>
// <groupId>co.weepay</groupId>
// <artifactId>weepay-java</artifactId>
// <version>1.0.0</version>
//</dependency>
// check sdk in samples folder CreatePaymentForm.txt samples 
// java  1.7 or later

    //Auth
    Auth options = new Auth();

    options.setBayiId(bayiId);
    options.setApiKey("apiKey");
    options.setSecretKey("secretKey");
    options.setBaseUrl("https://api.weepay.co");

    // Request
    FormInitializeRequest request = new FormInitializeRequest();
    request.setOptions(options);
    request.setOrderId("1");
    request.setIpAddress("192.168.1.2");
    request.setPrice(35.50);
    request.setCurrency(Currency.TL.name());
    request.setLocale(Locale.TR.getValue());
    request.setDescription("Açıklama Alanı");
    request.setCallBackUrl("https://websitem.com/callback");
    request.setInstallmentNumber(1);
    request.setPaymentGroup(PaymentGroup.PRODUCT.name());
    request.setPaymentChannel(PaymentChannel.WEB.name());

    // Customer
    Customer customer = new Customer();
    customer.setCustomerId(1);
    customer.setCustomerName("isim");
    customer.setCustomerSurname("soyisim");
    customer.setGsmNumber("50XXXXXX");
    customer.setEmail("hello@weepay.co");
    customer.setIdentityNumber("00032222721");
    customer.setCity("istanbul");
    customer.setCountry("turkey");
    request.setCustomer(customer);

    // Address
    // Billing Address
    Address billingAddress = new Address();
    billingAddress.setContactName("isim soyisim");
    billingAddress.setAddress("address");
    billingAddress.setCity("city");
    billingAddress.setCountry("turkey");
    billingAddress.setZipCode("34164");
    request.setBillingAddress(billingAddress);

    // Address
    // Shipping Address
    Address shippingAddress = new Address();
    shippingAddress.setContactName("isim soyisim");
    shippingAddress.setAddress("address");
    shippingAddress.setCity("city");
    shippingAddress.setCountry("turkey");
    shippingAddress.setZipCode("34164");
    request.setShippingAddress(shippingAddress);

    // Products
    // First Product
    List<Product> products = new ArrayList<Product>();
    Product firstProduct = new Product();
    firstProduct.setName("Ürün bir");
    firstProduct.setProductId(1234);
    firstProduct.setProductPrice(0.10);
    firstProduct.setItemType(ProductType.PHYSICAL.name());
    products.add(firstProduct);

    // Second Product
    Product secondProduct = new Product();
    secondProduct.setName("Ürün iki");
    secondProduct.setProductId(4567);
    secondProduct.setProductPrice(0.10);
    secondProduct.setItemType(ProductType.PHYSICAL.name());
    products.add(secondProduct);
    request.setProducts(products);

    CheckoutFormInitialize payment = CheckoutFormInitialize.create(request, options);
    System.out.println(payment.getCheckoutFormData());
```

{% endtab %}
{% endtabs %}

## API Servisinden Dönen Sonuç Örnekleri

### Başarılı Sonuç Örneği

```javascript
{
"CheckoutFormData":"html data",
"status":"success",
"paymentPageUrl":"Ortak Ödeme Sayfası linki"
}
```

### Başarısız Sonuç Örneği

```javascript
{
"status":"failure",
"errorCode":"030",
"error":"array()",
"message":"Hata Mesajı" 
}
```

## Ödeme Servisi Kullanım Çeşitleri

* Ödeme Formu Popup
* Ödeme Formu Responsive
* Ödeme Sayfası
* Ödeme Sayfası iFrame

### Ödeme Formu Kullanım Şekilleri

{% code title="Response" %}

```markup
Response olarak dönen CheckOutFormData nesnesi 2 farklı şekilde kullanılır.
<div id='weePay-checkout-form' class='popup'> // Popup Form
<div id='weePay-checkout-form' class='responsive'> // Responsive Form



```

{% endcode %}

### Ortak Ödeme Sayfası Kullanım Şekilleri

```markup
// Ortak Ödeme Sayfası

// Ödeme response ile gelen paymentPageUrl 
// alanındaki adrese Yönlendirme yapabilirinz
// Örnek Adres 
# https://api.weepay.co/GuvenliOdeme/Payment/xxxx-xxx-xxx-xxxxxx
```

### iframe Ortak Ödeme Sayfası&#x20;

```markup
// iframe ortak ödeme sayfası için
// Ödeme response ile gelen paymentPageUrl ortak ödeme URL'nin sonuna 
// get parametresi olarak iframe değeri true olarak gönderilir.
// Script tagları içerisine iframe resizer kullanarak iframe sorunsuz olarak kullanılır.

<iframe src="https://api.weepay.co/GuvenliOdeme/Payment/xxxx-xxx-xxx-xxxxxx?iframe=true"
id="weepayiframe" style="width: 100%;" frameborder="0" scrolling="no"></iframe>
<script src="https://service.weepay.co/assets/js/iframe-resizer.js"></script>
```

## 3D Secure (CallBack) Parametreleri

### Başarılı Sonuç Örneği

```javascript
{
"paymentStatus":true,// işlemin başarılı olup olmadı true / false
"paymentId":"",//Ödemenin Idsi
}
```

### Başarısız Sonuç Örneği

```javascript
{
"paymentStatus":false,// işlemin başarılı olup olmadı true / false
"errorCode":"00",
"message":"ÖRN : 3D onayı alınamadı."
}
```

{% hint style="danger" %}
ÖNEMLİ UYARI
{% endhint %}

CallBack URL POST olarak işlem sonucu gönderilir. İşlem sonucu başarılı ise [Ödeme Detay](https://developer.weepay.co/api/oedeme-detayi) servisimizi kullanarak ödemenin başarılı olup olmadığını tekrar kontrol ediniz.
