and / w1-api
W1 API
v0.5
2015-01-18 17:37 UTC
Requires
- php: >=5.4.0
- symfony/validator: ~2.3.3
This package is auto-updated.
Last update: 2024-09-09 03:59:52 UTC
README
工作流程由两步组成
- 将用户重定向到 W1 支付页面
- 检查支付
以下是每个步骤的代码示例
第1步
$api = new W1\PaymentAPI('merchantId', 'secretKey'); echo $api->getFormHTMLDocument($api->createPaymentForm() ->setPaymentId(uniqid()) ->setCultureId('ru' == $this->getLastLocale() ? W1\Form\PaymentForm::LANG_RU : W1\Form\PaymentForm::LANG_EN ) ->setAmount(2.99) ->setCurrencyId(W1\Form\PaymentForm::CURRENCY_USD) ->setDescription('Оплата за что-то') ->setSuccessUrl($this->get_page_url('buy_method_w1_callback')) // to redirect user ->setFailUrl($this->get_page_url('')) // to redirect user
第2步
$api = new W1\PaymentAPI('merchantId', 'secretKey'); if (!empty($_POST)) { if (!$api->createPaymentForm()->isPaymentAccepted($_POST)) { $this->logger()->log_exception('Error:W1', 'Wrong confirmation: ' . json_encode($_POST), __FILE__, __LINE__); echo $api->getRetryResponse('Wrong confirmation'); } else { $this->buy_dlc_finalize(); echo $api->getSuccessResponse(); } } else $this->redirect_to_relative('buy_method_w1');
就是这样!你太棒了! :)