저는 CodeIgniter에 전자 상거래 사이트를 구축했으며 원활한 페이팔 통합을 수행했습니다.
내 사냥을 할 때 객체 지향적 인 wrapper가 보이지 않았지만 좋은 시도를 보았습니다.
내 솔루션은 약간 개성이있었습니다. 여기에서 PHP API를 다운로드 : https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PHP_NVP_Samples.zip
내가 application/helpers/paypal_helper.php
로 CallerService.php
파일을 저장하고 응용 프로그램으로 당겨 application/config/autoload.php
에 추가.
이제 CallerService.php
에 constants.php
이 필요하므로 복사하여 붙여 넣거나 helpers 디렉토리에 constants.php
파일을 포함시켜야합니다. 방금 복사하고 붙여 넣었습니다. 그런 다음 계정에 대한 모든 상수를 구성해야합니다.
$nvp_query_string = '&PAYMENTACTION=Sale'
. '&AMT='.urlencode($order->total)
. '&CREDITCARDTYPE='.urlencode($this->input->post('credit_card_type'))
. '&ACCT='.urlencode($this->input->post('acct'))
. '&EXPDATE='.urlencode(str_pad($this->input->post('exp_date_month'), 2, '0', STR_PAD_LEFT).'20'.$this->input->post('exp_date_year'))
. '&CVV2='.urlencode($this->input->post('cvv2_number'))
. '&FIRSTNAME='.urlencode($first_name)
. '&LASTNAME='.urlencode($last_name)
. '&STREET='.urlencode($order->billing_address_1)
. '&CITY='.urlencode($order->billing_city)
. '&STATE='.urlencode($order->billing_state)
. '&ZIP='.urlencode($order->billing_zip)
. '&COUNTRYCODE=US&CURRENCYCODE=USD';
$response = hash_call('doDirectPayment', $nvp_query_string);
if (strpos(strtoupper($response['ACK']), 'SUCCESS') !== false) {
// Product purchase was successful.
}
else {
// Product purchase was unsuccessful.
// The Paypal response will be in $response['ACK'].
// The Paypal error message to show the customer will be in $response['L_LONGMESSAGE0'].
}
그것은 너무 우아한 아니지만, 확실히 잘 작동한다 : 즉이 설정 일단
는
, 내 코드는이처럼 보였다.
또한 SSL 인증서가 필요합니다. 단일 도메인의 경우 30 달러 정도면 구입할 수 있습니다. 처음에는 설치하기가 다소 어려우나이 단계를 건너 뛸 수는 없습니다. SSL은 고객의 컴퓨터와 서버 사이의 전송을 보호하므로 모든 서버와 라우터를 통과 할 때 CC 정보를 읽을 수 없습니다 (또는 Wi-Fi를 통해 스니핑 됨). 따라서 양식에 CC 정보를 사용하는 경우 양식이 https : //로 제출되고 보안되지 않은 http : //가 아닌지 확인하십시오.
감사합니다. Alan! 이것이 내가 생각한 것입니다.이 생각에서 시작해서 미래의 CI 프로젝트에서 사용할 수있는 멋진 래퍼 라이브러리를 만드는 것이 많은 도움이 될 것입니다. 다른 도움말/힌트/할 일이없는 경우 알려 주시기 바랍니다. – Obaid