Recurring Payment

RECURRING PAYMENT WITH REGISTERED CARD

Using this service, you can pay for your user with a card available in PAY for recurring payment.

1-)Create the payment request block wtih specified values. The payment process will be formed as a result of the request that you will send to the service with the registered card information through the structure that you will create yourself.

2-)For this reason, there is no need to create a form to interact with the user.Transactions will take place as Non3D (Non Secure).Your user will october take any additional actions or any information will not be requested from him during the process.(In order to use it, your store must have Non3D permissions)

3-)From the CAPI LIST service, you need to access the ctoken data by using the utoken data belonging to the user whose name you want to pay for.After that, utoken, ctoken and the following table with the specified values https://www.paytr.com/odeme you can request payment by POST method to the address

Values to be sent in POST REQUEST content:

Field name / type Description Mandatory Limitations & Notes
merchant_id (integer) Merchant ID: Your Merchant ID provided by PayTR Yes
paytr_token (string) Paytr_token: It is used to ensure that the request comes from you and the content did not change Yes Please check the sample codes for calculation
user_ip (string) User ip: User IP received during the request (Important: Make sure you send the external IP address when you run tests on your local machine) Yes Up to 39 characters (ipv4)
merchant_oid (string) Merchant order id: The unique order id you set for the transaction.(Note: Order number is posted back within callback notification - on STEP 2 Yes Up to 64 characters, Alpha numeric
email (string) User email address: The email address which; the user registered with on your system or you received via the order form Yes Up to 100 characters
payment_amount (double), decimal (.) and two digits after the point Payment amount: The total amount of the order. Yes For example: 100.99 or 150 or 1500.35
payment_type(string) Payment type Yes ('card')
installment_count(int) Installment count Yes 0, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12
card_type(string) Card type (For installment transactions) No advantage, axess, combo, bonus, cardfinans, maximum, paraf, world, saglamkart
currency(string) Currency No TL(or TRY), EUR, USDD (TL is assumed if not sent)
client_lang(string) Language to be used on payment process No tr for Turkish or en for English (tr is assumed if not sent)
test_mode When the merchant is in live mode, it can be sent as 1 to run a test No 0 or 1
non_3d For recurring payment send this value as 1 Yes 0 or 1
non3d_test_failed If you need to test failed Non3D transaction send 1 (non_3d and test_mode values must be both 1) No 0 or 1
merchant_ok_url(string) The page the user will be redirected to after successful payment (e.g. Order status / my orders page)(Warning: the payment may not have been approved yet when the user reaches this page Yes Up to 400 characters
merchant_fail_url(string) The page that the user will be redirected to if something unexpected occurs Yes Up to 400 characters
user_name (string) User name and surname: First and last name of the user that you have on your system or received via the order form Yes Up to 60 characters
user_address (string) User address: The address of the user that you have on your system or received via the order form Yes Up to 400 characters
user_phone (string) User phone number: The phone number of the user that you have on your system or received via the order form Yes Up to 20 characters
user_basket (string) User basket/order contents Yes JSON - Please check the sample codes for structure
debug_on (int) Display errors: If the value is 1, when wrong or incomplete information is transmitted to the API, error message is displayed on the page. No 0 or 1(Be sure to send 1 to detect errors during the integration and testing process)
utoken(string) User Token: User specific token notified to you by PAYTR system in post-payment notification Yes -
ctoken(string) Card Token: The token that identifies the user's registered card Yes -
recurring_payment(int) Recurring:After sending a payment request, the response in JSON format returns directly to the request result without redirecting to the successful or unsuccessful page according to the result of the transaction. In addition; Details of the transaction are sent to the defined Notification URL address. The values that the status field returned as a result of sync mode can receive are “failed”, “wait_callback” and “success”Note: The Non3D authorization must be turned on in your store for this operation. No 0 or 1 (A request must be sent to us in order for the relevant authorization to be defined to the store. If it is approved by our units, the authorization will be defined to the store.)


RECURRING RESPONSE

status msg (description) try_again
failed "The card was closed by the bank. Do not send transactions again with this card.” or a different error message. false
failed You have an ongoing transaction, you can try again after it is completed true
wait_callback Checking Payment, Wait for Notification. -
success Successful Payment -


<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
    </head>

    <?php

        $merchant_id = 'XXXXXXXXXXX';
        $merchant_key = 'XXXXXXXXXXX';
        $merchant_salt = 'YYYYYYYYYYY';

        $merchant_ok_url="http://site-ismi/basarili";
        $merchant_fail_url="http://site-ismi/basarisiz";

        $user_basket = htmlentities(json_encode(array(
            array("Altis Renkli Deniz Yatağı - Mavi", "18.00", 1),
            array("Pharmasol Güneş Kremi 50+ Yetişkin & Bepanthol Cilt Bakım Kremi", "33,25", 2),
            array("Bestway Çocuklar İçin Plaj Seti Beach Set ÇANTADA DENİZ TOPU-BOT-KOLLUK", "45,42", 1)
        )));

        srand(time(null));
        $merchant_oid = rand();

        $test_mode="0";

        $non_3d="1";

        $non3d_test_failed="0";

        if( isset( $_SERVER["HTTP_CLIENT_IP"] ) ) {
            $ip = $_SERVER["HTTP_CLIENT_IP"];
        } elseif( isset( $_SERVER["HTTP_X_FORWARDED_FOR"] ) ) {
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        } else {
            $ip = $_SERVER["REMOTE_ADDR"];
        }

        $user_ip = $ip;

        $email = "testnon3d@paytr.com";

        $payment_amount = "100.99";
        $currency="TL";

        $payment_type = "card";

        $recurring_payment = "1";

        $post_url = "https://www.paytr.com/odeme";

        $hash_str = $merchant_id . $user_ip . $merchant_oid . $email . $payment_amount . $payment_type . $installment_count. $currency. $test_mode. $non_3d;
        $token = base64_encode(hash_hmac('sha256',$hash_str.$merchant_salt,$merchant_key,true));

        $utoken = "";
        $ctoken = "";       

    ?>

    <body>
        <form action="<?php echo $post_url;?>" method="post">
          <input type="hidden" name="merchant_id" value="<?php echo $merchant_id;?>">
          <input type="hidden" name="user_ip" value="<?php echo $user_ip;?>">
          <input type="hidden" name="merchant_oid" value="<?php echo $merchant_oid;?>">
          <input type="hidden" name="email" value="<?php echo $email;?>">
          <input type="hidden" name="payment_type" value="<?php echo $payment_type;?>">
          <input type="hidden" name="payment_amount" value="<?php echo $payment_amount;?>">
          <input type="hidden" name="installment_count" value="0">
          <input type="hidden" name="currency" value="<?php echo $currency;?>">
          <input type="hidden" name="test_mode" value="<?php echo $test_mode;?>">
          <input type="hidden" name="non_3d" value="<?php echo $non_3d;?>">
          <input type="hidden" name="merchant_ok_url" value="<?php echo $merchant_ok_url;?>">
          <input type="hidden" name="merchant_fail_url" value="<?php echo $merchant_fail_url;?>">
          <input type="hidden" name="user_name" value="Paytr Test">
          <input type="hidden" name="user_address" value="test test test">
          <input type="hidden" name="user_phone" value="05555555555">
          <input type="hidden" name="user_basket" value="<?php echo $user_basket; ?>">
          <input type="hidden" name="debug_on" value="1">
          <input type="hidden" name="paytr_token" value="<?php echo $token; ?>">
          <input type="hidden" name="non3d_test_failed" value="<?php echo $non3d_test_failed; ?>">
          <input type="hidden" name="installment_count" value="<?php echo $installment_count; ?>">
          <input type="hidden" name="card_type" value="<?php echo $card_type; ?>">
          <input type="hidden" name="utoken" value="<?php echo $utoken; ?>">
          <input type="hidden" name="ctoken" value="<?php echo $ctoken; ?>">
          <input type="hidden" name="recurring_payment" value="<?php echo $recurring_payment;?>">
          <br />
          <input type="submit" value="Submit">
        </form>
    </body>
</html>

Recurring Payment Service sample codes Click to download.