Class: Onepay::AlipayRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/onepay/request/alipay.rb

Constant Summary collapse

GATEWAY_URL =
'https://openapi.alipay.com/gateway.do?'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#order_idObject

Returns the value of attribute order_id.



8
9
10
# File 'lib/onepay/request/alipay.rb', line 8

def order_id
  @order_id
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/onepay/request/alipay.rb', line 8

def title
  @title
end

#total_feeObject

Returns the value of attribute total_fee.



8
9
10
# File 'lib/onepay/request/alipay.rb', line 8

def total_fee
  @total_fee
end

Instance Method Details

#urlObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/onepay/request/alipay.rb', line 10

def url
  alipay_client = Alipay::Client.new(
    url: GATEWAY_URL,
    app_id: Onepay.config['alipay']['app_id'],
    app_private_key: Onepay.config['alipay']['private_key'],
    alipay_public_key: Onepay.config['alipay']['public_key']
  )

  alipay_client.page_execute_url(
    method: 'alipay.trade.wap.pay',
    notify_url: Onepay.config['alipay']['notify_url'],
    biz_content: {
      out_trade_no: @order_id,
      product_code: 'QUICK_WAP_WAY',
      total_amount: @total_fee,
      subject: @title
    }.to_json,
    timestamp: Time.now.strftime('%Y-%m-%d %H:%M:%S')
  )
end