You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
<?php
|
|
namespace app\common\payment;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use app\common\payment\BasePayment;
|
|
use app\common\payment\Ipayment;
|
|
|
|
//實作金流串接介面
|
|
class TappayCredit extends BasePayment implements Ipayment{
|
|
public function pay( $order ){
|
|
// tappay 後端串接, 使用guzzlehttp
|
|
$client = new Client();
|
|
$res = $client->request('POST', 'https://sandbox.tappaysdk.com/tpc/payment/pay-by-prime', [
|
|
'headers' => [
|
|
'Content-Type' => 'application/json',
|
|
'x-api-key' => 'partner_sp7XzLlfouHPF0iytyFcRo2v0rHk4kUO3VvoMw12DlHPXWtTqxODzE0Q',
|
|
],
|
|
'json' => [
|
|
'prime' => $order['prime'],
|
|
'partner_key' => 'partner_sp7XzLlfouHPF0iytyFcRo2v0rHk4kUO3VvoMw12DlHPXWtTqxODzE0Q',
|
|
'merchant_id' => 'waynehsu_CTBC',
|
|
'details' => 'TapPay Test',
|
|
'amount' => $order['amount'],
|
|
'order_number' => $order['sn'],
|
|
'cardholder' => [
|
|
'phone_number' => $order['phone'],
|
|
'name' => $order['name'],
|
|
'email' => $order['email'],
|
|
'zip_code' => $order['zip_code'],
|
|
],
|
|
'remember' => true,
|
|
],
|
|
]);
|
|
|
|
$result = json_decode($res->getBody(), true);
|
|
|
|
return ['code'=>200,'method'=>'post','data'=>$result];
|
|
}
|
|
|
|
public function response($data){
|
|
return ['code'=>200,'data'=>$data];
|
|
}
|
|
|
|
public function callback($data){
|
|
return ['code'=>200,'data'=>$data];
|
|
}
|
|
}
|