Changeset 6602 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/sponsor-payment-stripe.php
- Timestamp:
- 02/12/2018 05:39:50 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/sponsor-payment-stripe.php
r6601 r6602 5 5 6 6 namespace WordCamp\Budgets\Sponsor_Payment_Stripe; 7 use WordCamp\Utilities\Stripe_Client; 7 8 use WordCamp_Budgets; 9 use Exception; 8 10 9 11 defined( 'WPINC' ) or die(); … … 189 191 $wordcamp_site_url = set_url_scheme( esc_url_raw( get_blog_option( $wordcamp_site_id, 'home', '' ) ), 'https' ); 190 192 191 require_once( __DIR__ . '/stripe-php/init.php' ); 192 \Stripe\Stripe::setApiKey( $data['keys']['secret'] ); 193 $body = array( 194 'amount' => round( $payment_data['amount'], 2 ) * 100, 195 'currency' => $payment_data['currency'], 196 'source' => $_POST['stripeToken'], 197 'description' => 'WordCamp Sponsorship: ' . $wordcamp_obj->post_title, 198 'metadata' => array( 199 'invoice_id' => $payment_data['invoice_id'], 200 'wordcamp_id' => $payment_data['wordcamp_id'], 201 'wordcamp_site_id' => $wordcamp_site_id, 202 'wordcamp_url' => $wordcamp_site_url, 203 ), 204 ); 193 205 194 206 try { 195 $charge = \Stripe\Charge::create( array( 196 'amount' => round( $payment_data['amount'], 2 ) * 100, 197 'currency' => $payment_data['currency'], 198 'source' => $_POST['stripeToken'], 199 'description' => 'WordCamp Sponsorship: ' . $wordcamp_obj->post_title, 200 'metadata' => array( 201 'invoice_id' => $payment_data['invoice_id'], 202 'wordcamp_id' => $payment_data['wordcamp_id'], 203 'wordcamp_site_id' => $wordcamp_site_id, 204 'wordcamp_url' => $wordcamp_site_url, 205 ), 206 ) ); 207 } catch ( \Stripe\Error\Card $e ) { 208 $data['errors'][] = 'The card has been declined.'; 209 return; 210 } catch ( \Exception $e ) { 211 $data['errors'][] = 'An unknown error has occurred, please try again later.'; 207 $stripe = new Stripe_Client( $data['keys']['secret'] ); 208 $charge = $stripe->charge( $body ); 209 } catch ( Exception $exception ) { 210 $data['errors'][] = "An error occurred, please try another card. If that doesn't work, please contact ". EMAIL_CENTRAL_SUPPORT ."."; 212 211 return; 213 212 }
Note: See TracChangeset
for help on using the changeset viewer.