Paypal Express Checkout recurring payment










0















I'm trying to do recurring payment in paypal express checkout. Instant payment and recurring profile in paypal has been sucessfully created by using below code. Error in ipn response when recurring payment done in paypal i din't recive any response. Please verify below code



SetExpressCheckout



$total = 88; //Total do carrinho do cliente
$item_id = 'CLT-06';
$nvp = array(
'USER' => 'paypalsellerpay_api1.gmail.com',
'PWD' => 'C572HJQVLFCTRNC8',
'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
'METHOD' => 'SetExpressCheckout',
'VERSION' => '63',
'L_BILLINGTYPE0' => 'RecurringPayments',
'cancelUrl' => 'siteurl/cancel.php',
'returnUrl' => 'siteurl/retorno.php',
'PAYMENTREQUEST_n_NOTIFYURL' => 'siteurl/ipn_response.php',
'PAYMENTREQUEST_0_AMT' => $total,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'AMT' => $total,
'AUTOBILLOUTAMT' => 'AddToNextBilling',
'L_BILLINGAGREEMENTDESCRIPTION0' => 'NOC Live Express Test code',
'PAYMENTREQUEST_0_DESC' => 'NOC Live Express Test code',
'L_PAYMENTREQUEST_0_NAME0' => 'Recurring payment',
'L_PAYMENTTYPE0' => 'Any',
'item_number' => $item_id,
'L_PAYMENTREQUEST_0_NUMBER0' => $item_id,
'PAYMENTREQUEST_0_PAYMENTREQUESTID' => $item_id,
'L_PAYMENTREQUEST_0_DESC0' => 'Live Express Test codes',
'L_PAYMENTREQUEST_0_AMT0' => $total,
'CURRENCYCODE' => 'USD',
'PAYMENTACTION' => 'Sale',
'BILLINGPERIOD' => 'Day',
'BILLINGFREQUENCY' => '3',
'NOSHIPPING' => '1',
'ALLOWNOTE' => '1',


);

$curl = curl_init();

curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp || https://api-3t.paypal.com/nvp
curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt( $curl , CURLOPT_POST , 1 );
curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query($nvp));
$response = urldecode(curl_exec($curl));
curl_close( $curl );
$response_data = array();
if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
foreach ( $matches[ 'name' ] as $offset => $name )
$response_data[ $name ] = $matches[ 'value' ][ $offset ];



if ( isset( $response_data[ 'ACK' ] ) && $response_data[ 'ACK' ] == 'Success' )
$paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$query = array(
'cmd' => '_express-checkout',
'token' => $response_data[ 'TOKEN' ]
);

header( 'Location: ' . $paypalURL . '?' . http_build_query( $query ) );
else
echo 'Transaction failed';



GetExpressCheckoutDetails, DoExpressCheckoutPayment



$total = 58; 
$init_total = 88;
$item_id = 'CLT-07';
if ( isset( $_GET[ 'token' ] ) )
$token = $_GET[ 'token' ];
$nvp = array(
'TOKEN' => $token,
'METHOD' => 'GetExpressCheckoutDetails',
'VERSION' => '63',
'USER' => 'paypalsellerpay_api1.gmail.com',
'PWD' => 'C572HJQVLFCTRNC8',
'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
);

$curl = curl_init();

curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' );
curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt( $curl , CURLOPT_POST , 1 );
curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

$response = urldecode( curl_exec( $curl ) );
$response_data = array();
$response_data_get = array();

if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
foreach ( $matches[ 'name' ] as $offset => $name )
$response_data[ $name ] = $matches[ 'value' ][ $offset ];


$response_data_get = $response_data;

if ( isset( $response_data_get[ 'TOKEN' ] ) && isset( $response_data_get[ 'ACK' ]) )
if ( $response_data_get[ 'TOKEN' ] == $token && $response_data_get[ 'ACK' ] == 'Success' )
$nvp['TOKEN'] = $response_data_get[ 'TOKEN' ];
$nvp['PAYERID'] = $response_data_get[ 'PAYERID' ];
$nvp['AMT'] = $response_data_get[ 'AMT' ];
$nvp['CURRENCYCODE'] = $response_data_get[ 'CURRENCYCODE' ];
$nvp['L_PAYMENTREQUEST_0_NUMBER0'] = $item_id;
$nvp['PAYMENTREQUEST_0_PAYMENTREQUESTID'] = $item_id;
$nvp['NOTIFYURL'] = 'siteurl/ipn_response.php';
$nvp['METHOD'] = 'DoExpressCheckoutPayment';
$nvp['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';


curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

$response = urldecode( curl_exec( $curl ) );
$response_data = array();

if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
foreach ( $matches[ 'name' ] as $offset => $name )
$response_data[ $name ] = $matches[ 'value' ][ $offset ];


$response_data_recurr = array();
$response_data_recurr = recurr_payment($token, $init_total,$total);

if ( $response_data[ 'PAYMENTINFO_0_PAYMENTSTATUS' ] == 'Completed' )
echo 'Before Payment <br>'.print_r($response_data_get,true);
echo 'Sucess! <br>'.print_r($response_data,true);

pay_log('Payment Success');
else
echo 'Transaction Failed On Payment Failed <br>'.print_r($response_data,true);
pay_log('Payment Failed');

else
echo 'Transaction Failed On ACK & Token Failed <br>'.print_r($response_data,true);
pay_log('ACK && TOKEN Failed');

else
echo 'Transaction Failed On ACK & Token Not set<br>'.print_r($response_data,true);
pay_log('ISSET ACK && TOKEN NOT SET');


curl_close( $curl );



CreateRecurringPaymentsProfile



function recurr_payment($token, $init_total,$total)
$nvp = array();
$notifyurl='siteurl/ipn_response.php';
$nvp = array(
'USER' => 'paypalsellerpay_api1.gmail.com',
'PWD' => 'C572HJQVLFCTRNC8',
'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
'METHOD' => 'CreateRecurringPaymentsProfile',
'VERSION' => '63',
'TOKEN' => $token,
'SUBSCRIBERNAME' => 'Live Code Demo',
'PROFILESTARTDATE' => '2018-11-12 T00:00:00Z',
'DESC' => 'NOC Live Express Test code',
'BILLINGPERIOD' => 'Day',
'BILLINGFREQUENCY' => '1',
'TOTALBILLINGCYCLES' => '10',
'INITAMT' => $init_total,
'AMT' => $total,
'CURRENCYCODE' => 'USD',
'SHIPPINGAMT' => '1',
'NOTIFYURL' => urlencode($notifyurl),
'AUTOBILLOUTAMT' => 'AddToNextBilling'
);

$curl = curl_init();

curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp









share|improve this question


























    0















    I'm trying to do recurring payment in paypal express checkout. Instant payment and recurring profile in paypal has been sucessfully created by using below code. Error in ipn response when recurring payment done in paypal i din't recive any response. Please verify below code



    SetExpressCheckout



    $total = 88; //Total do carrinho do cliente
    $item_id = 'CLT-06';
    $nvp = array(
    'USER' => 'paypalsellerpay_api1.gmail.com',
    'PWD' => 'C572HJQVLFCTRNC8',
    'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
    'METHOD' => 'SetExpressCheckout',
    'VERSION' => '63',
    'L_BILLINGTYPE0' => 'RecurringPayments',
    'cancelUrl' => 'siteurl/cancel.php',
    'returnUrl' => 'siteurl/retorno.php',
    'PAYMENTREQUEST_n_NOTIFYURL' => 'siteurl/ipn_response.php',
    'PAYMENTREQUEST_0_AMT' => $total,
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
    'AMT' => $total,
    'AUTOBILLOUTAMT' => 'AddToNextBilling',
    'L_BILLINGAGREEMENTDESCRIPTION0' => 'NOC Live Express Test code',
    'PAYMENTREQUEST_0_DESC' => 'NOC Live Express Test code',
    'L_PAYMENTREQUEST_0_NAME0' => 'Recurring payment',
    'L_PAYMENTTYPE0' => 'Any',
    'item_number' => $item_id,
    'L_PAYMENTREQUEST_0_NUMBER0' => $item_id,
    'PAYMENTREQUEST_0_PAYMENTREQUESTID' => $item_id,
    'L_PAYMENTREQUEST_0_DESC0' => 'Live Express Test codes',
    'L_PAYMENTREQUEST_0_AMT0' => $total,
    'CURRENCYCODE' => 'USD',
    'PAYMENTACTION' => 'Sale',
    'BILLINGPERIOD' => 'Day',
    'BILLINGFREQUENCY' => '3',
    'NOSHIPPING' => '1',
    'ALLOWNOTE' => '1',


    );

    $curl = curl_init();

    curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp || https://api-3t.paypal.com/nvp
    curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
    curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
    curl_setopt( $curl , CURLOPT_POST , 1 );
    curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query($nvp));
    $response = urldecode(curl_exec($curl));
    curl_close( $curl );
    $response_data = array();
    if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
    foreach ( $matches[ 'name' ] as $offset => $name )
    $response_data[ $name ] = $matches[ 'value' ][ $offset ];



    if ( isset( $response_data[ 'ACK' ] ) && $response_data[ 'ACK' ] == 'Success' )
    $paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
    $query = array(
    'cmd' => '_express-checkout',
    'token' => $response_data[ 'TOKEN' ]
    );

    header( 'Location: ' . $paypalURL . '?' . http_build_query( $query ) );
    else
    echo 'Transaction failed';



    GetExpressCheckoutDetails, DoExpressCheckoutPayment



    $total = 58; 
    $init_total = 88;
    $item_id = 'CLT-07';
    if ( isset( $_GET[ 'token' ] ) )
    $token = $_GET[ 'token' ];
    $nvp = array(
    'TOKEN' => $token,
    'METHOD' => 'GetExpressCheckoutDetails',
    'VERSION' => '63',
    'USER' => 'paypalsellerpay_api1.gmail.com',
    'PWD' => 'C572HJQVLFCTRNC8',
    'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
    );

    $curl = curl_init();

    curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' );
    curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
    curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
    curl_setopt( $curl , CURLOPT_POST , 1 );
    curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

    $response = urldecode( curl_exec( $curl ) );
    $response_data = array();
    $response_data_get = array();

    if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
    foreach ( $matches[ 'name' ] as $offset => $name )
    $response_data[ $name ] = $matches[ 'value' ][ $offset ];


    $response_data_get = $response_data;

    if ( isset( $response_data_get[ 'TOKEN' ] ) && isset( $response_data_get[ 'ACK' ]) )
    if ( $response_data_get[ 'TOKEN' ] == $token && $response_data_get[ 'ACK' ] == 'Success' )
    $nvp['TOKEN'] = $response_data_get[ 'TOKEN' ];
    $nvp['PAYERID'] = $response_data_get[ 'PAYERID' ];
    $nvp['AMT'] = $response_data_get[ 'AMT' ];
    $nvp['CURRENCYCODE'] = $response_data_get[ 'CURRENCYCODE' ];
    $nvp['L_PAYMENTREQUEST_0_NUMBER0'] = $item_id;
    $nvp['PAYMENTREQUEST_0_PAYMENTREQUESTID'] = $item_id;
    $nvp['NOTIFYURL'] = 'siteurl/ipn_response.php';
    $nvp['METHOD'] = 'DoExpressCheckoutPayment';
    $nvp['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';


    curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

    $response = urldecode( curl_exec( $curl ) );
    $response_data = array();

    if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
    foreach ( $matches[ 'name' ] as $offset => $name )
    $response_data[ $name ] = $matches[ 'value' ][ $offset ];


    $response_data_recurr = array();
    $response_data_recurr = recurr_payment($token, $init_total,$total);

    if ( $response_data[ 'PAYMENTINFO_0_PAYMENTSTATUS' ] == 'Completed' )
    echo 'Before Payment <br>'.print_r($response_data_get,true);
    echo 'Sucess! <br>'.print_r($response_data,true);

    pay_log('Payment Success');
    else
    echo 'Transaction Failed On Payment Failed <br>'.print_r($response_data,true);
    pay_log('Payment Failed');

    else
    echo 'Transaction Failed On ACK & Token Failed <br>'.print_r($response_data,true);
    pay_log('ACK && TOKEN Failed');

    else
    echo 'Transaction Failed On ACK & Token Not set<br>'.print_r($response_data,true);
    pay_log('ISSET ACK && TOKEN NOT SET');


    curl_close( $curl );



    CreateRecurringPaymentsProfile



    function recurr_payment($token, $init_total,$total)
    $nvp = array();
    $notifyurl='siteurl/ipn_response.php';
    $nvp = array(
    'USER' => 'paypalsellerpay_api1.gmail.com',
    'PWD' => 'C572HJQVLFCTRNC8',
    'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
    'METHOD' => 'CreateRecurringPaymentsProfile',
    'VERSION' => '63',
    'TOKEN' => $token,
    'SUBSCRIBERNAME' => 'Live Code Demo',
    'PROFILESTARTDATE' => '2018-11-12 T00:00:00Z',
    'DESC' => 'NOC Live Express Test code',
    'BILLINGPERIOD' => 'Day',
    'BILLINGFREQUENCY' => '1',
    'TOTALBILLINGCYCLES' => '10',
    'INITAMT' => $init_total,
    'AMT' => $total,
    'CURRENCYCODE' => 'USD',
    'SHIPPINGAMT' => '1',
    'NOTIFYURL' => urlencode($notifyurl),
    'AUTOBILLOUTAMT' => 'AddToNextBilling'
    );

    $curl = curl_init();

    curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp









    share|improve this question
























      0












      0








      0








      I'm trying to do recurring payment in paypal express checkout. Instant payment and recurring profile in paypal has been sucessfully created by using below code. Error in ipn response when recurring payment done in paypal i din't recive any response. Please verify below code



      SetExpressCheckout



      $total = 88; //Total do carrinho do cliente
      $item_id = 'CLT-06';
      $nvp = array(
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      'METHOD' => 'SetExpressCheckout',
      'VERSION' => '63',
      'L_BILLINGTYPE0' => 'RecurringPayments',
      'cancelUrl' => 'siteurl/cancel.php',
      'returnUrl' => 'siteurl/retorno.php',
      'PAYMENTREQUEST_n_NOTIFYURL' => 'siteurl/ipn_response.php',
      'PAYMENTREQUEST_0_AMT' => $total,
      'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
      'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
      'AMT' => $total,
      'AUTOBILLOUTAMT' => 'AddToNextBilling',
      'L_BILLINGAGREEMENTDESCRIPTION0' => 'NOC Live Express Test code',
      'PAYMENTREQUEST_0_DESC' => 'NOC Live Express Test code',
      'L_PAYMENTREQUEST_0_NAME0' => 'Recurring payment',
      'L_PAYMENTTYPE0' => 'Any',
      'item_number' => $item_id,
      'L_PAYMENTREQUEST_0_NUMBER0' => $item_id,
      'PAYMENTREQUEST_0_PAYMENTREQUESTID' => $item_id,
      'L_PAYMENTREQUEST_0_DESC0' => 'Live Express Test codes',
      'L_PAYMENTREQUEST_0_AMT0' => $total,
      'CURRENCYCODE' => 'USD',
      'PAYMENTACTION' => 'Sale',
      'BILLINGPERIOD' => 'Day',
      'BILLINGFREQUENCY' => '3',
      'NOSHIPPING' => '1',
      'ALLOWNOTE' => '1',


      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp || https://api-3t.paypal.com/nvp
      curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
      curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
      curl_setopt( $curl , CURLOPT_POST , 1 );
      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query($nvp));
      $response = urldecode(curl_exec($curl));
      curl_close( $curl );
      $response_data = array();
      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];



      if ( isset( $response_data[ 'ACK' ] ) && $response_data[ 'ACK' ] == 'Success' )
      $paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
      $query = array(
      'cmd' => '_express-checkout',
      'token' => $response_data[ 'TOKEN' ]
      );

      header( 'Location: ' . $paypalURL . '?' . http_build_query( $query ) );
      else
      echo 'Transaction failed';



      GetExpressCheckoutDetails, DoExpressCheckoutPayment



      $total = 58; 
      $init_total = 88;
      $item_id = 'CLT-07';
      if ( isset( $_GET[ 'token' ] ) )
      $token = $_GET[ 'token' ];
      $nvp = array(
      'TOKEN' => $token,
      'METHOD' => 'GetExpressCheckoutDetails',
      'VERSION' => '63',
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' );
      curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
      curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
      curl_setopt( $curl , CURLOPT_POST , 1 );
      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

      $response = urldecode( curl_exec( $curl ) );
      $response_data = array();
      $response_data_get = array();

      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];


      $response_data_get = $response_data;

      if ( isset( $response_data_get[ 'TOKEN' ] ) && isset( $response_data_get[ 'ACK' ]) )
      if ( $response_data_get[ 'TOKEN' ] == $token && $response_data_get[ 'ACK' ] == 'Success' )
      $nvp['TOKEN'] = $response_data_get[ 'TOKEN' ];
      $nvp['PAYERID'] = $response_data_get[ 'PAYERID' ];
      $nvp['AMT'] = $response_data_get[ 'AMT' ];
      $nvp['CURRENCYCODE'] = $response_data_get[ 'CURRENCYCODE' ];
      $nvp['L_PAYMENTREQUEST_0_NUMBER0'] = $item_id;
      $nvp['PAYMENTREQUEST_0_PAYMENTREQUESTID'] = $item_id;
      $nvp['NOTIFYURL'] = 'siteurl/ipn_response.php';
      $nvp['METHOD'] = 'DoExpressCheckoutPayment';
      $nvp['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';


      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

      $response = urldecode( curl_exec( $curl ) );
      $response_data = array();

      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];


      $response_data_recurr = array();
      $response_data_recurr = recurr_payment($token, $init_total,$total);

      if ( $response_data[ 'PAYMENTINFO_0_PAYMENTSTATUS' ] == 'Completed' )
      echo 'Before Payment <br>'.print_r($response_data_get,true);
      echo 'Sucess! <br>'.print_r($response_data,true);

      pay_log('Payment Success');
      else
      echo 'Transaction Failed On Payment Failed <br>'.print_r($response_data,true);
      pay_log('Payment Failed');

      else
      echo 'Transaction Failed On ACK & Token Failed <br>'.print_r($response_data,true);
      pay_log('ACK && TOKEN Failed');

      else
      echo 'Transaction Failed On ACK & Token Not set<br>'.print_r($response_data,true);
      pay_log('ISSET ACK && TOKEN NOT SET');


      curl_close( $curl );



      CreateRecurringPaymentsProfile



      function recurr_payment($token, $init_total,$total)
      $nvp = array();
      $notifyurl='siteurl/ipn_response.php';
      $nvp = array(
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      'METHOD' => 'CreateRecurringPaymentsProfile',
      'VERSION' => '63',
      'TOKEN' => $token,
      'SUBSCRIBERNAME' => 'Live Code Demo',
      'PROFILESTARTDATE' => '2018-11-12 T00:00:00Z',
      'DESC' => 'NOC Live Express Test code',
      'BILLINGPERIOD' => 'Day',
      'BILLINGFREQUENCY' => '1',
      'TOTALBILLINGCYCLES' => '10',
      'INITAMT' => $init_total,
      'AMT' => $total,
      'CURRENCYCODE' => 'USD',
      'SHIPPINGAMT' => '1',
      'NOTIFYURL' => urlencode($notifyurl),
      'AUTOBILLOUTAMT' => 'AddToNextBilling'
      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp









      share|improve this question














      I'm trying to do recurring payment in paypal express checkout. Instant payment and recurring profile in paypal has been sucessfully created by using below code. Error in ipn response when recurring payment done in paypal i din't recive any response. Please verify below code



      SetExpressCheckout



      $total = 88; //Total do carrinho do cliente
      $item_id = 'CLT-06';
      $nvp = array(
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      'METHOD' => 'SetExpressCheckout',
      'VERSION' => '63',
      'L_BILLINGTYPE0' => 'RecurringPayments',
      'cancelUrl' => 'siteurl/cancel.php',
      'returnUrl' => 'siteurl/retorno.php',
      'PAYMENTREQUEST_n_NOTIFYURL' => 'siteurl/ipn_response.php',
      'PAYMENTREQUEST_0_AMT' => $total,
      'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
      'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
      'AMT' => $total,
      'AUTOBILLOUTAMT' => 'AddToNextBilling',
      'L_BILLINGAGREEMENTDESCRIPTION0' => 'NOC Live Express Test code',
      'PAYMENTREQUEST_0_DESC' => 'NOC Live Express Test code',
      'L_PAYMENTREQUEST_0_NAME0' => 'Recurring payment',
      'L_PAYMENTTYPE0' => 'Any',
      'item_number' => $item_id,
      'L_PAYMENTREQUEST_0_NUMBER0' => $item_id,
      'PAYMENTREQUEST_0_PAYMENTREQUESTID' => $item_id,
      'L_PAYMENTREQUEST_0_DESC0' => 'Live Express Test codes',
      'L_PAYMENTREQUEST_0_AMT0' => $total,
      'CURRENCYCODE' => 'USD',
      'PAYMENTACTION' => 'Sale',
      'BILLINGPERIOD' => 'Day',
      'BILLINGFREQUENCY' => '3',
      'NOSHIPPING' => '1',
      'ALLOWNOTE' => '1',


      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp || https://api-3t.paypal.com/nvp
      curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
      curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
      curl_setopt( $curl , CURLOPT_POST , 1 );
      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query($nvp));
      $response = urldecode(curl_exec($curl));
      curl_close( $curl );
      $response_data = array();
      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];



      if ( isset( $response_data[ 'ACK' ] ) && $response_data[ 'ACK' ] == 'Success' )
      $paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
      $query = array(
      'cmd' => '_express-checkout',
      'token' => $response_data[ 'TOKEN' ]
      );

      header( 'Location: ' . $paypalURL . '?' . http_build_query( $query ) );
      else
      echo 'Transaction failed';



      GetExpressCheckoutDetails, DoExpressCheckoutPayment



      $total = 58; 
      $init_total = 88;
      $item_id = 'CLT-07';
      if ( isset( $_GET[ 'token' ] ) )
      $token = $_GET[ 'token' ];
      $nvp = array(
      'TOKEN' => $token,
      'METHOD' => 'GetExpressCheckoutDetails',
      'VERSION' => '63',
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' );
      curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
      curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
      curl_setopt( $curl , CURLOPT_POST , 1 );
      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

      $response = urldecode( curl_exec( $curl ) );
      $response_data = array();
      $response_data_get = array();

      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];


      $response_data_get = $response_data;

      if ( isset( $response_data_get[ 'TOKEN' ] ) && isset( $response_data_get[ 'ACK' ]) )
      if ( $response_data_get[ 'TOKEN' ] == $token && $response_data_get[ 'ACK' ] == 'Success' )
      $nvp['TOKEN'] = $response_data_get[ 'TOKEN' ];
      $nvp['PAYERID'] = $response_data_get[ 'PAYERID' ];
      $nvp['AMT'] = $response_data_get[ 'AMT' ];
      $nvp['CURRENCYCODE'] = $response_data_get[ 'CURRENCYCODE' ];
      $nvp['L_PAYMENTREQUEST_0_NUMBER0'] = $item_id;
      $nvp['PAYMENTREQUEST_0_PAYMENTREQUESTID'] = $item_id;
      $nvp['NOTIFYURL'] = 'siteurl/ipn_response.php';
      $nvp['METHOD'] = 'DoExpressCheckoutPayment';
      $nvp['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';


      curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

      $response = urldecode( curl_exec( $curl ) );
      $response_data = array();

      if ( preg_match_all( '/(?<name>[^=]+)=(?<value>[^&]+)&?/' , $response , $matches ) )
      foreach ( $matches[ 'name' ] as $offset => $name )
      $response_data[ $name ] = $matches[ 'value' ][ $offset ];


      $response_data_recurr = array();
      $response_data_recurr = recurr_payment($token, $init_total,$total);

      if ( $response_data[ 'PAYMENTINFO_0_PAYMENTSTATUS' ] == 'Completed' )
      echo 'Before Payment <br>'.print_r($response_data_get,true);
      echo 'Sucess! <br>'.print_r($response_data,true);

      pay_log('Payment Success');
      else
      echo 'Transaction Failed On Payment Failed <br>'.print_r($response_data,true);
      pay_log('Payment Failed');

      else
      echo 'Transaction Failed On ACK & Token Failed <br>'.print_r($response_data,true);
      pay_log('ACK && TOKEN Failed');

      else
      echo 'Transaction Failed On ACK & Token Not set<br>'.print_r($response_data,true);
      pay_log('ISSET ACK && TOKEN NOT SET');


      curl_close( $curl );



      CreateRecurringPaymentsProfile



      function recurr_payment($token, $init_total,$total)
      $nvp = array();
      $notifyurl='siteurl/ipn_response.php';
      $nvp = array(
      'USER' => 'paypalsellerpay_api1.gmail.com',
      'PWD' => 'C572HJQVLFCTRNC8',
      'SIGNATURE' => 'APbFQnrgReyuSoEWhJ8cBfn34GiDATmy50R-KvFePYyoWPqBSA3JVkHp',
      'METHOD' => 'CreateRecurringPaymentsProfile',
      'VERSION' => '63',
      'TOKEN' => $token,
      'SUBSCRIBERNAME' => 'Live Code Demo',
      'PROFILESTARTDATE' => '2018-11-12 T00:00:00Z',
      'DESC' => 'NOC Live Express Test code',
      'BILLINGPERIOD' => 'Day',
      'BILLINGFREQUENCY' => '1',
      'TOTALBILLINGCYCLES' => '10',
      'INITAMT' => $init_total,
      'AMT' => $total,
      'CURRENCYCODE' => 'USD',
      'SHIPPINGAMT' => '1',
      'NOTIFYURL' => urlencode($notifyurl),
      'AUTOBILLOUTAMT' => 'AddToNextBilling'
      );

      $curl = curl_init();

      curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' ); //Link para ambiente de teste: https://api-3t.sandbox.paypal.com/nvp






      express paypal response paypal-ipn checkout






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 10:40









      Sathish PSSathish PS

      11




      11






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260437%2fpaypal-express-checkout-recurring-payment%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260437%2fpaypal-express-checkout-recurring-payment%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Syphilis

          Darth Vader #20