Stripe導入メモ

困った時はこちらで質問してください。回答を担当する人は特に決まっていませんので、分かる方は回答をお願いします。
アバター
DJB93B
記事: 2
登録日時: 2020/9/09 09:50

Stripe導入メモ

投稿記事by DJB93B » 2020/9/09 15:52

海外向け(国内含む)サイトを運営しておりますが、ある日突然PayPalアカウントが停止されてしまい
困った挙句、海外ではポピュラーな(実際のところはよく知りません)Stripe決済サービスを導入しました。

質問というよりも、導入メモです。

当方のバージョン1.51

Stripeのモジュールは以下からダウンロード
https://www.zen-cart.com/downloads.php?do=file&id=1548

このサイトの情報では、USAかカナダに銀行口座が無いと使えない風なことが書かれていますが
Stripeの日本語サイトで法人登録したのち、発行される公開キー、シークレットキーをコピペして
普通に使えるようになります。

ただし、インストールしてそのままだと支払いがUSDなので、ZENカート側もそれに合わせる必要があります。
言語に連動してUSDに切り替えるようにすれば、とりあえずこの問題は解決しそうですが
日本語にしたときに、金額が100倍(セント分、内部で100倍されてます)になってしまいました。

そこで、ここからは少々乱暴なのですが、以下のファイルの100倍しているところをすべて1倍に変更し
日本円でも何とか使える状態になっています。

!マークの行の右側、元のファイルでは数値が100、そこを全て1に変更しています

\includes\modules\payment\stripepay.php


-----------------------------------------------------------------

function before_process()
{
global $_POST, $order, $sendto, $currency, $charge,$db, $messageStack;
require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/stripepay/Stripe.php');
//Stripe get the test/production state
$secret_key = ((MODULE_PAYMENT_STRIPEPAY_TESTMODE == 'Test') ? MODULE_PAYMENT_STRIPEPAY_TESTING_SECRET_KEY : MODULE_PAYMENT_STRIPEPAY_MERCHANT_LIVE_SECRET_KEY);
Stripe::setApiKey($secret_key);
$error = '';
// get the credit card details submitted by the form
$token = $_POST['StripeToken'];
//existing customer
if (zen_not_null($_POST['StripeCustomerID'])) {
if ($token == 'NONE') {
//charge the customer on existing card
try {
$charge = Stripe_Charge::create(array(
//"amount" => ($order->info['total']) * 100, // amount in cents
//fimgirl fix for total
! "amount" =>floor(($order->info['total']) * 1),
"currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
"customer" => $_POST['StripeCustomerID']
));
}
catch (Exception $e) {
$error = $e->getMessage();
$messageStack->add_session('checkout_confirmation', $error . '<!-- [' . $this->code . '] -->', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL', true, false));
}
} //end use existing card
//start new card
//new card for the customer and he wants to save it (or we are not allowing the option do StripesaveCard==YES
elseif (zen_not_null($_POST['StripeSaveCard']) && ($_POST['StripeSaveCard'] == 'YES')) {
try {
//update the card for the customer
$cu = Stripe_Customer::retrieve($_POST['StripeCustomerID']);
$cu->source = $token;
$cu->save();
//charge the customer
$charge = Stripe_Charge::create(array(
//"amount" => ($order->info['total']) * 100, // amount in cents
//fimgirl fix for total
! "amount" =>floor(($order->info['total']) * 1),
"currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
"customer" => $_POST['StripeCustomerID']
));
}
catch (Exception $e) {
$error = $e->getMessage();
$messageStack->add_session('checkout_confirmation', $error . '<!-- [' . $this->code . '] -->', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL', true, false));
}
} //end save card
else {
//a saved customer has entered new card details but does NOT want them saved. Currently (Nov 2012) Stripe does not allow you to remove a card object so you'll have to charge the card and not the customer
try {
// create the charge on Stripe's servers - this will charge the user's card no customer object
$charge = Stripe_Charge::create(array(
// "amount" => ($order->info['total']) * 100, // amount in cents
//fimgirl fix for total
! "amount" =>floor(($order->info['total']) * 1),
"currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
"card" => $token,
"description" => $order->customer['email_address']
));
}
catch (Exception $e) {
$error = $e->getMessage();
$messageStack->add_session('checkout_confirmation', $error . '<!-- [' . $this->code . '] -->', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL', true, false));
}
}
} //end existing customer
//new customer wants to save card details
elseif (zen_not_null($_POST['StripeSaveCard']) && ($_POST['StripeSaveCard'] == 'YES')) {
//new customer create the object
try {
// create a Customer
$customer = Stripe_Customer::create(array(
"card" => $token,
"description" => $order->customer['email_address']
));
// charge the Customer instead of the card
$charge = Stripe_Charge::create(array(
// "amount" => ($order->info['total']) * 100, // amount in cents
//fimgirl fix for total
! "amount" =>floor(($order->info['total']) * 1),
"currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
"customer" => $customer->id
));
}

catch (Exception $e) {
$error = $e->getMessage();
$messageStack->add_session('checkout_confirmation', $error . '<!-- [' . $this->code . '] -->', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL', true, false));
}
}
// not a customer token
else {
try {
// create the charge on Stripe's servers - this will charge the user's card no customer object
$charge = Stripe_Charge::create(array(
// "amount" => ($order->info['total']) * 100, // amount in cents
//fimgirl fix for total
! "amount" =>floor(($order->info['total']) * 1),
"currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
"card" => $token,
"description" => $order->customer['email_address']
));
}
catch (Exception $e) {
$error = $e->getMessage();
$messageStack->add_session('checkout_confirmation', $error . '<!-- [' . $this->code . '] -->', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL', true, false));
}
} //end not a customer token
// die ( $charge);
return false;
}


-----------------------------------------------------------


円とドルを切り替えて使いたい場合、現状では上手く行っておりません。(当方勉強不足)

以上参考になれば幸いです。
アバター
DJB93B
記事: 2
登録日時: 2020/9/09 09:50

Stripe導入メモ

投稿記事by DJB93B » 2020/9/17 11:40

自己レスです

その後PayPalに問い合わせをして、私の会社のアカウントは再審査の結果、復活しました。

明らかに不当なアカウント停止に対しては、しっかりと主張することで再審査する事がわかりました。

で、停止されてあわててStripeを導入、結果としてはお客様の決済手段が増えたので、まあ良しとしましょう♪
アバター
adgroups
記事: 1
登録日時: 2020/12/12 14:02

Stripe導入メモ

投稿記事by adgroups » 2020/12/12 14:08

kash Dayal Groups The importance of user experience (Digital Marketing Course In Delhi), also known as user-friendliness, cannot be overemphasized when it comes to any website's success.
Why is digital marketing course in delhi Analysis so Important to Make Your Website Popular Among Competitors In simple terms, Website Designing Company In Noida is the overall experience you get when using or interacting with something. Having to analyze this can make you know how your visitors feel whenever they are exploring your website, making your website popular if you are doing the right thing and giving you an edge over your competitors.

A good Website Designing Company In Noida will allow your visitors to spend more time on your website and, with time increasing how often it appears in Google searches.

I will be sharing some of the reasons why Website Designing Company In Noida analysis is essential in making your website popular among your competitors, some of the ways you can achieve it, and its benefits. Visitors want a Seo Services In Gurgaon that gives room for quick navigation: Akash Dayal Groups Ability website designing company in noida to navigate or move from one point to another is essential in telling if a user has a good experience on a particular website or not. Someone with a not too good will not want to visit your site because all you need to get them to stick to you is their first 20 to 30 seconds. So while website designing always makes the navigation process very easy, it improves Digital Marketing Course In Delhi.

Design something that can make you get feedback from your visitors:
Having to get feedback from the visitors on your site will also let you know how you are doing compared to your competitors. With this feedback, you will see if you need to make some changes and when such changes are made, can you see any new effect in terms of edging your competitors. You can even ask them to suggest what they want you to improve on.

Doing that will make them see you as a listening firm and might want to relate with you based on it.
Akash Dayal Groups It helps your website ranking on Seo Services In Gurgaon engines:
This is so important because when people are satisfied with your website, they visit it, and the more it appears on Seo Services In Gurgaon search engines. With this more exposure, you can get more visitors, translating to more money for you than your competitors.

A Seo Services In Gurgaon with a well-structured layout and beautiful features will attract more visitors, and this could also give you an edge over your competitors. Aside from that, your page content should be attractive visually and easy to read—all these impacts on the seo services in gurgaon.

“Zen Cart 質問コーナー” へ戻る