Sử dụng WebPay trong thanh toán trực tuyến

  1. Webpay Customer
    • Update Customer Information
        webpay = WebPay.new("test_secret")
        webpay.customer.update(description: "Update desctiption", id: "cus_1ufaE11QX1Oc")
- Response
    <WebPay::CustomerResponse
      id: "cus_1ufaE11QX1Oc"
      object: "customer"
      livemode: false
      created: 1461295810
      email: nil
      description: "Update description"
      active_card: <WebPay::CardResponse
        object: "card"
        exp_year: 2021
        exp_month: 4
        fingerprint: "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7"
        name: "KEI KUBO"
        country: "JP"
        type: "Visa"
        cvc_check: "pass"
        last4: "4242"
      >
      recursions: []
    >
- Delete `Customer Information`
        webpay = WebPay.new("test_secret")
        webpay.customer.delete(id: "cus_1ufaE11QX1Oc1JE")
    <WebPay::CustomerResponse
      id: "cus_1GDcXwe3u3he411"
      object: "customer"
      livemode: false
      created: 1461295810
      email: nil
      description: "Awesome Customer"
      active_card: <WebPay::CardResponse
        object: "card"
        exp_year: 2021
        exp_month: 4
        fingerprint: "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7"
        name: "KEI KUBO"
        country: "JP"
        type: "Visa"
        cvc_check: "pass"
        last4: "4242"
      >
      recursions: []
    >
- Get `Customer List`
    webpay = WebPay.new("test_secret")
    webpay.customer.all(count: 3)
    #<WebPay::CustomerResponseList
      object: "list"
      url: "/v1/customers"
      count: 3
      data: [
        #<WebPay::CustomerResponse
          id: "cus_1GDcXwe3u3he411"
          object: "customer"
          livemode: false
          created: 1461295810
          email: nil
          description: "Awesome Customer"
          active_card: #<WebPay::CardResponse
            object: "card"
            exp_year: 2021
            exp_month: 4
            fingerprint: "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7"
            name: "KEI KUBO"
            country: "JP"
            type: "Visa"
            cvc_check: "pass"
            last4: "4242"
          >
          recursions: []
        >
      ]
    >
  1. WebPay Charge
    • Được định nghĩa trong function
     webpay.charge.create()
 ví dụ:
     webpay = WebPay.new("test_secret")
     webpay.charge.create(
       amount: 10000,
       currency: "jpy",
       card: "tok_SampleCardToken",
       description: nil
     )
     #<WebPay::ChargeResponse
      id: "ch_1q78in60y1QR64G"
      object: "charge"
      livemode: false
      currency: "jpy"
      description: nil
      amount: 400
      amount_refunded: 0
      customer: nil
      recursion: nil
      created: 1461031804
      paid: true
      refunded: false
      failure_message: nil
      card: #<WebPay::CardResponse
          object: "card"
          exp_year: 2018
          exp_month: 8
          fingerprint: "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7"
          name: "TARO YAMADA"
          country: "JP"
          type: "Visa"
          cvc_check: "pass"
          last4: "4242"
      >
      captured: true
      expire_time: nil
      fees: [#<WebPay::ChargeFeeResponse
          object: "fee"
          transaction_type: "payment"
          transaction_fee: 0
          rate: 3.25
          amount: 13
          created: 1461031804
      >]
    >
- Get `Charge Informations`
    + Được định nghĩa trong function
    webpay.charge.retrieve({CHARGE_ID})
Ví dụ
    webpay = WebPay.new("test_secret")
    webpay.charge.retrieve("ch_1q78in60y1QR64G")
    #<WebPay::ChargeResponse
      id: "ch_1q78in60y1QR64G"
      object: "charge"
      livemode: false
      currency: "jpy"
      description: nil
      amount: 400
      amount_refunded: 0
      customer: nil
      recursion: nil
      created: 1461031804
      paid: true
      refunded: false
      failure_message: nil
      card: #<WebPay::CardResponse
            object: "card"
            exp_year: 2018
            exp_month: 8
            fingerprint: "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7"
            name: "TARO YAMADA"
            country: "JP"
            type: "Visa"
            cvc_check: "pass"
            last4: "4242"
      >
      captured: true
      expire_time: nil
      fees: [#<WebPay::ChargeFeeResponse
            object: "fee"
            transaction_type: "payment"
            transaction_fee: 0
            rate: 3.25
            amount: 13
            created: 1461031804
      >]
    >
- Ý nghĩa các "Object"<br>
Property Child Property Model Value of explain
id string start to ch_. This is unique of string
object object object value is "charge"
livemode boolean true is production environment
false is test environment
amount integer This is price
This is charge Unit of One yen(¥)
card hash(bring dictionary) billing of Credit Card information value is hash
object string Value is "card"
exp_year integer
exp_month integer
fingerprint string This is key of unique by CreditCard.
name string This is Name of CreditCard
country string country code Currently
type string This is Card Brand(Visa, MasterCard,
American Express, Discover, JCB, Diners Club or "unknown")
cvc_check string check of security code pass or fail or unchecked
last4 string last 4 number of CreditCard
created timestamp created at
currency string ISO code name (for example japan is : jpy)
paid boolean Securing lines of credit
If Provisional sales or Actual sales
success : true failed sales : false
captured boolean uuid - string uuid of RFC 4122 (default null)finish of sales : true
not finish of sales : false
refunded boolean Billing is refund : true
Billing is not refund : false
amount_refunded integer Refunded of price. Unit of yen
customer string customer ID
shop string Shop ID
recursion string Regular purchases ID
description string This is unique of charge object.
If you manage user, when you will
implement add e-mail and user id for tracking,
This is so good
failure_message string failure detail message of charge,
in case failed charge
expire_time timestamp Unix time of provisional account sales
fees array(inclued of hash) List of Commission
object string value is fee
transaction_type string How do occur commission to transaction payment or refund
transaction_fee integer occur commission by each transaction. This is unit of yen
rate Percentage of commission
amount integer price of commission
created timestamp create at
uuid string uuid of RFC 4122 (default null)

All Rights Reserved