/** * 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; }
public function charge(array $data) { try { return \Stripe_Charge::create(['amount' => '2000', 'currency' => 'usd', 'description' => $data['email'], 'card' => $data['token']]); } catch (Stripe_CardError $e) { dd('card was declined'); } }
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' => '*****@*****.**', '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)); }
function do_transaction($amount, $cc, $cvc, $exp_month, $exp_year, $name, $description, $payment_data) { $result = array(); $stripe_settings = get_option('event_espresso_stripe_settings'); //Check for an alternate Stripe settings if (isset($payment_data['event_meta']['stripe_secret_key']) && !empty($payment_data['event_meta']['stripe_secret_key'])) { //Alternate Stripe settings $secretKey = $payment_data['event_meta']['stripe_secret_key']; } else { $publishableKey = $stripe_settings['stripe_publishable_key']; $secretKey = $stripe_settings['stripe_secret_key']; } $currencySymbol = $stripe_settings['stripe_currency_symbol']; //$transactionPrefix = $stripe_settings['stripe_transaction_prefix']; Stripe::setApiKey($secretKey); $charge = "unknown"; try { $charge = Stripe_Charge::create(array("amount" => $amount * 100, "currency" => $currencySymbol, "card" => array("number" => $cc, "exp_month" => $exp_month, "exp_year" => $exp_year, "cvc" => $cvc, "name" => $name), "description" => $description)); $result["status"] = 1; $result["msg"] = "Transaction was completed successfully"; $result['txid'] = $charge->id; } catch (Exception $e) { $result["status"] = 0; $result["error_msg"] = "Failed to charge the card."; } return $result; }
public function testRetrieve() { authorizeFromEnv(); $c = Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015))); $d = Stripe_Charge::retrieve($c->id); $this->assertEqual($d->id, $c->id); }
public function process_payment($order_id) { error_reporting(0); $order = $this->api->getOrderByID($order_id); $this->load_config(); $sandbox = true; if ($this->m_config['STRIPE_SANDBOX']) { $sandbox = false; } $amount = $order->gross * 100; $currency = $order->currency; $cardnumber = str_replace(" ", "", $_POST['credit_card_number']); $cardname = $_POST['credit_card_name']; $cardtype = $_POST['credit_card_type']; $cvnnumber = $_POST['credit_card_cvn']; $expdate = $_POST['credit_card_exp_month'] . $_POST['credit_card_exp_year']; // API credentials only need to be defined once define("STRIPE_TEST_API_KEY", $this->m_config['STRIPE_TEST_API_KEY']); define("STRIPE_LIVE_API_KEY", $this->m_config['STRIPE_LIVE_API_KEY']); define("STRIPE_SANDBOX", $sandbox); if ($sandbox) { Stripe::setApiKey(STRIPE_TEST_API_KEY); } else { Stripe::setApiKey(STRIPE_LIVE_API_KEY); } $c = Stripe_Charge::create(array("amount" => $amount, "currency" => $order->currency, "card" => array('number' => $cardnumber, 'exp_month' => $_POST['credit_card_exp_month'], 'exp_year' => $_POST['credit_card_exp_year']), "description" => "Charge for " . $cardname), array("idempotency_key" => $_POST['idempotency_key'])); if ($c->paid) { $order->paid(); echo "<h2>Your payment was successfully processed. Thank you!</h2>"; echo "Success! Transaction ID:" . $c->receipt_number; } else { echo "<h2>Your card was declined.</h2>"; } }
protected function send_to_stripe() { global $woocommerce; // 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($this->secret_key); // Get the credit card details submitted by the form $data = $this->getRequestData(); // Create the charge on Stripe's servers - this will charge the user's card try { $charge = Stripe_Charge::create(array("amount" => $data['amount'], "currency" => $data['currency'], "card" => $data['token'], "description" => $data['card']['name'], "capture" => !$this->capture)); error_log(var_export($charge, 1)); $this->transactionId = $charge['id']; //Save data for the "Capture" update_post_meta($this->order->id, 'transaction_id', $this->transactionId); update_post_meta($this->order->id, 'key', $this->secret_key); update_post_meta($this->order->id, 'auth_capture', $this->capture); return true; } catch (Stripe_Error $e) { // The card has been declined, or other error $body = $e->getJsonBody(); $err = $body['error']; error_log('Stripe Error:' . $err['message'] . "\n"); if (function_exists('wc_add_notice')) { wc_add_notice($err['message'], $notice_type = 'error'); } else { $woocommerce->add_error(__('Payment error:', 'woothemes') . $err['message']); } return false; } }
public function charge() { $id = $this->inputfilter->clean($this->app->get('PARAMS.id'), 'alnum'); $request = $this->getModel()->setState('filter.id', $id)->getItem(); $settings = \Striper\Models\Settings::fetch(); // 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($settings->{$settings->mode . '.secret_key'}); // Get the credit card token submitted by the form $token = $this->inputfilter->clean($this->app->get('POST.stripeToken'), 'string'); // Create the charge on Stripe's servers - this will charge the user's card try { $charge = \Stripe_Charge::create(array("amount" => $request->amountForStripe(), "currency" => "usd", "card" => $token, "description" => $request->{'client.email'})); // this needs to be created empty in model $request->acceptPayment($charge); // SEND email to the client $request->sendChargeEmailClient($charge); $request->sendChargeEmailAdmin($charge); $this->app->set('charge', $charge); $this->app->set('paymentrequest', $request); $view = \Dsc\System::instance()->get('theme'); echo $view->render('Striper/Site/Views::paymentrequest/success.php'); } catch (\Stripe_CardError $e) { // The card has been declined $view = \Dsc\System::instance()->get('theme'); echo $view->render('Striper/Site/Views::paymentrequest/index.php'); } }
function put_charge($request_data) { // permission /*if(!$this->permission->check($request_data)) { return $this->permission->errorMessage(); };*/ /*// validation $this->filter->set_request_data($request_data); if(!$this->filter->run()) { $return["errors"] = $this->filter->get_errors('error'); return $return; } $request_data = $this->filter->get_request_data();*/ $request_data = $this->filter->run($request_data); if ($this->filter->hasErrors()) { return $this->filter->getErrorsReturn(); } $result = $this->db->select('customers', array('user_ID' => USER_ID)); if (!$result) { return array('errors' => array('strip-customer' => 'No customer ID')); } $customer = $this->db->fetch_assoc($result); $c = Stripe_Customer::retrieve($customer['stripeTokens']); $c->updateSubscription(array("plan" => "basic", "prorate" => true)); $charge = Stripe_Charge::create(array('customer' => $customer['stripeToken'], 'amount' => 5000, 'currency' => 'cad')); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request CreateCharge */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (is_array($model['card'])) { throw new LogicException('The token has already been used.'); } if (empty($model['card'])) { throw new LogicException('The token has to be set.'); } try { \Stripe::setApiKey($this->keys->getSecretKey()); $charge = \Stripe_Charge::create((array) $model); $model->replace($charge->__toArray(true)); } catch (\Stripe_CardError $e) { $model->replace($e->getJsonBody()); } }
public function processTransaction($data) { $log = Logger::getInstance(); $log->LogDebug("process transaction stripe - "); $result = new stdClass(); $result->status = PAYMENT_ERROR; $result->payment_status = PAYMENT_STATUS_FAILURE; Stripe::setApiKey($this->SECRET_KEY); $result->amount = $data->cost > 0 ? $data->cost : $data->total; $data->stripeToken = JRequest::getVar('stripeToken', null); $log->LogDebug("process transaction stripe - token - " . $data->stripeToken); try { if (!isset($data->stripeToken)) { $result->error_message = "There was an error in processing your request. Please try again later."; $log->LogDebug("The Stripe Token was not generated correctly"); } else { Stripe_Charge::create(array("amount" => $result->amount, "currency" => strtolower($data->reservationData->hotel->hotel_currency), "card" => $data->stripeToken)); $result->status = PAYMENT_SUCCESS; $result->payment_status = PAYMENT_STATUS_PAID; } } catch (Exception $e) { $log->LogDebug($e->getMessage()); $result->error_message = $e->getMessage(); } $result->transaction_id = 0; $result->payment_date = date("Y-m-d"); $result->response_code = 0; $result->confirmation_id = $data->confirmation_id; $result->processor_type = $this->type; return $result; }
public function processTransaction($data) { $log = Logger::getInstance(); $log->LogDebug("process transaction stripe - "); if ($_POST) { Stripe::setApiKey($this->SECRET_KEY); $error = ''; $success = ''; try { if (!isset($_POST['stripeToken'])) { throw new Exception("The Stripe Token was not generated correctly"); } Stripe_Charge::create(array("amount" => 1000, "currency" => "usd", "card" => $_POST['stripeToken'])); $success = 'Your payment was successful.'; } catch (Exception $e) { $error = $e->getMessage(); } } $log->LogDebug("process response authorize - " . serialize($response)); if (isset($response->approved) && $response->approved == 1) { $result->status = PAYMENT_SUCCESS; $result->payment_status = PAYMENT_STATUS_PAID; } else { $result->status = PAYMENT_ERROR; $result->payment_status = PAYMENT_STATUS_FAILURE; $result->error_message = $response->error_message; } $result->transaction_id = 0; $result->payment_date = date("Y-m-d"); $result->response_code = $response->approved; $result->confirmation_id = $data->confirmation_id; $result->processor_type = $this->type; return $result; }
/** * Payment callback function * * @param array $data * @return array */ public function callback($data = array()) { $data = $this->app->data->create($data); $id = (int) $data->get('order_id', null); if ($id) { $order = $this->app->zoocart->table->orders->get($id); } else { $order = $data->get('order', null); } // Check against frauds $isValid = $this->isValidIPN($data); if ($isValid) { try { $apiKey = $this->_getPrivateKey(); Stripe::setApiKey($apiKey); $params = array('amount' => $data['amount'], 'currency' => $data['currency'], 'card' => $data['token'], 'description' => $data['description']); $transaction = Stripe_Charge::create($params); } catch (Exception $e) { $isValid = false; $data['failure_reason'] = $e->getMessage(); } } if ($isValid && !empty($transaction['failure_message'])) { $isValid = false; $data['failure_reason'] = "Stripe failure: " . $transaction['failure_message']; } if (!$isValid) { $status = 0; } else { $status = $transaction['paid'] ? 1 : 0; } return array('status' => $status, 'transaction_id' => !empty($transaction) ? $transaction['balance_transaction'] : '', 'order_id' => $order->id, 'total' => $order->total); }
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)); }
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); } }
public function testCreateForBitcoin() { self::authorizeFromEnv(); $receiver = $this->createTestBitcoinReceiver("*****@*****.**"); $charge = Stripe_Charge::create(array("amount" => $receiver->amount, "currency" => $receiver->currency, "description" => $receiver->description, 'source' => $receiver->id)); $ref = $charge->refunds->create(array('amount' => $receiver->amount, 'refund_address' => 'ABCDEF')); $this->assertEqual($receiver->amount, $ref->amount); $this->assertNotNull($ref->id); }
public function markAsSafe() { self::authorizeFromEnv(); $card = array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015); $charge = Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => $card)); $charge->markAsSafe(); $updatedCharge = Stripe_Charge::retrieve($charge->id); $this->assertEqual('safe', $updatedCharge['fraud_details']['user_report']); }
public function testBadData() { self::authorizeFromEnv(); try { Stripe_Charge::create(); } catch (Stripe_InvalidRequestError $e) { $this->assertEqual(400, $e->getHttpStatus()); } }
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); }
public function testUpdateMetadataAll() { authorizeFromEnv(); $charge = Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015))); $charge->metadata = array('test' => 'foo bar'); $charge->save(); $updatedCharge = Stripe_Charge::retrieve($charge->id); $this->assertEqual('foo bar', $updatedCharge->metadata['test']); }
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)); }
function runStripe() { require_once 'Stripe/lib/Stripe.php'; Stripe::setApiKey("sk_test_ZPmfNFOUBUAY3YyiSSzUPMA8"); //Stripe::setApiKey("sk_test_76rvqe8M1VH2uCa1sjVfL0Au"); $charge = Stripe_Charge::create(array("amount" => 1500, "currency" => "usd", "card" => $_POST['stripeToken'], "description" => "Charge for Facebook Login code.")); //echo "<pre>"; print_r($charge); die; //send the file, this line will be reached if no error was thrown above return "<h1>Your payment has been completed. We will send you the Facebook Login code in a minute.</h1>"; }
function submit_payment() { $this->_check_auth(); Stripe::setApiKey('cKBoVlAfDLHAIKtDkWbbY3Lg8sz1Y0bO'); $token = $this->input->post('stripeToken'); $charge = Stripe_Charge::create(array("amount" => 500, "currency" => "usd", "card" => $token, "description" => "*****@*****.**")); $userId = $this->session->userdata('user_id'); $this->load->model('billing'); $this->billing->update(TRUE, $userId); redirect('checkout/thank_you', 'refresh'); }
public function testDecline() { authorizeFromEnv(); try { Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4000000000000002', 'exp_month' => '3', 'exp_year' => '2020'))); } catch (Stripe_CardError $e) { $this->assertEqual(402, $e->getHttpStatus()); $body = $e->getJsonBody(); $this->assertTrue($body['error']); } }
public function indexAction() { $request = $this->container->get('request'); $message = ''; if ($request->get('test')) { \Stripe::setApiKey('pk_test_ur0ebwOGBrsNzQrpdCNENIu4'); $token = $request->get('stripeToken'); $customer = \Stripe_Customer::create(array('email' => '*****@*****.**', 'card' => $token)); $charge = \Stripe_Charge::create(array('customer' => $customer->id, 'amount' => 5000, 'currency' => 'usd')); $message = '<h1>Successfully charged $50.00!</h1>'; } return $this->render('AcmeTestBundle:Default:index.html.twig', array('message' => $message)); }
public function capture(Varien_Object $payment, $amount) { $order = $payment->getOrder(); $billingAddress = $order->getBillingAddress(); try { $charge = Stripe_Charge::create(array('amount' => $amount * 100, 'currency' => strtolower($order->getBaseCurrencyCode()), 'card' => array('number' => $payment->getCcNumber(), 'exp_month' => sprintf('%02d', $payment->getCcExpMonth()), 'exp_year' => $payment->getCcExpYear(), 'cvc' => $payment->getCcCid(), 'name' => $billingAddress->getName(), 'address_line1' => $billingAddress->getStreet(1), 'address_line2' => $billingAddress->getStreet(2), 'address_zip' => $billingAddress->getPostcode(), 'address_state' => $billingAddress->getRegion(), 'address_country' => $billingAddress->getCountry()), 'description' => sprintf('#%s, %s', $order->getIncrementId(), $order->getCustomerEmail()))); } catch (Exception $e) { $this->debugData($e->getMessage()); Mage::throwException(Mage::helper('foggyline_sprite')->__('Payment capturing error.')); } $payment->setTransactionId($charge->id)->setIsTransactionClosed(0); return $this; }
public function stripeAction() { $request = $this->container->get('request'); $message = ''; if ($request->get('test')) { \Stripe\Stripe::setApiKey('sk_test_ZPmfNFOUBUAY3YyiSSzUPMA8'); $token = $request->get('stripeToken'); $customer = \Stripe_Customer::create(array('email' => '*****@*****.**', 'card' => $token)); $charge = \Stripe_Charge::create(array('customer' => $customer->id, 'amount' => 5000, 'currency' => 'usd')); $message = '<h1>Successfully charged $50.00!</h1>'; } return $this->render('TestTestBundle:Page:stripe.html.twig', array('message' => $message)); }
/** * @phutil-external-symbol class Stripe_Charge */ protected function executeCharge(PhortunePaymentMethod $method, PhortuneCharge $charge) { $root = dirname(phutil_get_library_root('phabricator')); require_once $root . '/externals/stripe-php/lib/Stripe.php'; $secret_key = $this->getSecretKey(); $params = array('amount' => $charge->getAmountInCents(), 'currency' => 'usd', 'customer' => $method->getMetadataValue('stripe.customerID'), 'description' => $charge->getPHID(), 'capture' => true); $stripe_charge = Stripe_Charge::create($params, $secret_key); $id = $stripe_charge->id; if (!$id) { throw new Exception('Stripe charge call did not return an ID!'); } $charge->setMetadataValue('stripe.chargeID', $id); }
/** * Create Charge using Stripe PHP Library * * @param $amount int transaction amount in cents (i.e. $1 = '100') * @param $card string * @param $description string * @return array * * @since 1.0 * */ function wp_stripe_charge($amount, $card, $name, $description) { $options = get_option('wp_stripe_options'); $currency = $options['stripe_currency']; /* * Card - Token from stripe.js is provided (not individual card elements) */ $charge = array('card' => $card, 'amount' => $amount, 'currency' => $currency); if ($description) { $charge['description'] = $description; } $response = Stripe_Charge::create($charge); return $response; }
/** * Create Charge using Stripe PHP Library * * @param $amount int transaction amount in cents (i.e. $1 = '100') * @param $card string * @param $description string * @return array * * @since 1.0 * */ function wp_stripe_charge($amount, $card, $name, $description) { /* * Currency - All amounts must be denominated in USD when creating charges with Stripe — the currency conversion happens automatically */ $currency = 'usd'; /* * Card - Token from stripe.js is provided (not individual card elements) */ $charge = array('card' => $card, 'amount' => $amount, 'currency' => $currency); if ($description) { $charge['description'] = $description; } $response = Stripe_Charge::create($charge); return $response; }