本文整理汇总了PHP中Stripe_Customer类的典型用法代码示例。如果您正苦于以下问题:PHP Stripe_Customer类的具体用法?PHP Stripe_Customer怎么用?PHP Stripe_Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stripe_Customer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Create and send the request
*
* @param array $options array of options to be send in POST request
* @return gateway_response response object
*
*/
public function send($options, $type = '')
{
$result = '';
try {
if ($type == 'subscription') {
$result = Stripe_Customer::create($options);
} elseif ($type == 'plan') {
$result = Stripe_Plan::create($options);
} elseif ($type == 'retrieve') {
$result = Stripe_Plan::retrieve($options);
} elseif ($type == 'customer') {
$result = Stripe_Customer::create($options);
} elseif ($type == 'invoice') {
$result = Stripe_InvoiceItem::create($options);
// Stripe_Customer::invoiceItems($options);
} elseif ($type == 'cancel') {
$cu = Stripe_Customer::retrieve($options['customer']);
$result = $cu->cancelSubscription();
} else {
$result = Stripe_Charge::create($options);
}
} catch (Exception $ex) {
$result = $ex;
}
$response = new stripe_response($result);
return $response;
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:34,代码来源:gateway-request.php
示例2: indexAction
public function indexAction(Request $request, $id)
{
// Vérifier que l'utilisateur a le droit de supprimer ce contrat
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
$request = $this->container->get('request');
$message = '';
if ($request->isMethod('POST')) {
\Stripe::setApiKey('sk_test_GyiB2fCxy62ydudovWhyyp6H');
$token = $request->get('stripeToken');
$customer = \Stripe_Customer::create(array('email' => '[email protected]', 'card' => $token));
$charge = \Stripe_Charge::create(array('customer' => $customer->id, 'amount' => 700, 'currency' => 'eur'));
return $this->redirectToRoute("app_front_office_resiliation_preview", array("id" => $id));
}
return $this->render('AppFrontOfficeBundle:Payment:index.html.twig', array("message" => $message));
}
开发者ID:skycri,项目名称:MyAbos,代码行数:16,代码来源:PaymentController.php
示例3: fwd_stripe_prepare
/**
* Prepare stripe data for processing.
*/
function fwd_stripe_prepare($data, $settings)
{
// Load stripe library?
if (!class_exists('Stripe')) {
require_once dirname(__FILE__) . '/stripe/lib/Stripe.php';
}
// Set API key.
Stripe::setApiKey($settings['secret_key']);
$order = get("/orders/{$data['order_id']}");
$stripe = $order['billing']['stripe'];
// Need to convert token to customer?
if ($stripe['object'] == "token") {
if ($stripe['used'] == 'true') {
throw new Exception('Stripe token already used');
}
$customer = Stripe_Customer::create(array('description' => $order['billing']['name'], 'card' => $stripe['id']));
$billing['stripe'] = $customer->__toArray(true);
$billing['card'] = $billing['stripe']['active_card'];
unset($billing['stripe']['active_card']);
// Update order.
put($order, array('billing' => $billing));
// Update account billing also?
if (($account_billing = $order['account']['billing']) && $account_billing['method'] == 'card' && $account_billing['stripe']['id'] == $stripe['id']) {
$account_billing['stripe'] = $billing['stripe'];
$account_billing['card'] = $billing['card'];
put($order['account'], array('billing' => $account_billing));
}
}
return $data;
}
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:33,代码来源:fwd-stripe.php
示例4: pay
/**
* @method POST
*/
function pay()
{
// get token
$token = Utilities::ValidateJWTToken(apache_request_headers());
// check if token is not null
if ($token != NULL) {
// parse request
parse_str($this->request->data, $request);
$site = Site::GetBySiteId($token->SiteId);
$siteId = $site['SiteId'];
$email = $site['PrimaryEmail'];
$status = 'Active';
$stripe_token = $request['token'];
$plan = $request['plan'];
// set API key
Stripe::setApiKey(STRIPE_SECRET_KEY);
// create a new customer and subscribe them to the plan
$customer = Stripe_Customer::create(array("card" => $stripe_token, "plan" => $plan, "email" => $email));
// get back the id and the end period for the plan
$id = $customer->id;
// get subscription information
$subscription = $customer->subscriptions->data[0];
$subscriptionId = $subscription->id;
$stripe_status = $subscription->status;
$stripe_plan = $subscription->plan->id;
$stripe_planname = $subscription->plan->name;
// subscribe to a plan
Site::Subscribe($siteId, $status, $plan, 'stripe', $subscriptionId, $customerId);
// return a json response
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:37,代码来源:pay.php
示例5: create
public function create()
{
if ($_POST) {
$customer = Stripe_Customer::create(array('email' => $_POST['email']));
foreach ($_POST as $key => $value) {
$_POST[$key] = urldecode($value);
}
include OTHERS . "PasswordHash.php";
$new_password = $_POST['password'];
$salt = $this->_get_random_string(16);
$hashed_password = create_hash($new_password . $salt);
$stateSplit = explode(' - ', $_POST['state']);
$key = $this->_get_random_string(50);
$user = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'password' => $hashed_password, 'salt' => $salt, 'phone' => $_POST['phone'], 'email' => $_POST['email'], 'country' => $_POST['country'], 'state' => $stateSplit[1], 'state_abbr' => $stateSplit[0], 'confirmation_key' => $key, 'stripe_customer_id' => $customer->id);
if (isset($_POST['reg_plan_id'])) {
$user['stripe_reg_plan_id'] = $_POST['reg_plan_id'];
} else {
$this->load->model('settings_model');
$general = transformArrayToKeyValue($this->settings_model->get(array('category' => 'general')));
$this->load->model('package_model');
$package = $this->package_model->getPackage($general['trial_period_package']->v);
$user['stripe_reg_plan_id'] = $package->stripe_plan_id;
}
if ($this->user_model->add($user)) {
echo "OK";
}
} else {
$this->index();
}
}
开发者ID:jrdncchr,项目名称:merlinleads,代码行数:30,代码来源:registration.php
示例6: UpdateExistingCustomer
/**
* Function to update the customerinformation with customer id
* Cases when card expired or new card.
* @param Tokne id users strip token id
* @param user id
* @param amount to charge
* @param description
*/
public function UpdateExistingCustomer($customerId, $token, $name, $amount, $description = "")
{
$this->setAPIKey();
$cu = Stripe_Customer::retrieve($customerId);
$rr = json_decode($cu, true);
//echo'<pre>';print_r($rr);echo'</pre>';die();
$r = $rr['error']['message'];
$error_code = $rr['error']['code'];
$error_type = $rr['error']['type'];
//echo $error_code.'------------'.$error_type.'<br />';
if (empty($error_type) && empty($error_code)) {
$cu->card = $token;
if (!empty($description)) {
$cu->description = $description;
}
$cu->save();
$result = Stripe_Charge::create(array("amount" => "{$amount}", "currency" => "usd", "customer" => "{$customerId}"));
if ($result['paid'] === true) {
$result_array = array("success" => "1");
return $result_array;
} else {
return $result;
}
} else {
$result_array = array("update" => "1");
return $result_array;
}
}
开发者ID:jacquesbagui,项目名称:ofuz,代码行数:36,代码来源:Stripe.class.php
示例7: pay
/**
* @method POST
*/
function pay()
{
// parse request
parse_str($this->request->data, $request);
$token = $request['token'];
$plan = $request['plan'];
// get an authuser
$authUser = new AuthUser();
if (isset($authUser->UserUniqId)) {
// check if authorized
Stripe::setApiKey(STRIPE_API_KEY);
// create a new customer and subscribe them to the plan
$customer = Stripe_Customer::create(array("card" => $token, "plan" => $plan, "email" => $authUser->Email));
// get back the id and the end period for the plan
$id = $customer->id;
$end = $customer->subscription->current_period_end;
// #debug print 'end='.$end;
date_default_timezone_set('UTC');
// create a date from the timestamp returned by Stripe
$renewalDate = gmdate("Y-m-d H:i:s", intval($end));
// #debug print ' renewalDate='.$renewalDate;
// by default, you should not have to update a payment
$updatePayment = 0;
// update the db and session
Site::SetSubscription($authUser->SiteUniqId, $plan, $id, $renewalDate, $updatePayment);
AuthUser::SetPlan($plan, $renewalDate, $updatePayment);
// return a json response
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
开发者ID:eavesmonkey,项目名称:respond,代码行数:35,代码来源:pay.php
示例8: updateSubscription
public static function updateSubscription($service, $customerId, $plan)
{
\Stripe::setApiKey($service['stripe']['secret_key']);
$customer = \Stripe_Customer::retrieve($customerId);
$customer->updateSubscription(array("plan" => $plan, "prorate" => true));
return ['id' => $customer->subscription->plan->id, 'name' => $customer->subscription->plan->name];
}
开发者ID:bigset1,项目名称:blueridge,代码行数:7,代码来源:Teller.php
示例9: email_transfer_failed
function email_transfer_failed($transfer)
{
$customer = Stripe_Customer::retrieve($transfer->customer);
$subject = 'Your transfer was failed';
$headers = 'From: "Brandbits Support" <[email protected]>';
mail($customer->email, $subject, message_body(), $headers);
}
开发者ID:sgh1986915,项目名称:stripe-webhook,代码行数:7,代码来源:webhook.php
示例10: pay
static function pay($currency)
{
global $wpdb, $user_ID, $user_email;
$_course = new NamasteLMSCourseModel();
$token = $_POST['stripeToken'];
$course = get_post($_POST['course_id']);
$fee = get_post_meta($course->ID, 'namaste_fee', true);
$fee = apply_filters('namaste-coupon-applied', $fee);
// coupon code from other plugin?
try {
$customer = Stripe_Customer::create(array('email' => $user_email, 'card' => $token));
$charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $fee * 100, 'currency' => $currency));
} catch (Exception $e) {
wp_die($e->getMessage());
}
// !!!!in the next version avoid this copy-paste
// almost the same code is in models/payment.php for the paypal payments
$wpdb->query($wpdb->prepare("INSERT INTO " . NAMASTE_PAYMENTS . " SET \n\t\t\t\t\t\tcourse_id=%d, user_id=%s, date=CURDATE(), amount=%s, status='completed', paycode=%s, paytype='stripe'", $_POST['course_id'], $user_ID, $fee, $token));
do_action('namaste-paid', $user_ID, $fee, "course", $_POST['course_id']);
// enroll accordingly to course settings - this will be placed in a method once we
// have more payment options
$enroll_mode = get_post_meta($course->ID, 'namaste_enroll_mode', true);
if (!NamasteLMSStudentModel::is_enrolled($user_ID, $course->ID)) {
$status = $enroll_mode == 'free' ? 'enrolled' : 'pending';
$_course->enroll($user_ID, $course->ID, $status);
}
}
开发者ID:Bnei-Baruch,项目名称:Namaste,代码行数:27,代码来源:stripe-model.php
示例11: confirm
public function confirm()
{
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$amount = (int) ($this->currency->format($order_info['total'], $order_info['currency_code'], 1.0, false) * 100);
//Load Stripe Library
require_once './vendor/stripe/stripe-php/lib/Stripe.php';
if ($this->config->get('stripe_payments_mode') == 'live') {
$stripe = array("secret_key" => $this->config->get('stripe_payments_private_key'), "publishable_key" => $this->config->get('stripe_payments_public_key'));
} else {
$stripe = array("secret_key" => $this->config->get('stripe_payments_private_key_test'), "publishable_key" => $this->config->get('stripe_payments_public_key_test'));
}
Stripe::setApiKey($stripe['secret_key']);
$token = $_POST['stripeToken'];
$error = null;
try {
$customer = Stripe_Customer::create(array('email' => $order_info['email'], 'card' => $token));
$charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $amount, 'currency' => $order_info['currency_code'], 'metadata' => array('order_id' => $this->session->data['order_id'], 'customer' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'], 'email' => $order_info['email'], 'phone' => $order_info['telephone']), 'description' => 'Order ID# ' . $this->session->data['order_id']));
} catch (Stripe_CardError $e) {
// Error card processing
$error = $e->jsonBody['error'];
}
//create object to use as json
$json = array();
//If successful log transaction in opencart system
if (!$error) {
$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('stripe_payments_order_status_id'));
$json['success'] = $this->url->link('checkout/success', '', 'SSL');
} else {
$json['error'] = (string) $error['message'];
$json['details'] = $error;
}
$this->response->setOutput(json_encode($json));
}
开发者ID:dsadinoff,项目名称:stripe-payments,代码行数:34,代码来源:stripe_payments.php
示例12: testUpcoming
public function testUpcoming()
{
authorizeFromEnv();
$c = Stripe_Customer::create(array('card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015)));
$invoice = Stripe_Invoice::upcoming(array('customer' => $c->id));
$this->assertEqual($invoice->customer, $c->id);
$this->assertEqual($invoice->attempted, false);
}
开发者ID:KillerDesigner,项目名称:OpenVBX-Plugin-Stripe,代码行数:8,代码来源:InvoiceTest.php
示例13: testUpdateDescriptionNull
public function testUpdateDescriptionNull()
{
$customer = self::createTestCustomer(array('description' => 'foo bar'));
$customer->description = NULL;
$customer->save();
$updatedCustomer = Stripe_Customer::retrieve($customer->id);
$this->assertEqual(NULL, $updatedCustomer->description);
}
开发者ID:JSpier,项目名称:smacamp,代码行数:8,代码来源:CustomerTest.php
示例14: saveUserPayment
public function saveUserPayment()
{
$payment_token = Input::get('stripeToken');
$owner_id = Session::get('user_id');
$owner_data = Owner::find($owner_id);
try {
if (Config::get('app.default_payment') == 'stripe') {
Stripe::setApiKey(Config::get('app.stripe_secret_key'));
$customer = Stripe_Customer::create(array("card" => $payment_token, "description" => $owner_data->email));
$last_four = substr(Input::get('number'), -4);
if ($customer) {
$customer_id = $customer->id;
$payment = new Payment();
$payment->owner_id = $owner_id;
$payment->customer_id = $customer_id;
$payment->last_four = $last_four;
$payment->card_token = $customer->cards->data[0]->id;
$payment->save();
$message = "Your Card is successfully added.";
$type = "success";
return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
} else {
$message = "Sorry something went wrong.";
$type = "danger";
return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
}
} else {
Braintree_Configuration::environment(Config::get('app.braintree_environment'));
Braintree_Configuration::merchantId(Config::get('app.braintree_merchant_id'));
Braintree_Configuration::publicKey(Config::get('app.braintree_public_key'));
Braintree_Configuration::privateKey(Config::get('app.braintree_private_key'));
$result = Braintree_Customer::create(array("firstName" => $owner_data->first_name, "lastName" => $owner_data->last_name, "creditCard" => array("number" => Input::get('number'), "expirationMonth" => Input::get('month'), "expirationYear" => Input::get('year'), "cvv" => Input::get('cvv'))));
Log::info('result = ' . print_r($result, true));
if ($result->success) {
$num = $result->customer->creditCards[0]->maskedNumber;
$last_four = substr($num, -4);
$customer_id = $result->customer->id;
$payment = new Payment();
$payment->owner_id = $owner_id;
$payment->customer_id = $customer_id;
$payment->last_four = $last_four;
$payment->card_token = $result->customer->creditCards[0]->token;
$payment->save();
$message = "Your Card is successfully added.";
$type = "success";
return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
} else {
$message = "Sorry something went wrong.";
$type = "danger";
return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
}
}
} catch (Exception $e) {
$message = "Sorry something went wrong.";
$type = "danger";
return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
}
}
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:58,代码来源:WebUserController.php
示例15: testSave
public function testSave()
{
$customer = self::createTestCustomer();
$customer->email = '[email protected]';
$customer->save();
$this->assertEqual($customer->email, '[email protected]');
$customer2 = Stripe_Customer::retrieve($customer->id);
$this->assertEqual($customer->email, $customer2->email);
}
开发者ID:lintonrentfro,项目名称:simpleconvention,代码行数:9,代码来源:CustomerTest.php
示例16: payForOrder
public function payForOrder($order)
{
// Create a new customer
$customer = \Stripe_Customer::create(array('email' => $order['customerEmail'], 'card' => $order['token']));
// Pay for order
$charge = \Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $order['price'] * 100, 'currency' => 'usd'));
// Return charge object
return array('chargeId' => $charge->id, 'customerId' => $customer->id);
}
开发者ID:hackathon-5,项目名称:power-ragers-repo,代码行数:9,代码来源:StripeController.php
示例17: testInvalidCredentials
public function testInvalidCredentials()
{
Stripe::setApiKey('invalid');
try {
Stripe_Customer::create();
} catch (Stripe_AuthenticationError $e) {
$this->assertEqual(401, $e->getHttpStatus());
}
}
开发者ID:JSpier,项目名称:smacamp,代码行数:9,代码来源:AuthenticationErrorTest.php
示例18: testInvalidObject
public function testInvalidObject()
{
self::authorizeFromEnv();
try {
Stripe_Customer::retrieve('invalid');
} catch (Stripe_InvalidRequestError $e) {
$this->assertEqual(404, $e->getHttpStatus());
}
}
开发者ID:pikepa,项目名称:fitfasnfab,代码行数:9,代码来源:InvalidRequestErrorTest.php
示例19: stripeSubscribeCustomer
function stripeSubscribeCustomer()
{
// set your secret key: remember to change this to your live secret key in production
// see your keys here https://manage.stripe.com/account
Stripe::setApiKey("mDZRJuHrjeG3sSKJdmumEZdbGtr1TLDW");
// get the credit card details submitted by the form
$token = $_POST['stripeToken'];
$customer = Stripe_Customer::create(array("card" => $token, "plan" => "gold", "email" => "[email protected]"));
}
开发者ID:rncrtr,项目名称:clscHTML,代码行数:9,代码来源:functions.php
示例20: stripeAction
public function stripeAction(Request $request)
{
$em = $this->getDoctrine()->getEntityManager();
$registerDetail = $em->createQueryBuilder()->select('SalonsolutionsUser')->from('SalonSolutionWebBundle:SalonsolutionsUser', 'SalonsolutionsUser')->addOrderBy('SalonsolutionsUser.id', 'DESC')->setMaxResults(1)->getQuery()->getResult();
$userId = $registerDetail[0]->id;
$firstName = $registerDetail[0]->firstName;
$email = $registerDetail[0]->email;
$em = $this->getDoctrine()->getEntityManager();
$salonDetail = $em->createQueryBuilder()->select('SalonsolutionsSalon')->from('SalonSolutionWebBundle:SalonsolutionsSalon', 'SalonsolutionsSalon')->addOrderBy('SalonsolutionsSalon.id', 'DESC')->setMaxResults(1)->getQuery()->getResult();
$salonId = $salonDetail[0]->id;
$request = $this->container->get('request');
$message = '';
if ($request->get('test')) {
Stripe::setApiKey('sk_test_ZPmfNFOUBUAY3YyiSSzUPMA8');
$token = $request->get('stripeToken');
$customer = \Stripe_Customer::create(array('email' => $email, 'card' => $token));
$charge = \Stripe_Charge::create(array('customer' => $customer->id, 'amount' => 1000, 'currency' => 'usd', 'description' => $email));
$customerId = $customer->id;
$customeremail = $customer->email;
$times = date_create();
$time = date_format($times, 'H:i:s');
$mydate = getdate(date("U"));
$date = $mydate['weekday'] . ',' . $mydate['month'] . ',' . $mydate['mday'] . ',' . $mydate['year'];
$message = 'Successfully Paid $10.00 !';
$em = $this->getDoctrine()->getEntityManager();
$confirmedPayment = $em->createQueryBuilder()->select('SalonsolutionsUser')->update('SalonSolutionWebBundle:SalonsolutionsUser', 'SalonsolutionsUser')->set('SalonsolutionsUser.status', ':status')->setParameter('status', '1')->where('SalonsolutionsUser.email = :email')->setParameter('email', $email)->getQuery()->getResult();
$Payment = new SalonsolutionsPayment();
$Payment->setUserId($userId);
$Payment->setSalonId($salonId);
$Payment->setTransactionId($customerId);
$Payment->setTransactionDate($date);
$Payment->setTransactionTime($time);
$Payment->setTransactionAmount('10');
$Payment->setPaymentMethodId('1');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($Payment);
$em->flush();
$employeeMessage = new SalonsolutionsEmployeeMessages();
$employeeMessage->setSalonOwnerId($userId);
$employeeMessage->setType("Employee Message");
$employeeMessage->setMessage("This is a message to be displayed on Employee Dashboard ");
$employeeMessage->setStatus('0');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($employeeMessage);
$em->flush();
$halfMessage = new SalonsolutionsEmployeeMessages();
$halfMessage->setSalonOwnerId($userId);
$halfMessage->setMessage("Offering Message");
$halfMessage->setMessage("HALF PRICE SPRAY TANS EVERY FRIDAY !!! ");
$halfMessage->setStatus('0');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($halfMessage);
$em->flush();
}
return $this->render('SalonSolutionWebBundle:Home:stripe.html.twig', array('message' => $message, 'firstName' => $firstName));
}
开发者ID:abhikalotra,项目名称:Salon-Solutions,代码行数:56,代码来源:WebController.php
注:本文中的Stripe_Customer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论