2012-01-28 4 views
10

누구든지 API를 사용하여 PayPal 구독을 관리하는 방법을 알고 있습니까? 구독을 취소, 일시 중단 및 다시 활성화하려면 ManageRecurringPaymentsProfileStatus을 사용할 수 있지만 ID를 가져 오는 방법을 찾을 수 없어서 사용할 수 없다는 사실을 읽었습니다.API를 사용하여 PayPal 구독을 관리하는 방법은 무엇입니까?

This page은 ID를 포함하는 CreateRecurringPaymentsProfile의 응답을 사용한다고 말합니다. API를 사용하여 구독을 만들지는 못하기 때문에 이렇게 할 수 없습니다.

ID 만 가져 오는 API 메소드가 있습니까? 감사. 제공 한 모래 상자

+0

사람을 참조하십시오? 이 페이지에서는 ID가 profileID가되어야한다고 말하지만, 더 읽은 후에는 subscriptionID를 대신 사용할 수있는 것처럼 보입니다. 구독 세부 정보와 ID를 얻는 방법을 모르겠습니다. –

+2

S-로 시작하는 구독은 API를 통해 관리 할 수 ​​없습니다 (취소 만 가능). I-로 시작하는 새 구독은 API를 통해 관리 할 수 ​​있지만 제한된 기능 만 사용할 수 있습니다. 최상의 결과를 얻으려면 CreateRecurringPaymentsProfile을 통해 반복 지불 프로필을 만들고 여기에 ManageRecurringPaymentsProfileStatus를 사용하십시오. – Robert

답변

4

페이팔 직접 payment..please 변화 자격 ...

<?php 

/** DoDirectPayment NVP example; last modified 08MAY23. 
* 
* Process a credit card payment. 
*/ 

$environment = 'sandbox'; // or 'beta-sandbox' or 'live' 

/** 
* Send HTTP POST Request 
* 
* @param string The API method name 
* @param string The POST Message fields in &name=value pair format 
* @return array Parsed HTTP Response body 
*/ 
function PPHttpPost($methodName_, $nvpStr_) { 
    global $environment; 

    // Set up your API credentials, PayPal end point, and API version. 
    $API_UserName = urlencode('debash_1332929919_biz_api1.gmail.com'); 
    $API_Password = urlencode('1332929952'); 
    $API_Signature = urlencode('AIiPJKMw38NGZuaiDaeLWrH9x.WBAK4WXf1vh9.Y.YxEM-4DlbDLMEVe'); 
    $API_Endpoint = "https://api-3t.paypal.com/nvp"; 
    if("sandbox" === $environment || "beta-sandbox" === $environment) { 
     $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp"; 
    } 
    $version = urlencode('51.0'); 

    // Set the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 

    // Turn off the server and peer verification (TrustManager Concept). 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 

    // Set the API operation, version, and API signature in the request. 
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_"; 

    // Set the request as a POST FIELD for curl. 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); 

    // Get response from the server. 
    $httpResponse = curl_exec($ch); 

    if(!$httpResponse) { 
     exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')'); 
    } 

    // Extract the response details. 
    $httpResponseAr = explode("&", $httpResponse); 

    $httpParsedResponseAr = array(); 
    foreach ($httpResponseAr as $i => $value) { 
     $tmpAr = explode("=", $value); 
     if(sizeof($tmpAr) > 1) { 
      $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1]; 
     } 
    } 

    if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) { 
     exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint."); 
    } 

    return $httpParsedResponseAr; 
} 

// Set request-specific fields. 
$paymentType = urlencode('Sale');    // or 'Sale' 
$firstName = urlencode('Debashis'); 
$lastName = urlencode('Banerjee'); 
$creditCardType = urlencode('visa'); 
$creditCardNumber = urlencode('4860795409505688'); 
$expDateMonth = '3'; 
// Month must be padded with leading zero 
$padDateMonth = urlencode(str_pad($expDateMonth, 2, '0', STR_PAD_LEFT)); 

$expDateYear = urlencode('2017'); 
$cvv2Number = urlencode('111'); 
$address1 = urlencode('Kaikala'); 
$address2 = urlencode('Hooghly'); 
$city = urlencode('Kaikala'); 
$state = urlencode('WB'); 
$zip = urlencode('712405'); 
$country = urlencode('IN');    // US or other valid country code 
$amount = urlencode('71'); 
$currencyID = urlencode('USD');       // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') 

// Add request-specific fields to the request string. 
$nvpStr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber". 
      "&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName". 
      "&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID"; 

// Execute the API operation; see the PPHttpPost function above. 
$httpParsedResponseAr = PPHttpPost('DoDirectPayment', $nvpStr); 

if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { 
    exit('Direct Payment Completed Successfully: '.print_r($httpParsedResponseAr, true)); 
} else { 
    exit('DoDirectPayment failed: ' . print_r($httpParsedResponseAr, true)); 
} 

?> 

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code

감사

+0

일부 작동 코드는 +1입니다. 감사합니다. –

관련 문제