Beispiel #1
0
function record_request($vendor_id, $item_id, $phone, $notify)
{
    $new = make_post_call("request_ID", ["vendor_id" => $vendor_id, "item_id" => $item_id, "phone" => $phone, "notify" => $notify]);
    return $new;
}
echo "Payment related_resources:" . $related_resource_count . "(" . $related_resources . ")";
echo "\n \n";
echo "###########################################\n";
echo "Initiating a Payment with PayPal Account... \n";
$url = $host . '/v1/payments/payment';
$payment = array('intent' => 'sale', 'payer' => array('payment_method' => 'paypal'), 'transactions' => array(array('amount' => array('total' => '7.47', 'currency' => 'USD'), 'description' => 'payment using a PayPal account')), 'redirect_urls' => array('return_url' => 'http://www.return.com/?test=123', 'cancel_url' => 'http://www.cancel.com'));
$json = json_encode($payment);
$json_resp = make_post_call($url, $json);
foreach ($json_resp['links'] as $link) {
    if ($link['rel'] == 'execute') {
        $payment_execute_url = $link['href'];
        $payment_execute_method = $link['method'];
    } else {
        if ($link['rel'] == 'approval_url') {
            $payment_approval_url = $link['href'];
            $payment_approval_method = $link['method'];
        }
    }
}
echo "Payment Created successfully: " . $json_resp['id'] . " with state '" . $json_resp['state'] . "'\n\n";
echo "Please goto " . $payment_approval_url . " in your browser and approve the payment with a PayPal Account.\n";
echo "Enter PayerId from the return url to continue:";
$payerId = read_stdin();
echo "\n \n";
echo "###########################################\n";
echo "Executing the PayPal Payment for PayerId (" . $payerId . ")... \n";
$payment_execute = array('payer_id' => $payerId);
$json = json_encode($payment_execute);
$json_resp = make_post_call($payment_execute_url, $json);
echo "Payment Execute processed " . $json_resp['id'] . " with state '" . $json_resp['state'] . "'";
echo "\n \n";
Beispiel #3
0
            "currency":"USD"
            },
        "description":"This is the payment transaction description."
	}],
	"payer": {
		"payment_method":"paypal"
	},
	"intent":"sale",
	"redirect_urls": {
		"cancel_url":"http://localhost:8000/test3",
		"return_url":"http://localhost:8000/test2"
	}
   }';
//$json = json_encode($payment);
$url_2 = "https://api.sandbox.paypal.com/v1/payments/payment";
$json_resp = make_post_call($token, $url_2, $payment);
print_r($json_resp);
foreach ($json_resp['links'] as $link) {
    if ($link['rel'] == 'approval_url') {
        $payment_detail_url = $link['href'];
        $payment_detail_method = $link['method'];
    }
}
function Redirect_to($url, $permanent = false)
{
    if (headers_sent() === false) {
        header('Location: ' . $url, true, $permanent === true ? 301 : 302);
    }
    exit;
}
//echo $payment_detail_url;
Beispiel #4
0
"sku":"' . $itemSku . '",
"currency":"' . $currency . '"
}
]
}
}
],
"redirect_urls":{
"return_url":"https://www.example.com",
"cancel_url":"https://www.example.com"
}
}
';
//var_dump ($json);
//die(payment);
$json_resp = make_post_call($url, $payment);
#Get the token out of the response array (for later use)
$token = substr($json_resp['links']['1']['href'], -20);
$paymentID = $json_resp['id'];
#Put JSON in a nice readable format
$json_resp = stripslashes(json_format($json_resp));
?>

<html>
<head>
    <title>Paypal Plus pago directo con Tarjeta de Crédito / Débito</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href='https://fonts.googleapis.com/css?family=Raleway:400,500,300,600,200' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />