2012-11-29 2 views
2

신용 카드 지불 기능을 통합하기 위해 card.io android sdk를 사용하고 있지만 단순히 카드 정보를 입력 한 다음 아무것도하지 말라고 카드 정보를 스캔하는 것을 허용하지 않습니다.Card.io는 신용 카드 스캔을 허용하지 않습니다

아래 코드는 내 코드

패키지 org.my.scanExample;

import io.card.payment.CardIOActivity; 
import io.card.payment.CreditCard; 
import org.my.scanExample.R; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

public class MyScanActivity extends Activity 
{ 
    // You MUST register with card.io to get an app token. Go to https://card.io/apps/new/ 
    private static final String MY_CARDIO_APP_TOKEN = "App_Token"; 

    final String TAG = getClass().getName(); 

    private Button scanButton; 
    private TextView resultTextView; 

    private int MY_SCAN_REQUEST_CODE = 100; // arbitrary int 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     resultTextView = (TextView)findViewById(R.id.resultTextView); 
     scanButton = (Button)findViewById(R.id.scanButton); 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 

     resultTextView.setText("card.io library version: " + CardIOActivity.sdkVersion() + "\nBuilt: " + CardIOActivity.sdkBuildDate()); 

     if (CardIOActivity.canReadCardWithCamera(this)) { 
      scanButton.setText("Scan a credit card with card.io"); 
     } 
     else { 
      scanButton.setText("Enter credit card information"); 
     } 
    } 

    public void onScanPress(View v) { 
     // This method is set up as an onClick handler in the layout xml 
     // e.g. android:onClick="onScanPress" 

     Intent scanIntent = new Intent(this, CardIOActivity.class); 

     // required for authentication with card.io 
     scanIntent.putExtra(CardIOActivity.EXTRA_APP_TOKEN, MY_CARDIO_APP_TOKEN); 

     // customize these values to suit your needs. 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: true 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_ZIP, false); // default: false 

     // hides the manual entry button 
     // if set, developers should provide their own manual entry mechanism in the app 
     scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false); // default: false 

     // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. 
     startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE); 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 

     String resultStr; 
     if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { 
      CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); 

      // Never log a raw card number. Avoid displaying it, but if necessary use getFormattedCardNumber() 
      resultStr = "Card Number: " + scanResult.getRedactedCardNumber() + "\n"; 

      // Do something with the raw number, e.g.: 
      // myService.setCardNumber(scanResult.cardNumber); 

      if (scanResult.isExpiryValid()) { 
       resultStr += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n"; 
      } 

      if (scanResult.cvv != null) { 
       // Never log or display a CVV 
       resultStr += "CVV has " + scanResult.cvv.length() + " digits.\n"; 
      } 

      if (scanResult.zip != null) { 
       resultStr += "Zip: " + scanResult.zip + "\n"; 
      } 
     } 
     else { 
      resultStr = "Scan was canceled."; 
     } 
     resultTextView.setText(resultStr); 

    } 
} 
+0

logcat에 힌트가 있습니까? (내 실제 앱 코드에서 https://www.card.io/accounts/register/developer에서 가져온 앱과 '내 앱 토큰'을 대체했다고 가정합니다. – tomwhipple

+0

아니요, logcat에서 예외가 없습니다. . 내 생성 된 응용 프로그램 토큰을 응용 프로그램에 넣었습니다. 한가지 더 궁금한 점은 무료 API인가 SDT 사용 요금인가하는 것입니다. –

+0

logcat에 붙여 넣을 수 있습니까? 예외가 기록되지 않아도 단서를 제공하는 다른 메시지가있을 수 있습니다. – tomwhipple

답변

0
private static final String MY_CARDIO_APP_TOKEN = "App_Token"; 

앱 토큰이 유효하지 않습니다. 유효한 토큰을 사용하십시오.