【发布时间】:2016-12-31 07:13:11
【问题描述】:
您好,我创建了一个 PHP 脚本,它能够在 Paypal 中创建重复配置文件,但会产生一些问题
-> 如果将来客户卡将过期或发生某些事情,或者我没有按周期收到付款,应该通知 url。
下面我提到了我用来创建 Paypal 定期配置文件的代码
` function Do_direct_payment()
{
$DPFields = array(
'paymentaction' => $this->input->post('paymentType'), // How you want to obtain payment. Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. Sale indicates that this is a final sale for which you are requesting payment. Default is Sale.
'ipaddress' => $_SERVER['REMOTE_ADDR'], // Required. IP address of the payer's browser.
'returnfmfdetails' => '1' // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0.
);
$ProfileDetails = array(
'subscribername' => 'shakti', // Full name of the person receiving the product or service paid for by the recurring payment. 32 char max.
'profilestartdate' => '2016-08-24T18:29:50.588Z',
'profileenddate' => '2016-08-26T18:29:50.588Z', // Required. The date when the billing for this profile begins. Must be a valid date in UTC/GMT format.
'profilereference' => '' // The merchant's own unique invoice number or reference ID. 127 char max.
);
$ScheduleDetails = array(
'desc' => 'this is first recurring payment for testing', // Required. Description of the recurring payment. This field must match the corresponding billing agreement description included in SetExpressCheckout.
'maxfailedpayments' => '', // The number of scheduled payment periods that can fail before the profile is automatically suspended.
'autobilloutamt' => '' // This field indicates whether you would like PayPal to automatically bill the outstanding balance amount in the next billing cycle. Values can be: NoAutoBill or AddToNextBilling
);
$BillingPeriod = array(
'trialbillingperiod' => '',
'trialbillingfrequency' => '',
'trialtotalbillingcycles' => '',
'trialamt' => '100',
'billingperiod' => 'Day', // Required. Unit for billing during this subscription period. One of the following: Day, Week, SemiMonth, Month, Year
'billingfrequency' => '1', // Required. Number of billing periods that make up one billing cycle. The combination of billing freq. and billing period must be less than or equal to one year.
'totalbillingcycles' => '3', // the number of billing cycles for the payment period (regular or trial). For trial period it must be greater than 0. For regular payments 0 means indefinite...until canceled.
'amt' => '1000', // Required. Billing amount for each billing cycle during the payment period. This does not include shipping and tax.
'currencycode' => 'USD', // Required. Three-letter currency code.
'shippingamt' => '', // Shipping amount for each billing cycle during the payment period.
'taxamt' => '' // Tax amount for each billing cycle during the payment period.
);
$ActivationDetails = array(
'initamt' => '', // Initial non-recurring payment amount due immediatly upon profile creation. Use an initial amount for enrolment or set-up fees.
'failedinitamtaction' => '', // By default, PayPal will suspend the pending profile in the event that the initial payment fails. You can override this. Values are: ContinueOnFailure or CancelOnFailure
);
$CCDetails = array(
'creditcardtype' => $this->input->post('creditCardType'), // Required. Type of credit card. Visa, MasterCard, Discover, Amex, Maestro, Solo. If Maestro or Solo, the currency code must be GBP. In addition, either start date or issue number must be specified.
'acct' => $this->input->post('creditCardNumber'), // Required. Credit card number. No spaces or punctuation.
'expdate' => $this->input->post('expDateMonth').$this->input->post('expDateYear'), // Required. Credit card expiration date. Format is MMYYYY
'cvv2' => $this->input->post('cvv2Number'), // Requirements determined by your PayPal account settings. Security digits for credit card.
'startdate' => '', // Month and year that Maestro or Solo card was issued. MMYYYY
'issuenumber' => '' // Issue number of Maestro or Solo card. Two numeric digits max.
);
$PayerInfo = array(
'email' => $this->input->post('email'), // Email address of payer.
'payerid' => '', // Unique PayPal customer ID for payer.
'payerstatus' => '', // Status of payer. Values are verified or unverified
'business' => 'Testers, LLC' // Payer's business name.
);
$PayerName = array(
'salutation' => 'Mr.', // Payer's salutation. 20 char max.
'firstname' => $this->input->post('firstName'), // Payer's first name. 25 char max.
'middlename' =>$this->input->post('lastName'), // Payer's middle name. 25 char max.
'lastname' => $this->input->post('lastName'), // Payer's last name. 25 char max.
'suffix' => '' // Payer's suffix. 12 char max.
);
$BillingAddress = array(
'street' => '123 Test Ave.', // Required. First street address.
'street2' => '', // Second street address.
'city' => $this->input->post('city'), // Required. Name of City.
'state' => $this->input->post('state'), // Required. Name of State or Province.
'countrycode' => $this->input->post('country'), // Required. Country code.
'zip' => $this->input->post('zip'), // Required. Postal code of payer.
'phonenum' => $this->input->post('phone') // Phone Number of payer. 20 char max.
);
$ShippingAddress = array(
'shiptoname' => 'Tester Testerson', // Required if shipping is included. Person's name associated with this address. 32 char max.
'shiptostreet' => '123 Test Ave.', // Required if shipping is included. First street address. 100 char max.
'shiptostreet2' => '', // Second street address. 100 char max.
'shiptocity' => 'Kansas City', // Required if shipping is included. Name of city. 40 char max.
'shiptostate' => 'MO', // Required if shipping is included. Name of state or province. 40 char max.
'shiptozip' => '64111', // Required if shipping is included. Postal code of shipping address. 20 char max.
'shiptocountry' => 'US', // Required if shipping is included. Country code of shipping address. 2 char max.
'shiptophonenum' => '555-555-5555' // Phone number for shipping address. 20 char max.
);
$PaymentDetails = array(
'amt' => $this->input->post('amount') , // Required. Total amount of order, including shipping, handling, and tax.
'currencycode' => 'USD', // Required. Three-letter currency code. Default is USD.
'itemamt' => '95.00', // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax.
'shippingamt' => '5.00', // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt.
'shipdiscamt' => '', // Shipping discount for the order, specified as a negative number.
'handlingamt' => '', // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt.
'taxamt' => '', // Required if you specify itemized cart tax details. Sum of tax for all items on the order. Total sales tax.
'desc' => 'Web Order', // Description of the order the customer is purchasing. 127 char max.
'custom' => '', // Free-form field for your own use. 256 char max.
'invnum' => '', // Your own invoice or tracking number
'notifyurl' => $this->input->post('notifyURL') // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use.
);
$OrderItems = array();
$Item = array(
'l_name' => 'Test Widget 123', // Item Name. 127 char max.
'l_desc' => 'The best test widget on the planet!', // Item description. 127 char max.
'l_amt' => '95.00', // Cost of individual item.
'l_number' => '123', // Item Number. 127 char max.
'l_qty' => '1', // Item quantity. Must be any positive integer.
'l_taxamt' => '', // Item's sales tax amount.
'l_ebayitemnumber' => '', // eBay auction number of item.
'l_ebayitemauctiontxnid' => '', // eBay transaction ID of purchased item.
'l_ebayitemorderid' => '' // eBay order ID for the item.
);
array_push($OrderItems, $Item);
$Secure3D = array(
'authstatus3d' => '',
'mpivendor3ds' => '',
'cavv' => '',
'eci3ds' => '',
'xid' => ''
);
$PayPalRequestData = array(
'DPFields' => $DPFields,
'ProfileDetails' => $ProfileDetails,
'ScheduleDetails' => $ScheduleDetails,
'BillingPeriod' => $BillingPeriod,
'ActivationDetails' => $ActivationDetails,
'CCDetails' => $CCDetails,
'PayerInfo' => $PayerInfo,
'PayerName' => $PayerName,
'BillingAddress' => $BillingAddress,
'ShippingAddress' => $ShippingAddress,
'PaymentDetails' => $PaymentDetails,
'OrderItems' => $OrderItems,
'Secure3D' => $Secure3D
);
$PayPalResult = $this->paypal_pro->CreateRecurringPaymentsProfile($PayPalRequestData);
/*$CRPPFields = array(
'token' => '', // Token returned from PayPal SetExpressCheckout. Can also use token returned from SetCustomerBillingAgreement.
'softdescriptor' => '', // Information that is usually displayed in the account holder's statement. 23 char max.
'softdescriptorcity' => '', // A unique phone number, emaili address or URL, which is displayed on the account holder's statement.
);
echo '<pre>'; print_r($profileCreate);
die; */
if(!$this->paypal_pro->APICallSuccessful($PayPalResult['ACK']))
{
$errors = array('Errors'=>$PayPalResult['ERRORS']);
$this->load->view('paypal/samples/error',$errors);
}
else
{
// Successful call. Load view or whatever you need to do here.
$data = array('PayPalResult'=>$PayPalResult);
$this->load->view('paypal/samples/do_direct_payment',$data);
}
}
这段代码对我来说很好,我可以创建一个定期付款配置文件。当我运行这个脚本时,我得到了响应 ACK 成功
[PROFILEID] => I-1EF5JR4CKE8C
[PROFILESTATUS] => ActiveProfile
[TIMESTAMP] => 2016-08-24T07:07:06Z
[CORRELATIONID] => 13d41eec3fe72
[ACK] => Success
[VERSION] => 123.0
[BUILD] => 000000
现在我转到我的 Paypal 帐户,我可以看到一个 Paypal 经常性帐户已创建。但问题是在创建个人资料时没有收到 100 美元的金额。
【问题讨论】:
标签: php paypal codeigniter-3