1. Go to this page and download the library: Download tanatoss/merchant-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tanatoss / merchant-sdk-php example snippets
// Sets config file path(if config file is used) and registers the classloader
nfig file is used)
$config = array(
'mode' => 'sandbox',
'acct1.UserName' => 'jb-us-seller_api1.paypal.com',
'acct1.Password' => 'WX4WTU3S8MY44S7F'
.....
);
// Create request details
$itemAmount = new BasicAmountType($currencyId, $amount);
$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
// Create request
$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
......
// Perform request
$paypalService = new PayPalAPIInterfaceServiceService($config);
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
// Check results
if(strtoupper($setECResponse->Ack) == 'SUCCESS') {
// Success
}
$paypalService = new PayPalAPIInterfaceServiceService($config);
// Use the default account (the first account) configured in sdk_config.ini
$response = $paypalService->SetExpressCheckout($setECReq);
// Use a specific account configured in sdk_config.ini
$response = $paypalService->SetExpressCheckout($setECReq, '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 = $paypalService->SetExpressCheckout($setECReq, $cred);