1
cakephp 2.0 프레임 워크를 사용하고 있습니다. 누군가가 내가 Unscubscribe 기능에 user_id를 보내 whenver 내가 구독 취소 기능 월간 정기 결제를 취소 하시겠습니까?
public function unsubscribe() {
if(isset($_POST['user_id']) && !empty($_POST['user_id'])){
$this->loadModel('PaypalSinglePayment');
$this->loadModel('PaypalRecurringPayment');
$userDetails = $this->PaypalSinglePayment->find('first', array(
'conditions'=> array(
'user_id'=>$_POST['user_id'],
'payment_type'=>"Month"
)
)
);
if(!empty($userDetails))
{
$profile_id=urlencode($userDetails['PaypalSinglePayment']['subscriber_id']);
$profileID=urlencode($profile_id);
$action = urlencode('Cancel');
$nvpStr="&PROFILEID=$profileID&ACTION=$action";
$paypal = new PaypalPro(['live'=>1]);
$resArray=$paypal->hashCall("ManageRecurringPaymentsProfileStatus",$nvpStr);
$ack = strtoupper((string)$resArray["ACK"]);
if($ack=="SUCCESS"){
$this->PaypalSinglePayment->id = $userDetails['PaypalSinglePayment']['id'];
$data['payment_status'] = "Cancel";
if($this->PaypalSinglePayment->save($data)){
echo json_encode(array(
'status'=>'Success',
'responseCode'=>1
)
);
die;
}
}
else{
echo json_encode(array('msg' => 'Something went wrong, please try again','status'=>'Error Occured','responseCode'=>0));
die;
}
}
}
echo json_encode(array('msg' => 'Something went wrong, please try again','status'=>'Error Occured','responseCode'=>0));
die;
}
이 내가 잘못 여기서 뭐하는 거지 도와 줄 수는 여기에서 다른 상태로 이동 난이 성공적으로 subscriber_id를 얻을. 누군가가 내가 잘못 여기서 뭐하는 거지 내가 어떻게 도와 드릴까요하면 USER_ID = 24 PAYMENT_TYPE = "달"을 paypal_single_payments 테이블의 모든 기록을 가지고하지 않을 수 hashcallFunction
enter code here
public function hashCall($methodName,$nvpStr){
// form header string
$nvpheader = $this->nvpHeader();
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$this->apiEndpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//turning 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);
//in case of permission APIs send headers as HTTPheders
if(!empty($this->authToken) && !empty($this->authSignature) && !empty($this->authTimestamp))
{
$headers_array[] = "X-PP-AUTHORIZATION: ".$nvpheader;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
curl_setopt($ch, CURLOPT_HEADER, false);
}
else
{
$nvpStr = $nvpheader.$nvpStr;
}
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
if($this->useProxy)
curl_setopt ($ch, CURLOPT_PROXY, $this->proxyHost.":".$this->proxyPort);
//check if version is included in $nvpStr else include the version.
if(strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
$nvpStr = "&VERSION=" . urlencode($this->version) . $nvpStr;
}
$nvpreq="METHOD=".urlencode($methodName).$nvpStr;
//setting the nvpreq as POST FIELD to curl
curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);
//getting response from server
$response = curl_exec($ch);
//convrting NVPResponse to an Associative Array
$nvpResArray = $this->deformatNVP($response);
$nvpReqArray = $this->deformatNVP($nvpreq);
$_SESSION['nvpReqArray']=$nvpReqArray;
if (curl_errno($ch)) {
die("CURL send a error during perform operation: ".curl_error($ch));
} else {
//closing the curl
curl_close($ch);
}
return $nvpResArray;
}
프레임 워크를 사용하는 동안 항상 케이크 구조를 사용해야합니다. 우선, 데이터를'$ this-> request-> data [ 'Model'] [ 'attribute']'로 접근 할 것이다. 첫 번째 발견 물이 무엇을 얻었는지 확인 (인쇄) 했습니까? 'user_id'가 바로 거기에 도착했는지 확인 했습니까? – SrQ