Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Payment sandbox mode #657

Closed
wants to merge 4 commits into from
Closed

Support Payment sandbox mode #657

wants to merge 4 commits into from

Conversation

skyred
Copy link
Contributor

@skyred skyred commented Apr 21, 2017

Following discussion from #507

This PR adds the feature. So, app user can set sandbox mode like this:

$app = new Application($options);
$wechat_pay = $app->payment;
$wechat_pay->enableSandbox(TRUE);

Another option to enable to sandbox can be in $option:

    $options = [
      // 前面的appid什么的也得保留哦
      'app_id' => $appid,
      // ...
      // payment
      'payment' => [
        'merchant_id'        => $mch_id,
        'key'                => $key,
        'cert_path'          => 'path/to/your/cert.pem', // XXX: 绝对路径!!!!
        'key_path'           => 'path/to/your/key',      // XXX: 绝对路径!!!!
        'notify_url'         => $payment_gateway_plugin->getNotifyUrl()->toString(),
         'device_info'     => '013467007045764',
         'sub_app_id'      => '',
         'sub_merchant_id' => '',
         'sandbox_mode' => TRUE,
        // ...
      ],
    ];

But, this PR does't include the second way. Further contribution is welcomed.

{
$this->merchant = $merchant;
if ($isSandboxMode == TRUE) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRUE -> true

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- if ($isSandboxMode == TRUE) {
+ if ($isSandboxMode) {

*
* @var string
*/
protected $sandboxMode = '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- protected $sandboxMode = '';
+ protected $prefix = '';

@skyred
Copy link
Contributor Author

skyred commented Apr 21, 2017

It looks like PaymentAPITest.php has failed. https://travis-ci.org/overtrue/wechat/jobs/224199863#L342

@overtrue
Copy link
Collaborator

image

@@ -240,7 +240,7 @@ public function testAuthCodeToOpenId()

$response = $api->authCodeToOpenId('authcode');

$this->assertEquals(API::API_AUTH_CODE_TO_OPENID, $response['api']);
$this->assertEqualsself::API_ENDPOINT . $this->prefix . API::API_AUTH_CODE_TO_OPENID, $response['api']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请在本地测试通过再提交,谢谢。

@skyred
Copy link
Contributor Author

skyred commented Apr 21, 2017

Let me close this PR, and do a clean one.

@skyred skyred closed this Apr 21, 2017
@mingyoung
Copy link
Collaborator

@skyred 沙箱模式的签名是不是要从微信服务器获取?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants