original_string: public function charge(InvoicePayment $payment)
      {
          // Make a charge through Stripe
          try {
              $charge = Charge::create([
                  // Multiply by 100 as Stripe charges in pence.
                  'amount' => $payment->amount * 100,
                  'currency' => 'gbp',
                  'description' => 'Invoice payment',
                  'metadata' => [
                      'invoice_id' => $payment->invoice->id
                  ],
                  'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'],
              ]);
  
              // Add Stripe payment ID to invoice payment
              $payment->payment_id = $charge->id;
  
              $responseMeta = new InvoicePaymentMetadata();
              $responseMeta->key = 'GATEWAY_RESPONSE';
              $responseMeta->value = $charge->status;
              $payment->metadata()->save($responseMeta);
  
              $payment->save();
  
              return true;
  
          } catch(Card $cardError) {
  
              $payment->payment_id = $cardError->getJsonBody()['error']['charge'];
              $responseMeta = new InvoicePaymentMetadata();
              $responseMeta->key = 'GATEWAY_RESPONSE';
              $responseMeta->value = $cardError->getMessage();
              $payment->metadata()->save($responseMeta);
              $payment->save();
  
              return false;
          }
      }
code: public function charge(InvoicePayment $payment)
      {
          // Make a charge through Stripe
          try {
              $charge = Charge::create([
                  // Multiply by 100 as Stripe charges in pence.
                  'amount' => $payment->amount * 100,
                  'currency' => 'gbp',
                  'description' => 'Invoice payment',
                  'metadata' => [
                      'invoice_id' => $payment->invoice->id
                  ],
                  'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'],
              ]);
  
              // Add Stripe payment ID to invoice payment
              $payment->payment_id = $charge->id;
  
              $responseMeta = new InvoicePaymentMetadata();
              $responseMeta->key = 'GATEWAY_RESPONSE';
              $responseMeta->value = $charge->status;
              $payment->metadata()->save($responseMeta);
  
              $payment->save();
  
              return true;
  
          } catch(Card $cardError) {
  
              $payment->payment_id = $cardError->getJsonBody()['error']['charge'];
              $responseMeta = new InvoicePaymentMetadata();
              $responseMeta->key = 'GATEWAY_RESPONSE';
              $responseMeta->value = $cardError->getMessage();
              $payment->metadata()->save($responseMeta);
              $payment->save();
  
              return false;
          }
      }
code_tokens: public function charge ( InvoicePayment $ payment ) { // Make a charge through Stripe try { $ charge = Charge :: create ( [ // Multiply by 100 as Stripe charges in pence. 'amount' => $ payment -> amount * 100 , 'currency' => 'gbp' , 'description' => 'Invoice payment' , 'metadata' => [ 'invoice_id' => $ payment -> invoice -> id ] , 'source' => $ payment -> getPreCommitMetadataArray ( ) [ 'STRIPE_TOKEN' ] , ] ) ; // Add Stripe payment ID to invoice payment $ payment -> payment_id = $ charge -> id ; $ responseMeta = new InvoicePaymentMetadata ( ) ; $ responseMeta -> key = 'GATEWAY_RESPONSE' ; $ responseMeta -> value = $ charge -> status ; $ payment -> metadata ( ) -> save ( $ responseMeta ) ; $ payment -> save ( ) ; return true ; } catch ( Card $ cardError ) { $ payment -> payment_id = $ cardError -> getJsonBody ( ) [ 'error' ] [ 'charge' ] ; $ responseMeta = new InvoicePaymentMetadata ( ) ; $ responseMeta -> key = 'GATEWAY_RESPONSE' ; $ responseMeta -> value = $ cardError -> getMessage ( ) ; $ payment -> metadata ( ) -> save ( $ responseMeta ) ; $ payment -> save ( ) ; return false ; } }
docstring: Make a charge using Stripe.
  
  @param InvoicePayment $payment
  @return bool Whether or not the charge succeeded
docstring_tokens: Make a charge using Stripe .