ladela/paypal-adaptivepayments-sdk-php

Paypal PHP自适应支付SDK

v0.4.3 2013-01-14 13:39 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:42:17 UTC


README

先决条件

PayPal的PHP自适应支付SDK需要

  • PHP 5.2及以上版本,且启用了curl/openssl扩展

使用SDK

要使用SDK,

  • 将config和lib文件夹复制到您的项目中。修改配置文件以适应您的需求。
  • 确保您的项目中lib文件夹在PHP的包含路径中可用
  • 在您的代码中包含services\AdaptivePayments\AdaptivePaymentsService.php文件。
  • 实例化一个服务包装器对象
  • 根据项目的需求实例化一个请求对象。所有API请求和响应类都在services\AdaptivePayments\AdaptivePaymentsService.php中可用
  • 在服务对象上调用适当的方法,传入请求对象。

例如,

	require_once('services/AdaptivePayments/AdaptivePaymentsService.php');

    $payRequest = new PayRequest($requestEnvelope, $actionType, $cancelUrl, 
                                  $currencyCode, $receiverList, $returnUrl);
    // Add optional params
    if($_POST["feesPayer"] != "") {
	   $payRequest->feesPayer = $_POST["feesPayer"];
    }
	......

	$service = new AdaptivePaymentsService();
	$response = $service->Pay($payRequest);	
	$ack = strtoupper($response->responseEnvelope->ack); 
	if($ack == 'SUCCESS') {
		// Success
	}

SDK提供了多种方法来验证您的API调用。

	$service = new AdaptivePaymentsService();
	
	// Use the default account (the first account) configured in sdk_config.ini
	$response = $service->Pay($payRequest);	

	// Use a specific account configured in sdk_config.inig
	$response = $service->Pay($payRequest, 'jb-us-seller_api1.paypal.com');	
	 
	// Pass in a dynamically created API credential object
    $cred = new PPCertificateCredential("username", "password", "path-to-pem-file");
    $cred->setThirdPartyAuthorization(new PPTokenAuthorization("accessToken", "tokenSecret"));
	$response = $service->Pay($payRequest, $cred);	

SDK配置

在config/sdk_config.ini中替换API凭证。您可以使用配置文件来配置

  • (多个) API账户凭证。
  • 服务端点和其他HTTP连接参数
  • 日志记录

请参阅此软件包提供的示例配置文件。

同时使用多个SDK

*将'lib/service/'中的内容复制到其中一个SDK中 *将服务端点添加到'config/sdk_config.ini'中,端点如下列表所示

端点配置

*以下列表指定了不同服务在SANDBOX和PRODUCTION中的端点,以及它们的属性键和属性值作为端点。

------------------------------SANDBOX------------------------------

------------------------------PRODUCTION------------------------------

如需更多信息,请参考 https://www.x.com/developers/paypal/documentation-tools/api

即时支付通知 (IPN)

请参考 'samples/IPN' 目录下的 IPN-README 文件

获取帮助

如果您在使用 SDK 时需要帮助,需要的新功能或需要报告的问题,请访问

https://www.x.com/developers/paypal/forums/adaptive-payments-api

 OR

https://github.com/paypal/adaptivepayments-sdk-php/issues