当前位置: 首页>>代码示例>>PHP>>正文


PHP getApiContext函数代码示例

本文整理汇总了PHP中getApiContext函数的典型用法代码示例。如果您正苦于以下问题:PHP getApiContext函数的具体用法?PHP getApiContext怎么用?PHP getApiContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getApiContext函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: make_paypal_payment

 /**
  * 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;
 }
开发者ID:suman0359,项目名称:CI_Paypal_REST_API,代码行数:64,代码来源:payment_library.php

示例2: getPaymentDetails

 /**
  * Retrieves the payment information based on PaymentID from Paypal APIs
  *
  * @param $paymentId
  *
  * @return Payment
  */
 function getPaymentDetails($paymentId)
 {
     $payment = Payment::get($paymentId, getApiContext());
     return $payment;
 }
开发者ID:shivap87,项目名称:cost,代码行数:12,代码来源:Paypal.php

示例3: exit

    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
开发者ID:cioionut,项目名称:products-webEcommerce,代码行数:31,代码来源:paypal_bootstrap.php

示例4: makePaymentUsingPayPal

 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;
 }
开发者ID:edgarsandoval,项目名称:aseguro.mx,代码行数:27,代码来源:QuoteController.php

示例5: exit

<?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(
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:31,代码来源:bootstrap.php

示例6: define

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,
开发者ID:kenpi04,项目名称:apidemo,代码行数:31,代码来源:bootstrap.php

示例7: getApiContext

// 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__);
开发者ID:JackyBabyT,项目名称:knealschocolates.com,代码行数:31,代码来源:start.php

示例8: executePayment

/**
 * 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;
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:19,代码来源:paypal.php

示例9: define

//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.
    /*
开发者ID:jeremygeltman,项目名称:ThinkThinly,代码行数:31,代码来源:bootstrap.php

示例10: error_reporting

//     }
// }
// 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__);
开发者ID:kayecandy,项目名称:secudev,代码行数:31,代码来源:bootstrap.php


注:本文中的getApiContext函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。