잘 페이팔 SDK는 매우 간단합니다. 먼저 내가 당신의 예제 코드를 설치하고 서버에서 제대로 작동하는지 확인해 보았습니다. 이전 경험에서 SDK가 작동하지 않고 PHP 버전 문제가있는 드문 경우가 있습니다. 당신이 당신의 서버에서 작동 확신 둘째 후
차트 흐름은 다음과 같습니다
1 단계) SetExpressCheckout - 같은 모든 필수 필드 : 청구 주소, 제품은 총 등 ...
그 카트
이이 토큰을 얻을 것이다 올바른 수행 된 경우,
2 단계) GetExpressCheckout - 이전에 취득으로는 당신이 당신이 얻을 것이다 올바른하는 경우에 GetExpressCheckout이 토큰을 통과 할 것 토큰 : 승인, 토큰 , PayerID, value, currencyID 및 기본적으로 모든 구매 세부 사항이있는 오브젝트입니다.
3 단계) DoExpressCheckout - 다음과 같이 DoExpressCheckout을 2에서 획득 한 필드를 사용 :
$path = $pluginfolder.'paypal/lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php');
require_once('PPLoggingManager.php');
$logger = new PPLoggingManager('DoExpressCheckout');
$token = urlencode($getToken);
$payerId = urlencode( $getPayerID);
$paymentAction = urlencode( $paymentType);
$orderTotal = new BasicAmountType();
$orderTotal->currencyID = $getCurrencyID;
$orderTotal->value = $getOrderTotal;
$paymentDetails= new PaymentDetailsType();
$paymentDetails->OrderTotal = $orderTotal;
if(isset($notifyURL))
{
$paymentDetails->NotifyURL = $notifyURL;
}
$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = $payerId;
$DoECRequestDetails->Token = $token;
$DoECRequestDetails->PaymentAction = $paymentAction;
$DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
$DoECRequest = new DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
$DoECReq = new DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
/*
* Trying to go a head with the payment and catching errors that might occure.
*/
try {
/* wrap API method calls on the service object with a try catch */
$DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
} catch (Exception $ex) {
if(isset($ex)) {
$ex_message = $ex->getMessage();
$ex_type = get_class($ex);
if($ex instanceof PPConnectionException) {
$error[] = "Error connecting to " . $ex->getUrl();
$errorCheck = true;
} else if($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
$error[] = $ex->errorMessage();
$errorCheck = true;
} else if($ex instanceof PPConfigurationException) {
$error[] = "Invalid configuration. Please check your configuration file";
$errorCheck = true;
}
}
}
난이 도움이되기를 바랍니다.
doexpresscheckout에 토큰/지불기 ID를 추가합니까? –