コード例 #1
0
 /**
  * Make paypal Payment via REST API
  *
  */
 public function make_paypal_payment($price, $currencyType, $payment_desc, $card_type, $card_holder_name, $card_number, $expire_month, $expire_year, $cvv)
 {
     $price = (double) $price;
     $card_type = strtolower($card_type);
     // ### CreditCard
     // A resource representing a credit card that can be
     // used to fund a payment.
     $card = new PayPal\Api\CreditCard();
     $card->setType($card_type)->setNumber($card_number)->setExpireMonth("11")->setExpireYear($expire_year)->setCvv2($cvv)->setFirstName($card_holder_name);
     //->setLastName("Shopper");
     // ### FundingInstrument
     // A resource representing a Payer's funding instrument.
     // For direct credit card payments, set the CreditCard
     // field on this object.
     $fi = new PayPal\Api\FundingInstrument();
     $fi->setCreditCard($card);
     // ### Payer
     // A resource representing a Payer that funds a payment
     // For direct credit card payments, set payment method
     // to 'credit_card' and add an array of funding instruments.
     $payer = new PayPal\Api\Payer();
     $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
     // ### Amount
     // Lets you specify a payment amount.
     // You can also specify additional details
     // such as shipping, tax.
     $amount = new PayPal\Api\Amount();
     $amount->setCurrency($currencyType)->setTotal($price);
     //->setDetails($details);
     // ### Transaction
     // A transaction defines the contract of a
     // payment - what is the payment for and who
     // is fulfilling it.
     $transaction = new PayPal\Api\Transaction();
     $transaction->setAmount($amount)->setDescription($payment_desc)->setInvoiceNumber(uniqid());
     // ### Payment
     // A Payment Resource; create one using
     // the above types and intent set to sale 'sale'
     $payment = new PayPal\Api\Payment();
     $payment->setIntent("sale")->setPayer($payer)->setTransactions(array($transaction));
     // For Sample Purposes Only.
     $request = clone $payment;
     // ### Create Payment
     // Create a payment by calling the payment->create() method
     // with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
     // The return object contains the state.
     try {
         $clientId = $this->config->item('clientId');
         $clientSecret = $this->config->item('clientSecret');
         $apiContext = getApiContext($clientId, $clientSecret);
         $payment->create($apiContext);
     } catch (Exception $ex) {
         $this->session->set_flashdata('error_message', 'Something is going wrong! please try again later!!');
         redirect('', 'refresh');
         //ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
         //exit(1);
     }
     //ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment);
     return $payment;
 }
コード例 #2
0
ファイル: Paypal.php プロジェクト: shivap87/cost
 /**
  * Retrieves the payment information based on PaymentID from Paypal APIs
  *
  * @param $paymentId
  *
  * @return Payment
  */
 function getPaymentDetails($paymentId)
 {
     $payment = Payment::get($paymentId, getApiContext());
     return $payment;
 }
コード例 #3
0
    echo "The 'vendor' folder is missing. You must run 'composer update' to resolve application dependencies.\nPlease see the README for more information.\n";
    exit(1);
}
if (!file_exists(APPLICATION_PATH . "/../logs")) {
    mkdir(APPLICATION_PATH . "/../logs", 0774, true);
}
require APPLICATION_PATH . '/../vendor/autoload.php';
define("PP_CONFIG_PATH", APPLICATION_PATH . "/../");
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Rest\ApiContext;
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$config = new Zend_Config_Ini(APPLICATION_PATH . '/../sdk_config.ini', 'Account');
$clientId = $config->ClientId;
$clientSecret = $config->ClientSecret;
$apiContext = getApiContext($clientId, $clientSecret);
return $apiContext;
function getApiContext($clientId, $clientSecret)
{
    // #### SDK configuration
    // Register the sdk_config.ini file in current directory
    // as the configuration source.
    /*
    if(!defined("PP_CONFIG_PATH")) {
        define("PP_CONFIG_PATH", __DIR__);
    }
    */
    // ### Api context
    // Use an ApiContext object to authenticate
    // API calls. The clientId and clientSecret for the
    // OAuthTokenCredential class can be retrieved from
コード例 #4
0
 public function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl, $cancelUrl)
 {
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     // Specify the payment amount.
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($total);
     // ###Transaction
     // A transaction defines the contract of a
     // payment - what is the payment for and who
     // is fulfilling it. Transaction is created with
     // a 'Payee' and 'Amount' types
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($paymentDesc);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl);
     $redirectUrls->setCancelUrl($cancelUrl);
     $payment = new Payment();
     $payment->setRedirectUrls($redirectUrls);
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $payment->create(getApiContext());
     return $payment;
 }
コード例 #5
0
ファイル: bootstrap.php プロジェクト: fur81/zofaxiopeu
<?php

/*
 * Sample bootstrap file.
 */
// Include the composer autoloader
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
    echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n";
    exit(1);
}
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/common.php';
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
$apiContext = getApiContext();
/**
 * Helper method for getting an APIContext for all calls
 *
 * @return PayPal\Rest\ApiContext
 */
function getApiContext()
{
    // ### Api context
    // Use an ApiContext object to authenticate
    // API calls. The clientId and clientSecret for the
    // OAuthTokenCredential class can be retrieved from
    // developer.paypal.com
    /*	
    	// sandbox
    	$apiContext = new ApiContext(
    		new OAuthTokenCredential(
コード例 #6
0
ファイル: bootstrap.php プロジェクト: kenpi04/apidemo
require_once __DIR__ . '/common/paypal.php';
require_once __DIR__ . '/common/util.php';
require_once __DIR__ . '/common/key.php';
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
// Define connection parameters
define('MYSQL_HOST', 'localhost');
define('MYSQL_USERNAME', 'root');
define('MYSQL_PASSWORD', '12345');
define('MYSQL_DB', 'api_data');
define('API_USER', 'admin');
define('API_PASSWORD', 'admin');
define('ADMIN_USER', 'admin_123');
define('ADMIN_PASS', '12345%$#@!');
define('HOST', 'http://dungvt-002-site8.myasp.net/app/');
return getApiContext();
// SDK Configuration
function getApiContext()
{
    // Define the location of the sdk_config.ini file
    if (!defined("PP_CONFIG_PATH")) {
        define("PP_CONFIG_PATH", dirname(__DIR__));
    }
    $apiContext = new ApiContext(new OAuthTokenCredential('EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM', 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'));
    // Alternatively pass in the configuration via a hashmap.
    // The hashmap can contain any key that is allowed in
    // sdk_config.ini
    /*
    $apiContext->setConfig(array(
    	'http.ConnectionTimeOut' => 30,
    	'http.Retry' => 1,
コード例 #7
0
// Replace these values by entering your own ClientId and Secret by visiting https://developer.paypal.com/webapps/developer/applications/myapps
$clientId = $client_live;
$clientSecret = $secret_live;
$clientId = $client_sandbox;
$clientSecret = $secret_sandbox;
//test vals
/*'AS84hxmvVpU-Y904GwXJcu3C2iF54SGuO8k52fsLHhYmp135j5SonqREucemDsFAHRTIjEVZ4eVLdP3G',
'EHoKao6U4-HFjli2q1rumvQQ2I-ampQdMbVXSflc6n3eQPQ1L7MfQH2x5FPKpLMHneaUQ3nCXpeokXkh'*/
/**
 * All default curl options are stored in the array inside the PayPalHttpConfig class. To make changes to those settings
 * for your specific environments, feel free to add them using the code shown below
 * Uncomment below line to override any default curl options.
 */
//PayPalHttpConfig::$defaultCurlOptions[CURLOPT_SSLVERSION] = CURL_SSLVERSION_TLSv1_2;
/** @var \Paypal\Rest\ApiContext $apiContext */
$paypal = getApiContext($clientId, $clientSecret);
return $paypal;
/**
 * Helper method for getting an APIContext for all calls
 * @param string $clientId Client ID
 * @param string $clientSecret Client Secret
 * @return PayPal\Rest\ApiContext
 */
function getApiContext($clientId, $clientSecret)
{
    // #### SDK configuration
    // Register the sdk_config.ini file in current directory
    // as the configuration source.
    /*
    if(!defined("PP_CONFIG_PATH")) {
        define("PP_CONFIG_PATH", __DIR__);
コード例 #8
0
ファイル: paypal.php プロジェクト: fur81/zofaxiopeu
/**
 * Completes the payment once buyer approval has been
 * obtained. Used only when the payment method is 'paypal'
 * 
 * @param string $paymentId id of a previously created
 * 		payment that has its payment method set to 'paypal'
 * 		and has been approved by the buyer.
 * 
 * @param string $payerId PayerId as returned by PayPal post
 * 		buyer approval.
 */
function executePayment($paymentId, $payerId)
{
    $payment = Payment::get($paymentId, getApiContext());
    $paymentExecution = new PaymentExecution();
    $paymentExecution->setPayerId($payerId);
    $payment = $payment->execute($paymentExecution, getApiContext());
    return $payment;
}
コード例 #9
0
//CONST
define('IS_SANDBOX', false);
$mode = 'live';
if (IS_SANDBOX) {
    $mode = 'sandbox';
    $clientId = 'AdpL_r75o2aPiN36_q-N00bHysXd_kciEqBC1fk6wJScCooh_H_c3yiQtslCtBrdOHxcCMp1wWrEgKq3';
    $clientSecret = 'EJUta11-1or7CxrEmbG0JuGLRk8TFbYSA9rqrLwACUoNtHo1eo4AJlEnDQcOc2GRYs3v1vlSy7LpRuSC';
} else {
    // Replace these values by entering your own ClientId and Secret by visiting https://developer.paypal.com/webapps/developer/applications/myapps
    //live cred
    $clientId = 'AY7rStyj9hsTxKmRaNF33qil4RFvDzLD_ovULHhqGrOWOWuy9b-kkNNGfWg5eT4YsuEgZh7V4vSluypE';
    $clientSecret = 'EJSZ8J9mjaRJaob77W4Fs5rhSiyI-c2nAP2_lYLZFmxwT_im0y-mXRwCE_NQBSe7sdkw2ZPPh9Qi-pgk';
    ////live cred
}
/** @var \Paypal\Rest\ApiContext $apiContext */
$apiContext = getApiContext($clientId, $clientSecret, $mode);
return $apiContext;
/**
 * Helper method for getting an APIContext for all calls
 *
 * @param string $clientId Client ID
 * @param string $clientSecret Client Secret
 *
 * @return PayPal\Rest\ApiContext
 */
function getApiContext($clientId, $clientSecret, $mode)
{
    // #### SDK configuration
    // Register the sdk_config.ini file in current directory
    // as the configuration source.
    /*
コード例 #10
0
ファイル: bootstrap.php プロジェクト: kayecandy/secudev
//     }
// }
// require $composerAutoload;
require __DIR__ . '/common.php';
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Rest\ApiContext;
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Replace these values by entering your own ClientId and Secret by visiting https://developer.paypal.com/webapps/developer/applications/myapps
// global $clientId;
// $clientId = 'AQ2LctRuZ4HMRI4AWt-ho08f-pnzboLgP5Knxo6XzNgmCzMuNvRP2SKyjJ90MIF7V8vuIJPWoCEJfu1e';
// global $clientSecret;
// $clientSecret = 'ELHW3t4KYkWa3oosJUTQ0VB7R_HJE7kW_xMuQu-u_msHgokk1FF0rnydINs3E6xIKj448jDPov8sefZL';
/** @var \Paypal\Rest\ApiContext $apiContext */
global $PAYPAL;
$PAYPAL['api_context'] = getApiContext($PAYPAL['client_id'], $PAYPAL['client_secret']);
return $PAYPAL['api_context'];
/**
 * Helper method for getting an APIContext for all calls
 * @param string $clientId Client ID
 * @param string $clientSecret Client Secret
 * @return PayPal\Rest\ApiContext
 */
function getApiContext($clientId, $clientSecret)
{
    // #### SDK configuration
    // Register the sdk_config.ini file in current directory
    // as the configuration source.
    /*
    if(!defined("PP_CONFIG_PATH")) {
        define("PP_CONFIG_PATH", __DIR__);