本文整理匯總了PHP中Stripe\Stripe::setApiVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stripe::setApiVersion方法的具體用法?PHP Stripe::setApiVersion怎麽用?PHP Stripe::setApiVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stripe\Stripe
的用法示例。
在下文中一共展示了Stripe::setApiVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
/*
* Load Stripe configuration
*
* API keys should be utilizing Laravel's "dot files" to keep them out of source
* control and making them easily overridable on dev environments
*
* Read more: http://laravel.com/docs/configuration#environment-configuration
*/
$api_key = isset($_ENV['stripe.api_key']) ? $_ENV['stripe.api_key'] : $this->app['config']->get('services.stripe')['api_key'];
\Stripe\Stripe::setApiKey($api_key);
// Set API Version (optional)
$api_version = isset($_ENV['stripe.api_version']) ? $_ENV['stripe.api_version'] : $this->app['config']->get('services.stripe')['api_version'];
if ($api_version !== null) {
\Stripe\Stripe::setApiVersion($api_version);
}
$publishableKey = isset($_ENV['stripe.publishable_key']) ? $_ENV['stripe.publishable_key'] : $this->app['config']->get('services.stripe')['publishable_key'];
/*
* Register blade compiler for the Stripe publishable key.
*/
$blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler();
$blade->extend(function ($value, $compiler) use($publishableKey) {
$matcher = "/(?<!\\w)(\\s*)@stripeKey/";
return preg_replace($matcher, $publishableKey, $value);
});
}
示例2:
<?php
require_once 'stripe/init.php';
// Set Stripe API Key
\Stripe\Stripe::setApiKey("sk_test_t2dbnO7tLqxiz3MeyAIsLjJQ");
\Stripe\Stripe::setApiVersion("2015-08-07");
$token_id = $_POST['stripeToken'];
// It is generated by client side code
$customer = \Stripe\Customer::create(array("source" => $token_id, "description" => 'description for customer'));
$customer_id = $customer->id;
// Create a charge object to charge a credit or a debit card
$charge = \Stripe\Charge::create(array('customer' => $customer_id, 'amount' => 100, 'currency' => "usd", "description" => 'description for customer'));
示例3: formCapture
/**
*
*/
public function formCapture()
{
if (isset($_POST['pride_export'])) {
Entry::exportToCsv();
exit;
}
if (isset($_POST['edit_outspokane_entry'])) {
switch ($_POST['form']) {
case 'festival':
$entry = new FestivalEntry($_POST['id']);
break;
case 'cruise':
$entry = new CruiseEntry($_POST['id']);
break;
case 'parade':
$entry = new ParadeEntry($_POST['id']);
break;
case 'donation':
$entry = new Donation($_POST['id']);
break;
case 'flag':
$entry = new FlagHandle($_POST['id']);
break;
case 'sponsorship':
$entry = new Sponsorship($_POST['id']);
break;
default:
$entry = new MurderMysteryEntry($_POST['id']);
}
$entry->setEntryYear($_POST['entry_year'])->setOrganization($_POST['organization'])->setFirstName($_POST['first_name'])->setLastName($_POST['last_name'])->setEmail($_POST['email'])->setPhone($_POST['phone'])->setAddress($_POST['address'])->setCity($_POST['city'])->setState($_POST['state'])->setZip($_POST['zip'])->setQty($_POST['qty']);
if ($_POST['form'] == 'festival') {
$entry->setEntryTypeId($_POST['entry_type_id'])->setIsCornerBooth($_POST['is_corner_booth'])->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty']))->setPriceForCornerBooth(preg_replace('/[^0-9\\.]/', '', $_POST['price_for_corner_booth']))->setDescription($_POST['description']);
} elseif ($_POST['form'] == 'cruise') {
$entry->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty']));
} elseif ($_POST['form'] == 'parade') {
$entry->setEntryTypes($_POST['parade_entry_type'])->setDescription($_POST['description'])->setFloatParkingSpaces($_POST['float_parking_spaces'])->setFloatParkingSpaceCost(preg_replace('/[^0-9\\.]/', '', $_POST['float_parking_space_cost']))->setNeedsAmpedSound($_POST['needs_amped_sound'])->setGroupSize($_POST['group_size']);
} elseif ($_POST['form'] == 'murder_mystery') {
$entry->setIsSponsor($_POST['is_sponsor'])->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty']))->setIsUpgraded($_POST['is_upgraded'])->setVegetarianQty($_POST['vegetarian_qty']);
} elseif ($_POST['form'] == 'donation') {
$entry->setDonationAmount($_POST['donation_amount']);
} elseif ($_POST['form'] == 'flag') {
$entry->setMessage($_POST['message'])->setColor($_POST['color']);
} elseif ($_POST['form'] == 'sponsorship') {
$entry->setPosition($_POST['position'])->setLocalPosition($_POST['local_position'])->setAmount($_POST['amount'])->setUrl($_POST['url'])->setLevel($_POST['level'])->setLocalFirstName($_POST['local_first_name'])->setLocalLastName($_POST['local_last_name'])->setLocalAddress($_POST['local_address'])->setLocalCity($_POST['local_city'])->setLocalState($_POST['local_state'])->setLocalZip($_POST['local_zip'])->setLocalEmail($_POST['local_email'])->setLocalPhone($_POST['local_phone']);
}
$entry->update();
header('Location:admin.php?page=' . $_POST['return'] . '&action=view&id=' . $entry->getId());
exit;
}
if (isset($_POST['pride_action'])) {
if (wp_verify_nonce($_POST['_wpnonce'], 'pride-nonce')) {
if ($_POST['pride_action'] == 'cc') {
$parts = explode('-', $_POST['txid']);
if (count($parts) == 2) {
if (is_numeric($parts[1])) {
switch ($_POST['form']) {
case 'cruise':
$entry = new CruiseEntry($parts[1]);
$title = 'Pride Cruise';
break;
case 'festival':
$entry = new FestivalEntry($parts[1]);
$title = 'Pride Festival Entry';
break;
case 'murder_mystery':
$entry = new MurderMysteryEntry($parts[1]);
$title = 'Murder Mystery Ticket';
break;
case 'donation':
$entry = new Donation($parts[1]);
$title = 'Donation';
break;
case 'flag':
$entry = new FlagHandle($parts[1]);
$title = 'Flag Handle';
break;
case 'sponsorship':
$entry = new Sponsorship($parts[1]);
$title = 'Sponsorship';
break;
default:
/* 'parade' */
$entry = new ParadeEntry($parts[1]);
$title = 'Pride Parade Entry';
}
if ($entry->getCreatedAt() !== NULL && isset($_POST['stripeToken']) && strlen($_POST['stripeToken']) > 0) {
$stripe_keys = Entry::getStripeKeys();
Stripe::setApiKey($stripe_keys['secret']);
Stripe::setApiVersion('2016-03-07');
try {
/** @var \Stripe\Charge $charge */
$charge = Charge::create(array('amount' => round($entry->getAmountDue() * 100), 'currency' => 'usd', 'source' => $_POST['stripeToken'], 'description' => $entry->getEntryYear() . ' ' . $title));
$entry->setPaidAt(time())->setPaymentMethodId(Entry::PAYMENT_METHOD_CARD)->setPaymentAmount($entry->getAmountDue())->setPaymentConfirmationNumber($charge->id)->update();
header('Location:' . $_POST['_wp_http_referer']);
exit;
} catch (Card $e) {
/* card was declined */
//.........這裏部分代碼省略.........