Welcome! Log In Create A New Profile

Advanced

[PHP] Basic Stripe PHP question

Posted by [email protected] 
Hi all,

I am starting to work with Credit card processing and stripe

I am working with their documentation...

https://stripe.com/docs/api#create_charge

The code below will create a charge...

Stripe Basic PHP question:

from the example below... How do I display on the page, the result of the active charge just created in php?

Q: is there some return response variable that I can echo in php?

---

<?php
require_once('./config.php');

$token = $_POST['stripeToken'];

$customer = \Stripe\Customer::create(array(
'email' => '[email protected] <mailto:[email protected]>',
'card' => $token
));

$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));

echo ??VAR??? - ??????? how can I show the return response variable ;
?>


--
Thanks,
Dave - DealTek
dealtek@gmail.com
[db-17]
Jigar Dhulla
Re: [PHP] Basic Stripe PHP question
September 23, 2017 03:20PM
On Sat, Sep 23, 2017 at 1:42 AM, dealtek@gmail.com <[email protected]>
wrote:

> Hi all,
>
> I am starting to work with Credit card processing and stripe
>
> I am working with their documentation...
>
> https://stripe.com/docs/api#create_charge
>
> The code below will create a charge...
>
> Stripe Basic PHP question:
>
> from the example below... How do I display on the page, the result of the
> active charge just created in php?
>
> Q: is there some return response variable that I can echo in php?
>
> ---
>
> <?php
> require_once('./config.php');
>
> $token = $_POST['stripeToken'];
>
> $customer = \Stripe\Customer::create(array(
> 'email' => '[email protected] <mailto:[email protected]>',
> 'card' => $token
> ));
>
> $charge = \Stripe\Charge::create(array(
> 'customer' => $customer->id,
> 'amount' => 5000,
> 'currency' => 'usd'
> ));
>
> echo ??VAR??? - ??????? how can I show the return response variable ;
> ?>
>
>
> --
> Thanks,
> Dave - DealTek
> dealtek@gmail.com
> [db-17]
>
> ​Hi Dave,

Looks like you are using Stripe's PHP Library (
https://github.com/stripe/stripe-php)

Looking at Basic Example (
https://github.com/stripe/stripe-php#getting-started)​

You should "echo $charge;"



--
Regards,
Jigar Dhulla
Unknown Business
Re: [PHP] Basic Stripe PHP question
September 23, 2017 03:50PM
Hi!

You can take a look at LaciCloud's source code for an easy example:
https://github.com/lacicloud/LaciCloud/blob/master/www/developers/localweb/pay.php

On Fri, Sep 22, 2017 at 10:12 PM, dealtek@gmail.com <[email protected]>
wrote:

> Hi all,
>
> I am starting to work with Credit card processing and stripe
>
> I am working with their documentation...
>
> https://stripe.com/docs/api#create_charge
>
> The code below will create a charge...
>
> Stripe Basic PHP question:
>
> from the example below... How do I display on the page, the result of the
> active charge just created in php?
>
> Q: is there some return response variable that I can echo in php?
>
> ---
>
> <?php
> require_once('./config.php');
>
> $token = $_POST['stripeToken'];
>
> $customer = \Stripe\Customer::create(array(
> 'email' => '[email protected] <mailto:[email protected]>',
> 'card' => $token
> ));
>
> $charge = \Stripe\Charge::create(array(
> 'customer' => $customer->id,
> 'amount' => 5000,
> 'currency' => 'usd'
> ));
>
> echo ??VAR??? - ??????? how can I show the return response variable ;
> ?>
>
>
> --
> Thanks,
> Dave - DealTek
> dealtek@gmail.com
> [db-17]
>
>
Sorry, only registered users may post in this forum.

Click here to login