PHP code example of jlkaufman / cakephp-paypal-rest-client
1. Go to this page and download the library: Download jlkaufman/cakephp-paypal-rest-client 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/ */
jlkaufman / cakephp-paypal-rest-client example snippets
// Paypal
public $Paypal = array(
'datasource' => 'PaypalSource.PaypalSource',
'environment' => 'sandbox', // Production: 'production' SandBox: 'sandbox'
'username' => '',
'password' => '',
'receiver_email' => ''
);
$data = array(
'credit_card' => array(
"number" => "4417119669820331",
"type" => "visa",
"expire_month" => 1,
"expire_year" => 2018,
"cvv2" => "874",
"first_name" => "Joe",
"last_name" => "Shopper"
),
'billing_address' => array(
"line1" => "52 N Main ST",
"line2" => "Apt. 211",
"city" => "Johnstown",
"country_code" => "CA",
"postal_code" => "H0H 0H0",
"state" => "Quebec"
),
'transaction' => array(
"amount" => array(
"total" => "7.47",
"currency" => "USD",
"details" => array(
"subtotal" => "7.41",
"tax" => "0.03",
"shipping" => "0.03"
)
),
"description" => "This is the payment transaction description."
)
);
$response = $this->Paypal->creditCardPayment($data, $type);
$data = array(
'credit_card_token' => array(
"credit_card_id" => "CARD-7VH15004HC811510SKEGDHDI"
),
'transaction' => array(
"amount" => array(
"total" => "7.47",
"currency" => "USD",
"details" => array(
"subtotal" => "7.41",
"tax" => "0.03",
"shipping" => "0.03"
)
),
"description" => "This is the payment transaction description."
)
);
$response = $this->Paypal->creditCardPayment($data, $type);
$capture_data = array(
'authorization_id' => '10V50318J8770814T',
'currency' => 'USD',
'total' => '7.47',
'is_final_capture' => true
);
$response = $this->Paypal->captureAuthorization($data);
$data = array(
'authorization_id' => '2073151243457584H'
);
$response = $this->Paypal->voidAuthorization($data);
$data = array(
'payment_id' => '3XX41928KR179661L',
'currency' => 'USD',
'total' => '7.47'
);
$response = $this->Paypal->refundPayment($data);