Skip to content

Instantly share code, notes, and snippets.

@neo22s
Created February 7, 2016 21:36
Show Gist options
  • Save neo22s/22de47afe43470769d08 to your computer and use it in GitHub Desktop.
Save neo22s/22de47afe43470769d08 to your computer and use it in GitHub Desktop.
paypal adaptive payment example to pay directly to an account
<?
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ini_set('display_errors', 1);
use PayPal\Service\AdaptivePaymentsService;
use PayPal\Types\AP\FundingConstraint;
use PayPal\Types\AP\FundingTypeInfo;
use PayPal\Types\AP\FundingTypeList;
use PayPal\Types\AP\PayRequest;
use PayPal\Types\AP\Receiver;
use PayPal\Types\AP\ReceiverList;
use PayPal\Types\AP\SenderIdentifier;
use PayPal\Types\Common\PhoneNumberType;
use PayPal\Types\Common\RequestEnvelope;
require 'PPAutoloader.php';
PPAutoloader::register();
$returnUrl = 'http://' . $_SERVER['SERVER_NAME']. "/index.php";
$payRequest = new PayRequest();
$receiver = array();
$receiver[0] = new Receiver();
$receiver[0]->amount = "1.00";
$receiver[0]->email = "platfo_1255170694_biz@gmail.com";
$receiverList = new ReceiverList($receiver);
$payRequest->receiverList = $receiverList;
$payRequest->senderEmail = "platfo_1255077030_biz@gmail.com";
$requestEnvelope = new RequestEnvelope("en_US");
$payRequest->requestEnvelope = $requestEnvelope;
$payRequest->actionType = "PAY";
$payRequest->cancelUrl = $returnUrl;
$payRequest->returnUrl = $returnUrl;
$payRequest->currencyCode = "USD";
$payRequest->ipnNotificationUrl = $returnUrl;
$sdkConfig = array(
"mode" => "sandbox",
"acct1.UserName" => "jb-us-seller_api1.paypal.com",
"acct1.Password" => "WX4WTU3S8MY44S7F",
"acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy",
"acct1.AppId" => "APP-80W284485P519543T"
);
$adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
$payResponse = $adaptivePaymentsService->Pay($payRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment