Mam możliwość utworzyć guziki ale chcę użyć SOAPa w php. Poniżej zamieszczam tajny kod i wyjaśnienie
$client = new SoapClient('https://www.paypal.com/wsdl/PayPalSvc.wsdl', array(
'soap_version' => '106.0',
'trace' => 1,
'exceptions' => 1,
'location'=> 'https://api-3t.paypal.com/2.0/',
));
$cred = array(
'Username' => 'moj_prawidlowy username',
'Password' => 'KO23W9UJSB57HIJD',
'Signature' => 'AFcWxV21C7fd0v98TYYRCpSSRl31A7MbjiHUHOLDgv0HmrH.pJcvMr.r'
);
$Credentials = new stdClass();
$Credentials->Credentials = new SoapVar( $cred, SOAP_ENC_OBJECT, 'Credentials' );
$headers = new SoapVar( $Credentials,
SOAP_ENC_OBJECT,
'CustomSecurityHeaderType',
'urn:ebay:apis:eBLBaseComponents'
);
$client->__setSoapHeaders( new SoapHeader(
'urn:ebay:api:PayPalAPI',
'RequesterCredentials',
$headers ));
$args = array(
'Version' => '106.0',
'ReturnAllCurrencies' => '1'
);
$GetBalanceRequest = new stdClass();
$GetBalanceRequest->GetBalanceRequest = new SoapVar( $args,
SOAP_ENC_OBJECT,
'GetBalanceRequestType',
'urn:ebay:api:PayPalAPI'
);
$params = new SoapVar( $GetBalanceRequest, SOAP_ENC_OBJECT, 'GetBalanceRequest' );
$result = $client->GetBalance( $params );
echo 'Balance is: ', $result->Balance->_, ' ', $result->Balance->currencyID;
/*
Powyzej kod dziala i wyświetla mi Balance. ale to kod z przykładu z PayPala
Teraz chciałem ustawić platności poniższym kodem
*/
//set Express checkout
$args2 = array(
'OrderTotal' => '10.0 PLN',
'PaymentRequestID' => '78y3h7y8y78',
);
$PaymentDetails = new stdClass();
$PaymentDetails->PaymentDetails = new SoapVar( $args2,
SOAP_ENC_OBJECT,
'PaymentDetailsType',
'urn:ebay:api:PayPalAPI'
);
$args3 = array(
'PayPalAccountID' => '3C988uJMfU7A',
'PaymentRequestID' => '3366y66uug',
);
$SellerDetails = new stdClass();
$SellerDetails->SellerDetails = new SoapVar( $args3,
SOAP_ENC_OBJECT,
'SellerDetailsType',
'urn:ebay:api:PayPalAPI'
);
$paymentDetailsArray = array();
$paymentDetailsArray[] = $PaymentDetails->PaymentDetails;
$args1 = array(
'Version' => '106.0',
'ReturnURL' => 'http://www/success',
'CancelURL' => 'http://www/cancel',
'ReqConfirmShipping' => '0',
'NoShipping' => '1',
'PaymentDetails' => $paymentDetailsArray,
);
$SetExpressCheckoutRequestDetails = new stdClass();
$SetExpressCheckoutRequestDetails->SetExpressCheckoutRequestDetails = new SoapVar( $args1,
SOAP_ENC_OBJECT,
'SetExpressCheckoutRequestDetailsType',
'urn:ebay:api:PayPalAPI'
);
//var_dump($SetExpressCheckoutRequestDetails);
//die();
$params = new SoapVar( $SetExpressCheckoutRequestDetails, SOAP_ENC_OBJECT, 'SetExpressCheckoutRequestDetails' );
$result = $client->SetExpressCheckout( $params );
var_dump($result);
die();
I mam błąd wersji ale to spowodowane jest chyba czymś innym bo nr wersji się zgadza 106. Ktoś ma jakś pomysł albo przykład jak to pocisnąć. To mój 4 dzień i chyba się poddaje :/