tappay_ruby 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +69 -0
 - data/lib/tappay/credit_card/pay.rb +0 -1
 - data/lib/tappay/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 42349c6d543ca1fa3a3bf6ead0e0f6eb9f281c80b28d35811058d2661d084f10
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 82da8ed41bed6cfa50845bf8d9751fb796e8c2373e7978c9e60d35d560c2ccb8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bfd22c013a32a3aa5c13bc28c84d94e21f49cdaf71657b6f7cf39e2c0240cff23fe61db6b396ccbb02cdf0571802318689b022bc796e4253ea799bc3837c1898
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4878db49a06c88e21fc6a5affa06eed404bf2a90feaaa82921824ad27a280977caafe05d945765a43ca21cba41dba78bf52d6bd7cbdf8d59706a62207accacc3
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -52,13 +52,40 @@ Tappay.configure do |config| 
     | 
|
| 
       52 
52 
     | 
    
         
             
              # Common settings
         
     | 
| 
       53 
53 
     | 
    
         
             
              config.partner_key = 'your_partner_key'.freeze
         
     | 
| 
       54 
54 
     | 
    
         
             
              config.app_id = 'your_app_id'.freeze
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              # Merchant settings (use either merchant_id or merchant_group_id, not both)
         
     | 
| 
       55 
57 
     | 
    
         
             
              config.merchant_id = 'your_merchant_id'.freeze
         
     | 
| 
      
 58 
     | 
    
         
            +
              # OR
         
     | 
| 
      
 59 
     | 
    
         
            +
              config.merchant_group_id = 'your_merchant_group_id'.freeze
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       56 
61 
     | 
    
         
             
              config.instalment_merchant_id = 'your_instalment_merchant_id'.freeze
         
     | 
| 
       57 
62 
     | 
    
         
             
              config.currency = 'TWD'.freeze
         
     | 
| 
       58 
63 
     | 
    
         
             
              config.vat_number = 'your_vat_number'.freeze
         
     | 
| 
       59 
64 
     | 
    
         
             
            end
         
     | 
| 
       60 
65 
     | 
    
         
             
            ```
         
     | 
| 
       61 
66 
     | 
    
         | 
| 
      
 67 
     | 
    
         
            +
            ### Merchant ID Configuration
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            The gem supports two types of merchant identification:
         
     | 
| 
      
 70 
     | 
    
         
            +
            1. `merchant_id`: Individual merchant ID
         
     | 
| 
      
 71 
     | 
    
         
            +
            2. `merchant_group_id`: Group merchant ID
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            Important rules:
         
     | 
| 
      
 74 
     | 
    
         
            +
            - You can set either `merchant_id` or `merchant_group_id` in the configuration, but not both
         
     | 
| 
      
 75 
     | 
    
         
            +
            - When making a payment, you can override the configured merchant ID by providing either `merchant_id` or `merchant_group_id` in the payment options
         
     | 
| 
      
 76 
     | 
    
         
            +
            - If you provide merchant ID in the payment options, it will take precedence over any configuration
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            Example of overriding merchant ID in payment:
         
     | 
| 
      
 79 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 80 
     | 
    
         
            +
            # Using merchant_group_id in payment options
         
     | 
| 
      
 81 
     | 
    
         
            +
            result = Tappay::CreditCard::Pay.by_prime(
         
     | 
| 
      
 82 
     | 
    
         
            +
              prime: 'prime_from_tappay_sdk',
         
     | 
| 
      
 83 
     | 
    
         
            +
              amount: 100,
         
     | 
| 
      
 84 
     | 
    
         
            +
              merchant_group_id: 'group_123',  # This will be used instead of configured merchant_id
         
     | 
| 
      
 85 
     | 
    
         
            +
              order_number: 'ORDER-123'
         
     | 
| 
      
 86 
     | 
    
         
            +
            )
         
     | 
| 
      
 87 
     | 
    
         
            +
            ```
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
       62 
89 
     | 
    
         
             
            ### 2. Using Environment Variables
         
     | 
| 
       63 
90 
     | 
    
         | 
| 
       64 
91 
     | 
    
         
             
            For better security, you can use environment variables:
         
     | 
| 
         @@ -138,6 +165,38 @@ result = Tappay::CreditCard::Pay.by_prime( 
     | 
|
| 
       138 
165 
     | 
    
         | 
| 
       139 
166 
     | 
    
         
             
            Both approaches are valid and will work the same way. The CardHolder object provides a more structured way to handle cardholder information and includes validation.
         
     | 
| 
       140 
167 
     | 
    
         | 
| 
      
 168 
     | 
    
         
            +
            ## Payment URL
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            When processing payments, the API response may include a `payment_url` field. This URL is used for redirecting users to complete their payment in scenarios such as:
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
            - 3D Secure verification
         
     | 
| 
      
 173 
     | 
    
         
            +
            - LINE Pay payment page
         
     | 
| 
      
 174 
     | 
    
         
            +
            - JKO Pay payment page
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
            Note: payment_url is not supported for:
         
     | 
| 
      
 177 
     | 
    
         
            +
            - Apple Pay
         
     | 
| 
      
 178 
     | 
    
         
            +
            - Google Pay
         
     | 
| 
      
 179 
     | 
    
         
            +
            - Samsung Pay
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
            Example of handling payment URL in response:
         
     | 
| 
      
 182 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 183 
     | 
    
         
            +
            result = Tappay::CreditCard::Pay.by_prime(
         
     | 
| 
      
 184 
     | 
    
         
            +
              prime: 'prime_from_tappay_sdk',
         
     | 
| 
      
 185 
     | 
    
         
            +
              amount: 100,
         
     | 
| 
      
 186 
     | 
    
         
            +
              order_number: 'ORDER-123'
         
     | 
| 
      
 187 
     | 
    
         
            +
            )
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            if result['status'] == 0
         
     | 
| 
      
 190 
     | 
    
         
            +
              if result['payment_url']
         
     | 
| 
      
 191 
     | 
    
         
            +
                # Redirect user to payment page for:
         
     | 
| 
      
 192 
     | 
    
         
            +
                # - 3D Secure verification
         
     | 
| 
      
 193 
     | 
    
         
            +
                # - LINE Pay payment
         
     | 
| 
      
 194 
     | 
    
         
            +
                # - JKO Pay payment
         
     | 
| 
      
 195 
     | 
    
         
            +
                redirect_to result['payment_url']
         
     | 
| 
      
 196 
     | 
    
         
            +
              end
         
     | 
| 
      
 197 
     | 
    
         
            +
            end
         
     | 
| 
      
 198 
     | 
    
         
            +
            ```
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
       141 
200 
     | 
    
         
             
            ## Usage
         
     | 
| 
       142 
201 
     | 
    
         | 
| 
       143 
202 
     | 
    
         
             
            ### Pay by Prime
         
     | 
| 
         @@ -165,6 +224,11 @@ if result['status'] == 0 
     | 
|
| 
       165 
224 
     | 
    
         
             
                card_token = result['card_secret']['card_token']
         
     | 
| 
       166 
225 
     | 
    
         
             
                # Store card_key and card_token securely for future payments
         
     | 
| 
       167 
226 
     | 
    
         
             
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
              
         
     | 
| 
      
 228 
     | 
    
         
            +
              # Handle payment URL if present (for 3D Secure, LINE Pay, JKO Pay)
         
     | 
| 
      
 229 
     | 
    
         
            +
              if result['payment_url']
         
     | 
| 
      
 230 
     | 
    
         
            +
                redirect_to result['payment_url']
         
     | 
| 
      
 231 
     | 
    
         
            +
              end
         
     | 
| 
       168 
232 
     | 
    
         
             
            end
         
     | 
| 
       169 
233 
     | 
    
         
             
            ```
         
     | 
| 
       170 
234 
     | 
    
         | 
| 
         @@ -213,6 +277,11 @@ begin 
     | 
|
| 
       213 
277 
     | 
    
         
             
                number_of_instalments = instalment_info['number_of_instalments']
         
     | 
| 
       214 
278 
     | 
    
         
             
                first_payment = instalment_info['first_payment']
         
     | 
| 
       215 
279 
     | 
    
         
             
                each_payment = instalment_info['each_payment']
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                # Handle payment URL if present (for 3D Secure)
         
     | 
| 
      
 282 
     | 
    
         
            +
                if result['payment_url']
         
     | 
| 
      
 283 
     | 
    
         
            +
                  redirect_to result['payment_url']
         
     | 
| 
      
 284 
     | 
    
         
            +
                end
         
     | 
| 
       216 
285 
     | 
    
         
             
              end
         
     | 
| 
       217 
286 
     | 
    
         
             
            rescue Tappay::PaymentError => e
         
     | 
| 
       218 
287 
     | 
    
         
             
              # Handle payment error
         
     | 
    
        data/lib/tappay/version.rb
    CHANGED