#Nugax

1 messages · Page 1 of 1 (latest)

calm spindleBOT
sturdy vessel
#

Hi, how can we help?

#

@kind vault please continue here

kind vault
#

oh sorry

#

didnt see this

#

trying to write a program to manage credit cards

#

in stripe accounts

#

for my program

#

have this code, Get_Customer_Cards, but it doesnt seem to return a list

#

the key is fine but it doesnt return the list as it should. maybe something changed in stripe?

sturdy vessel
kind vault
#

I dont know let me try

#

i changed the code and the last thing printed is the Secret Key from this line:

#

print("SK: $secretkey");

#

I dont know why it fails at the Client Setup

#

I can add new clients to Stripe using the add customer API

#

or maybe not.

#

...

#

that didnt work either. it was adding clients

sturdy vessel
#

Okie, do you see your request on Dashboard request log?

kind vault
#

in stripe?

sturdy vessel
#

Yes

kind vault
#

where do i look

#

I dont see anything

#

in the dashboard

sturdy vessel
#

If you print $card_list do you see anything?

kind vault
#

something is wrong with the client initalization i think

#

it wont even add a customer anymore. It used to. Its giving a ERROR 500 Internal Server error now

#

when i try to create a customer in stripe

sturdy vessel
#

that sounds like a completely different issue

kind vault
#

could be the same issue if its not even creating the client

#

which is why no API calls are making it to the dashboard

#

//Create Stripe Customer Account
function Create_Stripe_Customer($customer_name, $customer_email, $customer_phone, $customer_id) {
//Set Customer Stripe Key
$key = $_SESSION["stripe_secret_key"];
//Set The Object For Client
$stripe = new \Stripe\StripeClient($key);

//Set Variables
$date_time = CreateDate();
$customer_description = "Created By KarateMonkey | $date_time | AccountID: $customer_id";

//Create The Customer
$cust_obj = $stripe->customers->create([
    'name'        => $customer_name,
    'description' => $customer_description,
    'email'       => $customer_email,
    'phone'       => $customer_phone,
]);

//Set Customer ID That Is Returned From Stripe
$customer_stripe_id = $cust_obj["id"];

//Return Customer Stripe ID (IfSet)
if (isset($customer_stripe_id)) {
    return $customer_stripe_id;
}
else {
    //Return 0 if no customer ID
    return 0;
}

}

#

That is supposed to create the stripe customer

#

but it returns an error 500

#

is it ok to make this call for each page? $stripe = new \Stripe\StripeClient($key);

sturdy vessel
#

You sure you have variable on $key? This part

$key = $_SESSION["stripe_secret_key"]
kind vault
#

i should but I can output it

#

//Create Stripe Customer Account
function Create_Stripe_Customer($customer_name, $customer_email, $customer_phone, $customer_id) {
//Set Customer Stripe Key
$key = $_SESSION["stripe_secret_key"];
print("Key: $key");
//Set The Object For Client
$stripe = new \Stripe\StripeClient($key);

//Set Variables
$date_time = CreateDate();
$customer_description = "Created By KarateMonkey | $date_time | AccountID: $customer_id";

//Create The Customer
$cust_obj = $stripe->customers->create([
    'name'        => $customer_name,
    'description' => $customer_description,
    'email'       => $customer_email,
    'phone'       => $customer_phone,
]);

//Set Customer ID That Is Returned From Stripe
$customer_stripe_id = $cust_obj["id"];

//Return Customer Stripe ID (IfSet)
if (isset($customer_stripe_id)) {
    return $customer_stripe_id;
}
else {
    //Return 0 if no customer ID
    return 0;
}

}

#

in stripe dashboard, im not even seening a failed api attempt in the log

#

under developers

#

oh wait....

#

im supposed to have a VENDOR dir

#

correct?

#

tahts the issue!

#

crap

#

Yep that fixed it

#

I had re-cloned my git library and forgot to move the vendor dir from home dir back to the apache html hosting dir for it to load stripe library! I knew it was something like that.

#

its creating customers now

sturdy vessel
#

Glad to hear you figured it out!

kind vault
#

lets see if we can get the wallet to work

#

so what I want to do is just be able to add a card

#

thats it.

#

well first return list of cards, second add a card!

#

but i cant get the wallet stuff to work

#

ok

#

got the list working

#

the last issue i have with the wallet

#

is my add card button doesnt work.

#

What stripe method would I use if I just created a page to grab card details myself?

sturdy vessel
#

You would want to use a SetupIntent

kind vault
#

do you have an example code?

#

i see in the log when I use the $session = \Stripe\Checkout\Session::create([

#

it tries to start it, but it never displays the page to add the card info

#

it logs it though

#

so maybe i just need to collect the card info myself and send it to stripe using a method

#

I dont understand how to use SetupIntent

#

Where do I provide card info? number, exp, ccb?

#

ccv?

sturdy vessel
#

You can use a CheckoutSession with setup mode

#

It will collect the card without doing a charge

#

and then you will have the card info insde the PaymentMethod, inside the SetupIntet which is collected by the CheckoutSession

kind vault
#

thats what I had, but it doesnt prompt anymore

#

and this is the JS i have

#

<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe('<?= $publish_key ?>');

var checkoutButton = document.getElementById('checkout-button');

checkoutButton.addEventListener('click', function() {
    stripe.redirectToCheckout({
        // Make the id field from the Checkout Session creation API response
        // available to this file, so you can provide it as argument here
        // instead of the {{CHECKOUT_SESSION_ID}} placeholder.
        sessionId: '<?= $session->id ?>'
    }).then(function (result) {
        // If `redirectToCheckout` fails due to a browser or network
        // error, display the localized error message to your customer
        // using `result.error.message`.
        alert(result.error.message);
    });
});
sturdy vessel
#

Okie but on which part it "doesn't prompt anymore"? Do you see a Checkout Session cs_xxx created on your backend?

kind vault
#

yes

#

but it used to load a form you could fill in

#

and it doenst load anything now

#

so I dont know how to actually collect the informatioon to add it

sturdy vessel
#

Not sure which form? I see you have a $session->id and use redirectToCheckout on it

kind vault
#

"id": "cs_live_c1bG5xA5gyYzWvthMIDnAeQlyPhUECscs5LLYCTnyNCqx1mYt32Yhjs5Mk",

#

like that

#

how do i use redirectToCheckout

#

oh thats what i did

sturdy vessel
#

There are 2 potential issues here

  1. redirectToCheckout is a legacy method, you should just perfrom redirection serverside
  2. That's a Live mode Checkout Session. You should test everything on Test mode before

Besides, your code should still work

kind vault
#

sure it doesnt matter those, ill blow this account up latger on

#

its for testing anyhow

kind vault
#

How do I do server side redirection

sturdy vessel
#

It's just to take the Checkout Session url, and do a redirection

#

depends on which language