#xwtk-payments

1 messages ยท Page 1 of 1 (latest)

mossy wave
tacit skiff
#

Hey karllekko

mossy wave
#

@tacit skiff hi there! But yes, that's expected, for right now the links only support Cards, you need to integrate with the API to accept other methods.

tacit skiff
#

Ah I see now! Is it possible to do PHP-only integration?

#

(without frameworks)

#

and a bit confusing here, should I include the vendor/autoload.php?

mossy wave
#

what do you call a framework exactly?

you can use PHP, and if you do you should use our library(https://github.com/stripe/stripe-php), but that's not really a framework I would say.

mossy wave
mossy wave
#

there are ways to manually install/use the library instead, there's instructions on that github page

#

yes you don't have to use Slim if you don't want to

#

we used to use it in our examples but are trying to get rid of it since it just confuses people

tacit skiff
#

yeah but another question arises ๐Ÿ™‚

#

I am reading but like

#

I am sorry I just don't understand what I should do haha

mossy wave
tacit skiff
tacit skiff
#

alright @mossy wave so I installed Slim and Stripe-php

#

but now I get a Page Not Found

#

should I show part of my code?

mossy wave
#

you might want to hire a developer or stick with PaymentLinks or a third party integration overall.

For what it's worth I'd suggest not using Slim at all(not sure if it's in the example you're looking at, as I said we're trying to stop using it)

tacit skiff
#

Yeah its the example I was looking at in Accepting Payments

#

To prebuilt checkout

mossy wave
#

there are much easier ways to use Stripe, for example I'd just use Checkout

tacit skiff
#

Because custom checkout flow is really confusing for me right now so trying to figure out

tacit skiff
mossy wave
#
<?php

require '../vendor/autoload.php';

$key = "sk_test_xxxxx";

\Stripe\Stripe::setApiKey($key);

if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  echo 'Invalid request';
  exit;
}


$checkout_session = \Stripe\Checkout\Session::create([
  'success_url' => 'https://example.com/success.html?session_id={CHECKOUT_SESSION_ID}',
  'cancel_url' => 'https://example.com/canceled.html',
  'payment_method_types' => ["card"],
  'mode' => 'payment',
  'line_items' => [[
    'price_data' => [
      'currency' => 'usd',
      'product_data' => [
        'name' => 'T-shirt',
      ],
      'unit_amount' => 2000,
    ],
    'quantity' => 1,
  ]],
]);

header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);

?>

like something as simple as that can work

tacit skiff
#

Oh!

#

Oh this is RIGHT what I needed

#

How come I didn't find this

#

Also I can put customer email in the arguments right?

#

And set payment method types to auto

mossy wave
tacit skiff
#

got it

#

i do get the following error however

#

[Mon Jan 10 15:37:54.715631 2022] [proxy_fcgi:error] [pid 1321558:tid 139815563532032] [client 37.252.82.66:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught (Status 400) (Request req_mcAgLrV47v50ZJ) Received unknown parameter: automatic_payment_methods\n thrown in [redacted]/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38', referer: https://enterprise.xwtk.cloud/account/buy.php

mossy wave
#

try just removing that line entirely

#

I think you can just omit it and that implies automatic selection

#

automatic_payment_methods is for PaymentIntents too, not Checkout, so it's a different API, that's your confusion.

tacit skiff
#

ah I see

#

thank you so much for the help

#

will give an update in a min or 2

#

also a question about GPay and Apple Pay, how can I put them in the arguments? or it just automatically shows (I already enabled them in Stripe Payment Methods)

#

oh and also @mossy wave how can I enable automatic_tax parameter so its paid by the customer

#

because

    'enabled' => false,
    'status' => null,
  ]],

returns invalid parameter

mossy wave
tacit skiff
mossy wave
#

for that invalid parameter error, can you share the request ID req_xxx for the error so I can see what you're doing and take a quick look at your account set up? https://support.stripe.com/questions/finding-the-id-for-an-api-request

tacit skiff
#

even easier

#

just this

#

[Mon Jan 10 15:50:56.216206 2022] [proxy_fcgi:error] [pid 1321558:tid 139815496390400] [client 37.252.82.66:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught (Status 400) (Request req_Fm3wVKCpdIRMQB) Received unknown parameter: automatic_tax[0]\n thrown in [redacted]/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38', referer: https://enterprise.xwtk.cloud/account/buy.php

#

nevermind figured it out!

mossy wave
#

yeah I think you had too many [ ] if that was it

tacit skiff
#

yeah

#

and what about tax_behavior

#

putting 'tax_behavior' => 'exclusive', returns invalid parameter req_BHprFlTIfzWzaa

#

ah seems like it needs to be in price data

#

huh nope

#

still returns the same error @mossy wave

#

btw my price currency is USD but my bank is EUR, will stripe be able to do the conversion and payout to the EUR bank?

tacit skiff
#

great!

tacit skiff
#

should I send you the request ID?

#

or part of code

#
  'customer_email' => $_SESSION['user'],
  'success_url' => $success,
  'cancel_url' => 'https://enterprise.xwtk.cloud/account/buy.php?cancel',
  'payment_method_types' => ["card","wechat_pay"],
  'mode' => 'payment',
  'tax_behavior' => 'exclusive',
  'automatic_tax' => [
    'enabled' => true,
  ],
  'payment_method_options' => [
    'wechat_pay' => [
      'client' => "web"
    ],
  ],
  'line_items' => [[
    'price_data' => [
      'currency' => 'usd',
      'tax_behavior' => 'exclusive',
      'product_data' => [
        'name' => $_SESSION['product'],
      ],
      'unit_amount' => $price,
    ],
    'quantity' => 1,
  ]],
]);```
#

Request

req_ZMuEU1ld8GmXiC

mossy wave
#

you still have tax_behavior at the top level

tacit skiff
#

oh my god

#

i missed it xD

#

so sorry hahaha

#

@mossy wave

#

[Mon Jan 10 16:20:39.137032 2022] [proxy_fcgi:error] [pid 1321558:tid 139815588710144] [client 37.252.82.66:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught (Status 400) (Request req_C8wOGPAaQ7Sj4W) The currency provided (usd) is invalid for one or more payment method types on this Checkout Session. The payment method type wechat_pay only supports the following currencies: .\n thrown in /home/admin/web/enterprise.xwtk.cloud/public_html/account/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38', referer: https://enterprise.xwtk.cloud/account/buy.php

#

any ideas?

#

i removed alipay for this too but wechat seems to have USD

#

(alipay actually too)

grizzled olive
#

Hey, taking over from @mossy wave

#

Catching up

tacit skiff
#

hey!

#

so any ideas?

#

my website has all prices in USD

grizzled olive
#

Checking on some things as that error seems misleading

tacit skiff
#

sure

grizzled olive
tacit skiff
#

and about alipay?

grizzled olive
#

It's not enabled (or even offered) on your account

tacit skiff
#

yeah its not offered

grizzled olive
#

Do you have a specific error relating to Alipay?

tacit skiff
#

yeah one second

grizzled olive
tacit skiff
#

i dont know hahaha i thought wechat pay didnt need even to be enabled

#

[Mon Jan 10 16:02:36.011654 2022] [proxy_fcgi:error] [pid 1321558:tid 139815362205440] [client 37.252.82.66:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught (Status 400) (Request req_9CNdQwyeYVgrI8) Invalid currency options ``usd``. The payment method `alipay` only supports the following currencies: ``cny`, `eur``.\n thrown in /home/admin/web/enterprise.xwtk.cloud/public_html/account/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38', referer: https://enterprise.xwtk.cloud/account/buy.php

#

while

mossy wave
#

depending on business location like it says.

tacit skiff
#

ah hmm i see

mossy wave
#

in general Alipay/WeChat only work for CNY and your account's local currency(which is EUR for you if your account is in Greece), you can't charge in USD

tacit skiff
#

understood!

#

so no wechat and alipay haha

mossy wave
tacit skiff
#

thought it would be pretty great so absolutely everyone could pay but yeah

tacit skiff
#

it worked!

#

so many thanks to all you guys, I really appreciate all the help!

grizzled olive
#

Np!