Paypal adaptive Zahlung PHP
Ich habe dieses Problem. Ich habe dieses Tutorial befolgt ->http://www.youtube.com/watch?v=rzRR1i-F_VA
und nachdem ich alles eingestellt habe, habe ich ein Problem damit, den Authentifizierungsprozess zu durchlaufen. Und nach einigen Recherchen zur Authentifizierung habe ich dies getestet ->https://developer.paypal.com/webapps/developer/docs/classic/lifecycle/ug_sandbox/
Irgendwann im Prozess (Erstellen von Testanforderungen) habe ich es in einer Bash-Konsole getestet, und meine Benutzer-ID, mein Kennwort und meine Signatur haben funktioniert. Also denke ich, dass das Problem in dem von mir verwendeten Code lag.
Also hier ist der Code:
<?php
class PaypalTest extends CComponent{
public $api_user = "**********************";
public $api_pass = "***********";
public $api_sig = "**************************";
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;
public function __construct(){
$this->headers = array(
"X-PAYPAL-SECURITY-USERID: ".$this->api_user,
"X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
"X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ".$this->app_id,
);
}
public function getPaymentOptions($paykey){
}
public function setPaymentOptions(){
}
public function _paypalSend($data,$call){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HEADER, $this->headers);
$response = json_decode(curl_exec($ch),true);
return $response;
}
public function splitPay(){
// create the pay request
$createPacket = array(
"actionType" =>"PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array(
"amount"=> "1.00",
"email"=>"********@hotmail.com"
),
array(
"amount"=> "2.00",
"email"=>"********@gmail.ca"
),
),
),
"returnUrl" => "http://test.local/payments/confirm",
"cancelUrl" => "http://test.local/payments/cancel",
"requestEnvelope" => array(
"errorLanguage" => "en_US",
"detailLevel" => "ReturnAll",
),
);
$response = $this->_paypalSend($createPacket,"Pay");
}
}
Und hier ist der Aufruf:
$payment = new PaypalTest();
$payment->splitPay();
Ganz einfach, aber etwas funktioniert nicht. Und ich kenne Curl nicht so gut, also dachte ich, ihr könnt mir helfen
PS: Ich bin im Sandbox-Modus
Vielen Dank
Carl